mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:11:49 +00:00
Syntactic indexing policy toggle: UI and supporting APIs (with backcompat) (#64075)
Fixes GRAPH-751 Fixes GRAPH-636 Reverts sourcegraph/sourcegraph#64046 which itself was a revert of https://github.com/sourcegraph/sourcegraph/pull/63876 due to backwards compatibility concerns. This new PR adds two extra commits which restore the `indexingEnabled` field, and make `syntacticIndexingEnabled` field optional. --- Fixes GRAPH-636 Fixes GRAPH-751 This PR aims to allow admins to enable syntactic indexing on per-policy basis using the existing UI and APIs with the following amendments: - New UI toggle for syntactic indexing – **only visible if the experimental feature is enabled** (see screenshots below) - New field in GraphQL API for syntactic indexing - New Go resolvers to handle the new field To support this on the backend, we also update the policies handling code and SQL queries to ensure we can retrieve and update the `syntactic_indexing_enabled` field. <!-- PR description tips: https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e --> ## Test plan - Backend part covered by updated policies tests - Manual testing of UI With experimental feature **enabled**:  With experimental feature **disabled**:  <!-- REQUIRED; info at https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles --> ## Changelog - In site-admin APIs for updating code intelligence policies: - field `indexingEnabled` is renamed to `preciseIndexingEnabled` - a required `syntacticIndexingEnabled` is added (only takes effect if experimental feature is enabled) - field `forIndexing` is renamed to `forPreciseIndexing` <!-- OPTIONAL; info at https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c -->
This commit is contained in:
parent
5507a4a588
commit
7e5b52ea67
@ -23,7 +23,7 @@ export const POLICIES_CONFIGURATION = gql`
|
||||
$repository: ID
|
||||
$query: String
|
||||
$forDataRetention: Boolean
|
||||
$forIndexing: Boolean
|
||||
$forPreciseIndexing: Boolean
|
||||
$first: Int
|
||||
$after: String
|
||||
$protected: Boolean
|
||||
@ -32,7 +32,7 @@ export const POLICIES_CONFIGURATION = gql`
|
||||
repository: $repository
|
||||
query: $query
|
||||
forDataRetention: $forDataRetention
|
||||
forIndexing: $forIndexing
|
||||
forPreciseIndexing: $forPreciseIndexing
|
||||
first: $first
|
||||
after: $after
|
||||
protected: $protected
|
||||
@ -57,7 +57,7 @@ export const queryPolicies = (
|
||||
first,
|
||||
query,
|
||||
forDataRetention,
|
||||
forIndexing,
|
||||
forPreciseIndexing,
|
||||
after,
|
||||
protected: varProtected,
|
||||
}: Partial<CodeIntelligenceConfigurationPoliciesVariables>,
|
||||
@ -67,7 +67,7 @@ export const queryPolicies = (
|
||||
repository: repository ?? null,
|
||||
query: query ?? null,
|
||||
forDataRetention: forDataRetention ?? null,
|
||||
forIndexing: forIndexing ?? null,
|
||||
forPreciseIndexing: forPreciseIndexing ?? null,
|
||||
first: first ?? null,
|
||||
after: after ?? null,
|
||||
protected: varProtected ?? null,
|
||||
|
||||
@ -14,6 +14,7 @@ export const nullPolicy = {
|
||||
retentionDurationHours: null,
|
||||
retainIntermediateCommits: false,
|
||||
indexingEnabled: false,
|
||||
syntacticIndexingEnabled: false,
|
||||
indexCommitMaxAgeHours: null,
|
||||
indexIntermediateCommits: false,
|
||||
repository: null,
|
||||
@ -36,6 +37,7 @@ export const defaultCodeIntelligenceConfigurationPolicyFieldsFragment = gql`
|
||||
retentionDurationHours
|
||||
retainIntermediateCommits
|
||||
indexingEnabled
|
||||
syntacticIndexingEnabled
|
||||
indexCommitMaxAgeHours
|
||||
indexIntermediateCommits
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ const emptyPolicy: CodeIntelligenceConfigurationPolicyFields = {
|
||||
retentionDurationHours: null,
|
||||
retainIntermediateCommits: false,
|
||||
indexingEnabled: false,
|
||||
syntacticIndexingEnabled: false,
|
||||
indexCommitMaxAgeHours: null,
|
||||
indexIntermediateCommits: false,
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ const CREATE_POLICY_CONFIGURATION = gql`
|
||||
$retentionDurationHours: Int
|
||||
$retainIntermediateCommits: Boolean!
|
||||
$indexingEnabled: Boolean!
|
||||
$syntacticIndexingEnabled: Boolean!
|
||||
$indexCommitMaxAgeHours: Int
|
||||
$indexIntermediateCommits: Boolean!
|
||||
) {
|
||||
@ -28,6 +29,7 @@ const CREATE_POLICY_CONFIGURATION = gql`
|
||||
retentionDurationHours: $retentionDurationHours
|
||||
retainIntermediateCommits: $retainIntermediateCommits
|
||||
indexingEnabled: $indexingEnabled
|
||||
syntacticIndexingEnabled: $syntacticIndexingEnabled
|
||||
indexCommitMaxAgeHours: $indexCommitMaxAgeHours
|
||||
indexIntermediateCommits: $indexIntermediateCommits
|
||||
) {
|
||||
@ -47,6 +49,7 @@ const UPDATE_POLICY_CONFIGURATION = gql`
|
||||
$retentionDurationHours: Int
|
||||
$retainIntermediateCommits: Boolean!
|
||||
$indexingEnabled: Boolean!
|
||||
$syntacticIndexingEnabled: Boolean!
|
||||
$indexCommitMaxAgeHours: Int
|
||||
$indexIntermediateCommits: Boolean!
|
||||
) {
|
||||
@ -60,6 +63,7 @@ const UPDATE_POLICY_CONFIGURATION = gql`
|
||||
retentionDurationHours: $retentionDurationHours
|
||||
retainIntermediateCommits: $retainIntermediateCommits
|
||||
indexingEnabled: $indexingEnabled
|
||||
syntacticIndexingEnabled: $syntacticIndexingEnabled
|
||||
indexCommitMaxAgeHours: $indexCommitMaxAgeHours
|
||||
indexIntermediateCommits: $indexIntermediateCommits
|
||||
) {
|
||||
|
||||
@ -40,7 +40,7 @@ export interface CodeIntelConfigurationPageProps extends TelemetryProps, Telemet
|
||||
authenticatedUser: AuthenticatedUser | null
|
||||
queryPolicies?: typeof defaultQueryPolicies
|
||||
repo?: { id: string; name: string }
|
||||
indexingEnabled?: boolean
|
||||
preciseIndexingEnabled?: boolean
|
||||
telemetryService: TelemetryService
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ export const CodeIntelConfigurationPage: FunctionComponent<CodeIntelConfiguratio
|
||||
authenticatedUser,
|
||||
queryPolicies = defaultQueryPolicies,
|
||||
repo,
|
||||
indexingEnabled = window.context?.codeIntelAutoIndexingEnabled,
|
||||
preciseIndexingEnabled = window.context?.codeIntelAutoIndexingEnabled,
|
||||
telemetryService,
|
||||
telemetryRecorder,
|
||||
}) => {
|
||||
@ -129,8 +129,8 @@ export const CodeIntelConfigurationPage: FunctionComponent<CodeIntelConfiguratio
|
||||
]}
|
||||
description={
|
||||
<>
|
||||
Rules that control{indexingEnabled && <> auto-indexing and</>} data retention behavior of code
|
||||
graph data.
|
||||
Rules that control{preciseIndexingEnabled && <> precise auto-indexing and</>} data retention
|
||||
behavior of code graph data.
|
||||
</>
|
||||
}
|
||||
actions={authenticatedUser?.siteAdmin && <CreatePolicyButtons repo={repo} />}
|
||||
@ -159,7 +159,7 @@ export const CodeIntelConfigurationPage: FunctionComponent<CodeIntelConfiguratio
|
||||
noun="configuration policy"
|
||||
pluralNoun="configuration policies"
|
||||
nodeComponent={PoliciesNode}
|
||||
nodeComponentProps={{ isDeleting, onDelete, indexingEnabled }}
|
||||
nodeComponentProps={{ isDeleting, onDelete, preciseIndexingEnabled }}
|
||||
queryConnection={queryCustomPoliciesCallback}
|
||||
cursorPaging={true}
|
||||
filters={[
|
||||
@ -173,10 +173,10 @@ export const CodeIntelConfigurationPage: FunctionComponent<CodeIntelConfiguratio
|
||||
value: 'all',
|
||||
args: {},
|
||||
},
|
||||
...(indexingEnabled
|
||||
...(preciseIndexingEnabled
|
||||
? [
|
||||
{
|
||||
label: 'Policies affecting auto-indexing',
|
||||
label: 'Policies affecting precise precise auto-indexing',
|
||||
value: 'indexing',
|
||||
args: { forIndexing: true },
|
||||
},
|
||||
@ -206,7 +206,7 @@ export const CodeIntelConfigurationPage: FunctionComponent<CodeIntelConfiguratio
|
||||
noun="configuration policy"
|
||||
pluralNoun="configuration policies"
|
||||
nodeComponent={PoliciesNode}
|
||||
nodeComponentProps={{ indexingEnabled }}
|
||||
nodeComponentProps={{ preciseIndexingEnabled }}
|
||||
queryConnection={queryDefaultPoliciesCallback}
|
||||
emptyElement={<EmptyPoliciesList repo={repo} />}
|
||||
hideSearch={true}
|
||||
@ -220,30 +220,30 @@ export const CodeIntelConfigurationPage: FunctionComponent<CodeIntelConfiguratio
|
||||
|
||||
interface ProtectedPoliciesNodeProps {
|
||||
node: CodeIntelligenceConfigurationPolicyFields
|
||||
indexingEnabled?: boolean
|
||||
preciseIndexingEnabled?: boolean
|
||||
}
|
||||
|
||||
export interface UnprotectedPoliciesNodeProps {
|
||||
node: CodeIntelligenceConfigurationPolicyFields
|
||||
isDeleting: boolean
|
||||
onDelete: (id: string, name: string) => Promise<void>
|
||||
indexingEnabled?: boolean
|
||||
preciseIndexingEnabled?: boolean
|
||||
}
|
||||
|
||||
type PoliciesNodeProps = ProtectedPoliciesNodeProps | UnprotectedPoliciesNodeProps
|
||||
|
||||
export const PoliciesNode: FunctionComponent<React.PropsWithChildren<PoliciesNodeProps>> = ({
|
||||
node: policy,
|
||||
indexingEnabled = false,
|
||||
preciseIndexingEnabled = false,
|
||||
...props
|
||||
}) => (
|
||||
<>
|
||||
<span className={styles.separator} />
|
||||
|
||||
<div className={classNames(styles.name, 'd-flex flex-column')}>
|
||||
<PolicyDescription policy={policy} indexingEnabled={indexingEnabled} />
|
||||
<PolicyDescription policy={policy} preciseIndexingEnabled={preciseIndexingEnabled} />
|
||||
<RepositoryAndGitObjectDescription policy={policy} />
|
||||
{policy.indexingEnabled && indexingEnabled && <AutoIndexingDescription policy={policy} />}
|
||||
{policy.indexingEnabled && preciseIndexingEnabled && <AutoIndexingDescription policy={policy} />}
|
||||
{policy.retentionEnabled && <RetentionDescription policy={policy} />}
|
||||
</div>
|
||||
|
||||
@ -290,13 +290,13 @@ export const PoliciesNode: FunctionComponent<React.PropsWithChildren<PoliciesNod
|
||||
|
||||
interface PolicyDescriptionProps {
|
||||
policy: CodeIntelligenceConfigurationPolicyFields
|
||||
indexingEnabled?: boolean
|
||||
preciseIndexingEnabled?: boolean
|
||||
allowGlobalPolicies?: boolean
|
||||
}
|
||||
|
||||
const PolicyDescription: FunctionComponent<PolicyDescriptionProps> = ({
|
||||
policy,
|
||||
indexingEnabled = false,
|
||||
preciseIndexingEnabled = false,
|
||||
allowGlobalPolicies = window.context?.codeIntelAutoIndexingAllowGlobalPolicies,
|
||||
}) => (
|
||||
<div className={styles.policyDescription}>
|
||||
@ -312,7 +312,7 @@ const PolicyDescription: FunctionComponent<PolicyDescriptionProps> = ({
|
||||
</Text>
|
||||
</Link>
|
||||
|
||||
{!policy.retentionEnabled && !(indexingEnabled && policy.indexingEnabled) && (
|
||||
{!policy.retentionEnabled && !(preciseIndexingEnabled && policy.indexingEnabled) && (
|
||||
<Tooltip content="This policy has no enabled behaviors.">
|
||||
<Icon
|
||||
svgPath={mdiCircleOffOutline}
|
||||
@ -323,12 +323,12 @@ const PolicyDescription: FunctionComponent<PolicyDescriptionProps> = ({
|
||||
</Tooltip>
|
||||
)}
|
||||
|
||||
{indexingEnabled && !allowGlobalPolicies && hasGlobalPolicyViolation(policy) && (
|
||||
<Tooltip content="This Sourcegraph instance has disabled global policies for auto-indexing.">
|
||||
{preciseIndexingEnabled && !allowGlobalPolicies && hasGlobalPolicyViolation(policy) && (
|
||||
<Tooltip content="This Sourcegraph instance has disabled global policies for precise auto-indexing.">
|
||||
<Icon
|
||||
svgPath={mdiAlert}
|
||||
inline={true}
|
||||
aria-label="This Sourcegraph instance has disabled global policies for auto-indexing."
|
||||
aria-label="This Sourcegraph instance has disabled global policies for precise auto-indexing."
|
||||
className="text-warning ml-2"
|
||||
/>
|
||||
</Tooltip>
|
||||
@ -454,11 +454,11 @@ interface AutoIndexingDescriptionProps {
|
||||
|
||||
const AutoIndexingDescription: FunctionComponent<AutoIndexingDescriptionProps> = ({ policy }) => (
|
||||
<div>
|
||||
<Tooltip content="This policy affects auto-indexing.">
|
||||
<Tooltip content="This policy affects precise auto-indexing.">
|
||||
<Icon
|
||||
svgPath={mdiDatabaseClock}
|
||||
inline={true}
|
||||
aria-label="This policy affects auto-indexing."
|
||||
aria-label="This policy affects precise auto-indexing."
|
||||
className="mr-2"
|
||||
/>
|
||||
</Tooltip>
|
||||
|
||||
@ -61,8 +61,9 @@ const MS_IN_HOURS = 60 * 60 * 1000
|
||||
export interface CodeIntelConfigurationPolicyPageProps extends TelemetryProps, TelemetryV2Props {
|
||||
repo?: { id: string; name: string }
|
||||
authenticatedUser: AuthenticatedUser | null
|
||||
indexingEnabled?: boolean
|
||||
allowGlobalPolicies?: boolean
|
||||
preciseIndexingEnabled?: boolean
|
||||
syntacticIndexingEnabled?: boolean
|
||||
}
|
||||
|
||||
type PolicyUpdater = <K extends keyof CodeIntelligenceConfigurationPolicyFields>(updates: {
|
||||
@ -72,7 +73,8 @@ type PolicyUpdater = <K extends keyof CodeIntelligenceConfigurationPolicyFields>
|
||||
export const CodeIntelConfigurationPolicyPage: FunctionComponent<CodeIntelConfigurationPolicyPageProps> = ({
|
||||
repo,
|
||||
authenticatedUser,
|
||||
indexingEnabled = window.context?.codeIntelAutoIndexingEnabled,
|
||||
preciseIndexingEnabled = window.context?.codeIntelAutoIndexingEnabled,
|
||||
syntacticIndexingEnabled = window.context?.experimentalFeatures['codeintelSyntacticIndexing.enabled'] ?? false,
|
||||
allowGlobalPolicies = window.context?.codeIntelAutoIndexingAllowGlobalPolicies,
|
||||
telemetryService,
|
||||
telemetryRecorder,
|
||||
@ -206,8 +208,8 @@ export const CodeIntelConfigurationPolicyPage: FunctionComponent<CodeIntelConfig
|
||||
]}
|
||||
description={
|
||||
<>
|
||||
Rules that control{indexingEnabled && <> auto-indexing and</>} data retention behavior of code
|
||||
graph data.
|
||||
Rules that control{preciseIndexingEnabled && <> auto-indexing and</>} data retention behavior of
|
||||
code graph data.
|
||||
</>
|
||||
}
|
||||
className="mb-3"
|
||||
@ -227,7 +229,15 @@ export const CodeIntelConfigurationPolicyPage: FunctionComponent<CodeIntelConfig
|
||||
<GitConfiguration policy={policy} updatePolicy={updatePolicy} repo={repo} />
|
||||
{!policy.repository && <RepositorySettingsSection policy={policy} updatePolicy={updatePolicy} />}
|
||||
|
||||
{indexingEnabled && <IndexSettingsSection policy={policy} updatePolicy={updatePolicy} repo={repo} />}
|
||||
{(preciseIndexingEnabled || syntacticIndexingEnabled) && (
|
||||
<IndexSettingsSection
|
||||
policy={policy}
|
||||
updatePolicy={updatePolicy}
|
||||
repo={repo}
|
||||
syntacticIndexingEnabled={syntacticIndexingEnabled}
|
||||
preciseIndexingEnabled={preciseIndexingEnabled}
|
||||
/>
|
||||
)}
|
||||
<RetentionSettingsSection policy={policy} updatePolicy={updatePolicy} />
|
||||
|
||||
<div className="mt-4">
|
||||
@ -263,7 +273,7 @@ export const CodeIntelConfigurationPolicyPage: FunctionComponent<CodeIntelConfig
|
||||
{!policy.protected && policy.id !== '' && (
|
||||
<Tooltip
|
||||
content={`Deleting this policy may immediately affect data retention${
|
||||
indexingEnabled ? ' and auto-indexing' : ''
|
||||
preciseIndexingEnabled ? ' and auto-indexing' : ''
|
||||
}.`}
|
||||
>
|
||||
<Button
|
||||
@ -678,45 +688,79 @@ interface IndexSettingsSectionProps {
|
||||
policy: CodeIntelligenceConfigurationPolicyFields
|
||||
updatePolicy: PolicyUpdater
|
||||
repo?: { id: string; name: string }
|
||||
syntacticIndexingEnabled: boolean
|
||||
preciseIndexingEnabled: boolean
|
||||
}
|
||||
|
||||
const IndexSettingsSection: FunctionComponent<IndexSettingsSectionProps> = ({ policy, updatePolicy, repo }) => (
|
||||
<div className="form-group">
|
||||
<Label className="mb-0">
|
||||
Auto-indexing
|
||||
<div className={styles.toggleContainer}>
|
||||
<Toggle
|
||||
id="indexing-enabled"
|
||||
value={policy.indexingEnabled}
|
||||
className={styles.toggle}
|
||||
onToggle={indexingEnabled => {
|
||||
if (indexingEnabled) {
|
||||
updatePolicy({ indexingEnabled })
|
||||
} else {
|
||||
updatePolicy({
|
||||
indexingEnabled,
|
||||
indexIntermediateCommits: false,
|
||||
indexCommitMaxAgeHours: null,
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
const IndexSettingsSection: FunctionComponent<IndexSettingsSectionProps> = ({
|
||||
policy,
|
||||
updatePolicy,
|
||||
repo,
|
||||
syntacticIndexingEnabled,
|
||||
preciseIndexingEnabled,
|
||||
}) => (
|
||||
<div>
|
||||
{preciseIndexingEnabled && (
|
||||
<div className="form-group">
|
||||
<Label className="mb-0">
|
||||
Auto-indexing
|
||||
<div className={styles.toggleContainer}>
|
||||
<Toggle
|
||||
id="indexing-enabled"
|
||||
value={policy.indexingEnabled}
|
||||
className={styles.toggle}
|
||||
onToggle={preciseIndexingEnabled => {
|
||||
if (preciseIndexingEnabled) {
|
||||
updatePolicy({ indexingEnabled: preciseIndexingEnabled })
|
||||
} else {
|
||||
updatePolicy({
|
||||
indexingEnabled: preciseIndexingEnabled,
|
||||
indexIntermediateCommits: false,
|
||||
indexCommitMaxAgeHours: null,
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
<Text size="small" className="text-muted mb-0">
|
||||
Sourcegraph will automatically generate precise code intelligence data for matching
|
||||
{repo ? '' : ' repositories and'} revisions. Indexing configuration will be inferred from the
|
||||
content at matching revisions if not explicitly configured for{' '}
|
||||
{repo ? 'this repository' : 'matching repositories'}.{' '}
|
||||
{repo && (
|
||||
<>
|
||||
See this repository's <Link to="../index-configuration">index configuration</Link>.
|
||||
</>
|
||||
)}
|
||||
</Text>
|
||||
<Text size="small" className="text-muted mb-0">
|
||||
Sourcegraph will automatically generate precise code intelligence data for matching
|
||||
{repo ? '' : ' repositories and'} revisions. Indexing configuration will be inferred from
|
||||
the content at matching revisions if not explicitly configured for{' '}
|
||||
{repo ? 'this repository' : 'matching repositories'}.{' '}
|
||||
{repo && (
|
||||
<>
|
||||
See this repository's <Link to="../index-configuration">index configuration</Link>.
|
||||
</>
|
||||
)}
|
||||
</Text>
|
||||
</div>
|
||||
</Label>
|
||||
<IndexSettings policy={policy} updatePolicy={updatePolicy} />
|
||||
</div>
|
||||
</Label>
|
||||
)}
|
||||
|
||||
<IndexSettings policy={policy} updatePolicy={updatePolicy} />
|
||||
{syntacticIndexingEnabled && (
|
||||
<div className="form-group">
|
||||
<Label className="mb-0">
|
||||
Syntactic indexing
|
||||
<div className={styles.toggleContainer}>
|
||||
<Toggle
|
||||
id="syntactic-indexing-enabled"
|
||||
value={policy.syntacticIndexingEnabled ?? false}
|
||||
className={styles.toggle}
|
||||
onToggle={syntacticIndexingEnabled => {
|
||||
updatePolicy({ syntacticIndexingEnabled })
|
||||
}}
|
||||
/>
|
||||
|
||||
<Text size="small" className="text-muted mb-0">
|
||||
Sourcegraph will automatically generate syntactic code intelligence data for matching
|
||||
{repo ? '' : ' repositories and'} revisions.
|
||||
</Text>
|
||||
</div>
|
||||
</Label>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -913,6 +957,7 @@ function comparePolicies(
|
||||
a.retentionDurationHours === b.retentionDurationHours,
|
||||
a.retainIntermediateCommits === b.retainIntermediateCommits,
|
||||
a.indexingEnabled === b.indexingEnabled,
|
||||
a.syntacticIndexingEnabled === b.syntacticIndexingEnabled,
|
||||
a.indexCommitMaxAgeHours === b.indexCommitMaxAgeHours,
|
||||
a.indexIntermediateCommits === b.indexIntermediateCommits,
|
||||
comparePatterns(a.repositoryPatterns, b.repositoryPatterns),
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
extend type Query {
|
||||
"""
|
||||
Returns precise code intelligence configuration policies that control data retention
|
||||
and (if enabled) auto-indexing behavior.
|
||||
Returns code intelligence configuration policies for precise and
|
||||
syntactic indexing that control data retention and (if enabled) precise
|
||||
auto-indexing behavior.
|
||||
"""
|
||||
codeIntelligenceConfigurationPolicies(
|
||||
"""
|
||||
@ -23,10 +24,16 @@ extend type Query {
|
||||
forDataRetention: Boolean
|
||||
|
||||
"""
|
||||
If set to true, then only configuration policies with indexing enabled are returned.
|
||||
If set to false, then configuration policies with indexing enabled are filtered out.
|
||||
If set to true, then only configuration policies with precise indexing enabled are returned.
|
||||
If set to false, then configuration policies with precise indexing enabled are filtered out.
|
||||
"""
|
||||
forIndexing: Boolean
|
||||
forPreciseIndexing: Boolean
|
||||
|
||||
"""
|
||||
If set to true, then only configuration policies with syntactic indexing enabled are returned.
|
||||
If set to false, then configuration policies with syntactic indexing enabled are filtered out.
|
||||
"""
|
||||
forSyntacticIndexing: Boolean
|
||||
|
||||
"""
|
||||
If set to true, then only configuration policies with embeddings enabled are returned.
|
||||
@ -103,6 +110,7 @@ extend type Mutation {
|
||||
retentionDurationHours: Int
|
||||
retainIntermediateCommits: Boolean!
|
||||
indexingEnabled: Boolean!
|
||||
syntacticIndexingEnabled: Boolean
|
||||
indexCommitMaxAgeHours: Int
|
||||
indexIntermediateCommits: Boolean!
|
||||
|
||||
@ -128,6 +136,7 @@ extend type Mutation {
|
||||
retentionDurationHours: Int
|
||||
retainIntermediateCommits: Boolean!
|
||||
indexingEnabled: Boolean!
|
||||
syntacticIndexingEnabled: Boolean
|
||||
indexCommitMaxAgeHours: Int
|
||||
indexIntermediateCommits: Boolean!
|
||||
|
||||
@ -256,10 +265,15 @@ type CodeIntelligenceConfigurationPolicy implements Node {
|
||||
retainIntermediateCommits: Boolean!
|
||||
|
||||
"""
|
||||
Whether or not this configuration policy affects auto-indexing schedules.
|
||||
Whether or not this configuration policy affects precise indexing schedules.
|
||||
"""
|
||||
indexingEnabled: Boolean!
|
||||
|
||||
"""
|
||||
Whether or not this configuration policy affects syntactic indexing schedules.
|
||||
"""
|
||||
syntacticIndexingEnabled: Boolean
|
||||
|
||||
"""
|
||||
The max age of commits indexed by this configuration policy.
|
||||
"""
|
||||
|
||||
@ -165,6 +165,7 @@ SELECT
|
||||
p.retention_duration_hours,
|
||||
p.retain_intermediate_commits,
|
||||
p.indexing_enabled,
|
||||
p.syntactic_indexing_enabled,
|
||||
p.index_commit_max_age_hours,
|
||||
p.index_intermediate_commits,
|
||||
p.embeddings_enabled
|
||||
@ -207,6 +208,7 @@ SELECT
|
||||
p.retention_duration_hours,
|
||||
p.retain_intermediate_commits,
|
||||
p.indexing_enabled,
|
||||
p.syntactic_indexing_enabled,
|
||||
p.index_commit_max_age_hours,
|
||||
p.index_intermediate_commits,
|
||||
p.embeddings_enabled
|
||||
@ -237,7 +239,8 @@ func (s *store) CreateConfigurationPolicy(ctx context.Context, configurationPoli
|
||||
configurationPolicy.RetentionEnabled,
|
||||
retentionDurationHours,
|
||||
configurationPolicy.RetainIntermediateCommits,
|
||||
configurationPolicy.IndexingEnabled,
|
||||
configurationPolicy.PreciseIndexingEnabled,
|
||||
configurationPolicy.SyntacticIndexingEnabled,
|
||||
indexingCommitMaxAgeHours,
|
||||
configurationPolicy.IndexIntermediateCommits,
|
||||
configurationPolicy.EmbeddingEnabled,
|
||||
@ -260,10 +263,11 @@ INSERT INTO lsif_configuration_policies (
|
||||
retention_duration_hours,
|
||||
retain_intermediate_commits,
|
||||
indexing_enabled,
|
||||
syntactic_indexing_enabled,
|
||||
index_commit_max_age_hours,
|
||||
index_intermediate_commits,
|
||||
embeddings_enabled
|
||||
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
RETURNING
|
||||
id,
|
||||
repository_id,
|
||||
@ -276,6 +280,7 @@ RETURNING
|
||||
retention_duration_hours,
|
||||
retain_intermediate_commits,
|
||||
indexing_enabled,
|
||||
syntactic_indexing_enabled,
|
||||
index_commit_max_age_hours,
|
||||
index_intermediate_commits,
|
||||
embeddings_enabled
|
||||
@ -323,7 +328,8 @@ func (s *store) UpdateConfigurationPolicy(ctx context.Context, policy shared.Con
|
||||
policy.RetentionEnabled,
|
||||
retentionDuration,
|
||||
policy.RetainIntermediateCommits,
|
||||
policy.IndexingEnabled,
|
||||
policy.PreciseIndexingEnabled,
|
||||
policy.SyntacticIndexingEnabled,
|
||||
indexCommitMaxAge,
|
||||
policy.IndexIntermediateCommits,
|
||||
policy.EmbeddingEnabled,
|
||||
@ -345,6 +351,7 @@ SELECT
|
||||
retention_duration_hours,
|
||||
retain_intermediate_commits,
|
||||
indexing_enabled,
|
||||
syntactic_indexing_enabled,
|
||||
index_commit_max_age_hours,
|
||||
index_intermediate_commits,
|
||||
embeddings_enabled
|
||||
@ -363,6 +370,7 @@ UPDATE lsif_configuration_policies SET
|
||||
retention_duration_hours = %s,
|
||||
retain_intermediate_commits = %s,
|
||||
indexing_enabled = %s,
|
||||
syntactic_indexing_enabled = %s,
|
||||
index_commit_max_age_hours = %s,
|
||||
index_intermediate_commits = %s,
|
||||
embeddings_enabled = %s
|
||||
@ -430,7 +438,8 @@ func scanConfigurationPolicy(s dbutil.Scanner) (configurationPolicy shared.Confi
|
||||
&configurationPolicy.RetentionEnabled,
|
||||
&retentionDurationHours,
|
||||
&configurationPolicy.RetainIntermediateCommits,
|
||||
&configurationPolicy.IndexingEnabled,
|
||||
&configurationPolicy.PreciseIndexingEnabled,
|
||||
&configurationPolicy.SyntacticIndexingEnabled,
|
||||
&indexCommitMaxAgeHours,
|
||||
&configurationPolicy.IndexIntermediateCommits,
|
||||
&configurationPolicy.EmbeddingEnabled,
|
||||
|
||||
@ -209,7 +209,8 @@ func TestDeleteConfigurationPolicyByID(t *testing.T) {
|
||||
RetentionEnabled: false,
|
||||
RetentionDuration: &d1,
|
||||
RetainIntermediateCommits: true,
|
||||
IndexingEnabled: false,
|
||||
PreciseIndexingEnabled: false,
|
||||
SyntacticIndexingEnabled: false,
|
||||
IndexCommitMaxAge: &d2,
|
||||
IndexIntermediateCommits: true,
|
||||
}
|
||||
@ -253,7 +254,8 @@ func TestDeleteConfigurationProtectedPolicy(t *testing.T) {
|
||||
RetentionEnabled: false,
|
||||
RetentionDuration: &d1,
|
||||
RetainIntermediateCommits: true,
|
||||
IndexingEnabled: false,
|
||||
PreciseIndexingEnabled: false,
|
||||
SyntacticIndexingEnabled: false,
|
||||
IndexCommitMaxAge: &d2,
|
||||
IndexIntermediateCommits: true,
|
||||
}
|
||||
|
||||
@ -190,6 +190,7 @@ RETURNING
|
||||
retention_duration_hours,
|
||||
retain_intermediate_commits,
|
||||
indexing_enabled,
|
||||
syntactic_indexing_enabled,
|
||||
index_commit_max_age_hours,
|
||||
index_intermediate_commits,
|
||||
embeddings_enabled
|
||||
|
||||
@ -13,7 +13,8 @@ type ConfigurationPolicy struct {
|
||||
RetentionEnabled bool
|
||||
RetentionDuration *time.Duration
|
||||
RetainIntermediateCommits bool
|
||||
IndexingEnabled bool
|
||||
PreciseIndexingEnabled bool
|
||||
SyntacticIndexingEnabled bool
|
||||
IndexCommitMaxAge *time.Duration
|
||||
IndexIntermediateCommits bool
|
||||
EmbeddingEnabled bool
|
||||
|
||||
@ -20,6 +20,8 @@ type configurationPolicyResolver struct {
|
||||
errTracer *observation.ErrCollector
|
||||
}
|
||||
|
||||
var _ resolverstubs.CodeIntelligenceConfigurationPolicyResolver = &configurationPolicyResolver{}
|
||||
|
||||
func NewConfigurationPolicyResolver(repoStore database.RepoStore, configurationPolicy shared.ConfigurationPolicy, errTracer *observation.ErrCollector) resolverstubs.CodeIntelligenceConfigurationPolicyResolver {
|
||||
return &configurationPolicyResolver{
|
||||
repoStore: repoStore,
|
||||
@ -93,8 +95,15 @@ func (r *configurationPolicyResolver) RetainIntermediateCommits() bool {
|
||||
return r.configurationPolicy.RetainIntermediateCommits
|
||||
}
|
||||
|
||||
// NOTE: the names differ to preserve the backwards compatibility -
|
||||
// the field has to remain named indexingEnabled in generated
|
||||
// GraphQL API
|
||||
func (r *configurationPolicyResolver) IndexingEnabled() bool {
|
||||
return r.configurationPolicy.IndexingEnabled
|
||||
return r.configurationPolicy.PreciseIndexingEnabled
|
||||
}
|
||||
|
||||
func (r *configurationPolicyResolver) SyntacticIndexingEnabled() *bool {
|
||||
return &r.configurationPolicy.SyntacticIndexingEnabled
|
||||
}
|
||||
|
||||
func (r *configurationPolicyResolver) IndexCommitMaxAgeHours() *int32 {
|
||||
|
||||
@ -48,7 +48,8 @@ func (r *rootResolver) CreateCodeIntelligenceConfigurationPolicy(ctx context.Con
|
||||
RetentionEnabled: args.RetentionEnabled,
|
||||
RetentionDuration: toDuration(args.RetentionDurationHours),
|
||||
RetainIntermediateCommits: args.RetainIntermediateCommits,
|
||||
IndexingEnabled: args.IndexingEnabled,
|
||||
PreciseIndexingEnabled: args.IndexingEnabled,
|
||||
SyntacticIndexingEnabled: *args.SyntacticIndexingEnabled,
|
||||
IndexCommitMaxAge: toDuration(args.IndexCommitMaxAgeHours),
|
||||
IndexIntermediateCommits: args.IndexIntermediateCommits,
|
||||
EmbeddingEnabled: args.EmbeddingsEnabled != nil && *args.EmbeddingsEnabled,
|
||||
@ -90,7 +91,8 @@ func (r *rootResolver) UpdateCodeIntelligenceConfigurationPolicy(ctx context.Con
|
||||
RetentionEnabled: args.RetentionEnabled,
|
||||
RetentionDuration: toDuration(args.RetentionDurationHours),
|
||||
RetainIntermediateCommits: args.RetainIntermediateCommits,
|
||||
IndexingEnabled: args.IndexingEnabled,
|
||||
PreciseIndexingEnabled: args.IndexingEnabled,
|
||||
SyntacticIndexingEnabled: *args.SyntacticIndexingEnabled,
|
||||
IndexCommitMaxAge: toDuration(args.IndexCommitMaxAgeHours),
|
||||
IndexIntermediateCommits: args.IndexIntermediateCommits,
|
||||
EmbeddingEnabled: args.EmbeddingsEnabled != nil && *args.EmbeddingsEnabled,
|
||||
@ -125,11 +127,6 @@ func (r *rootResolver) DeleteCodeIntelligenceConfigurationPolicy(ctx context.Con
|
||||
return resolverstubs.Empty, nil
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
const maxDurationHours = 87600 // 10 years
|
||||
|
||||
func validateConfigurationPolicy(policy resolverstubs.CodeIntelConfigurationPolicy) error {
|
||||
@ -159,8 +156,8 @@ func validateConfigurationPolicy(policy resolverstubs.CodeIntelConfigurationPoli
|
||||
}
|
||||
|
||||
if policy.EmbeddingsEnabled != nil && *policy.EmbeddingsEnabled {
|
||||
if policy.RetentionEnabled || policy.IndexingEnabled {
|
||||
return errors.Errorf("configuration policies can apply to SCIP indexes or embeddings, but not both")
|
||||
if policy.RetentionEnabled || policy.IndexingEnabled || *policy.SyntacticIndexingEnabled {
|
||||
return errors.Errorf("configuration policies can apply to indexing (precise or syntactic) or embeddings, but not both")
|
||||
}
|
||||
|
||||
if shared.GitObjectType(policy.Type) != shared.GitObjectTypeCommit {
|
||||
|
||||
@ -22,7 +22,7 @@ func (r *rootResolver) CodeIntelligenceConfigurationPolicies(ctx context.Context
|
||||
attribute.String("repository", string(pointers.Deref(args.Repository, ""))),
|
||||
attribute.String("query", pointers.Deref(args.Query, "")),
|
||||
attribute.Bool("forDataRetention", pointers.Deref(args.ForDataRetention, false)),
|
||||
attribute.Bool("forIndexing", pointers.Deref(args.ForIndexing, false)),
|
||||
attribute.Bool("forPreciseIndexing", pointers.Deref(args.ForPreciseIndexing, false)),
|
||||
attribute.Bool("protected", pointers.Deref(args.Protected, false)),
|
||||
}})
|
||||
endObservation.OnCancel(ctx, 1, observation.Args{})
|
||||
@ -48,7 +48,7 @@ func (r *rootResolver) CodeIntelligenceConfigurationPolicies(ctx context.Context
|
||||
}
|
||||
opts.Protected = args.Protected
|
||||
opts.ForDataRetention = args.ForDataRetention
|
||||
opts.ForPreciseIndexing = args.ForIndexing
|
||||
opts.ForPreciseIndexing = args.ForPreciseIndexing
|
||||
opts.ForEmbeddings = args.ForEmbeddings
|
||||
|
||||
configPolicies, totalCount, err := r.policySvc.GetConfigurationPolicies(ctx, opts)
|
||||
|
||||
@ -25,12 +25,13 @@ type PoliciesServiceResolver interface {
|
||||
|
||||
type CodeIntelligenceConfigurationPoliciesArgs struct {
|
||||
PagedConnectionArgs
|
||||
Repository *graphql.ID
|
||||
Query *string
|
||||
ForDataRetention *bool
|
||||
ForIndexing *bool
|
||||
ForEmbeddings *bool
|
||||
Protected *bool
|
||||
Repository *graphql.ID
|
||||
Query *string
|
||||
ForDataRetention *bool
|
||||
ForPreciseIndexing *bool
|
||||
ForSyntacticIndexing *bool
|
||||
ForEmbeddings *bool
|
||||
Protected *bool
|
||||
}
|
||||
|
||||
type CreateCodeIntelligenceConfigurationPolicyArgs struct {
|
||||
@ -48,6 +49,7 @@ type CodeIntelConfigurationPolicy struct {
|
||||
RetentionDurationHours *int32
|
||||
RetainIntermediateCommits bool
|
||||
IndexingEnabled bool
|
||||
SyntacticIndexingEnabled *bool
|
||||
IndexCommitMaxAgeHours *int32
|
||||
IndexIntermediateCommits bool
|
||||
// EmbeddingsEnabled, if nil, should currently default to false.
|
||||
@ -92,6 +94,7 @@ type CodeIntelligenceConfigurationPolicyResolver interface {
|
||||
RetentionDurationHours() *int32
|
||||
RetainIntermediateCommits() bool
|
||||
IndexingEnabled() bool
|
||||
SyntacticIndexingEnabled() *bool
|
||||
IndexCommitMaxAgeHours() *int32
|
||||
IndexIntermediateCommits() bool
|
||||
EmbeddingsEnabled() bool
|
||||
|
||||
Loading…
Reference in New Issue
Block a user