Reuse artifact dependents during analysis

This commit is contained in:
2026-12-02 21:20:37 +00:00
parent 19b720742e
commit 9ae5443073
4 changed files with 15 additions and 33 deletions

View File

@@ -41,10 +41,10 @@ their scope. Unless assigned otherwise, a finding remains independent audit
remediation. Shared code does not make a refactoring a prerequisite or assign
the whole finding to a roadmap.
Twenty-eight entries are closed by the safety, transfer, audio discovery, S3
Twenty-nine entries are closed by the safety, transfer, audio discovery, S3
planning, prerequisite-history, publication-import, CLI classification,
inspection aggregation, test maintenance, dead-code removal, and associated
documentation work; 15 remain open. **Planned** identifies
documentation work; 14 remain open. **Planned** identifies
an agreed remedy awaiting implementation. **Potentially eliminated** requires verification that the offending
lifecycle is removed. **Coordinate** identifies shared changes, not a commitment
that a related feature implements the entire finding. Findings close only after their
@@ -559,7 +559,10 @@ Related: [CAT-10](#cat-10--p2-hydrate-previous-inputs-for-the-full-analysis-prer
### CAT-18 — P3: Reuse the analysis reverse-dependency index within an invocation
Status: Open
Status: Closed
**Closure.** Analysis reuses its operation-owned graph for success and failure
invalidation, including eligibility barriers. Analyze and checkpoint tests pass.
Original findings: [EF-02](02-efficiency.md#ef-02--p3-analysis-rebuilds-the-same-dependency-index-after-each-completion).

View File

@@ -277,7 +277,7 @@ Validation: `go test ./internal/config ./internal/artifactdeps ./internal/artifa
## Stage 8: Reuse Reverse Dependencies Throughout Analysis
CAT IDs: CAT-18. Status: Pending.
CAT IDs: CAT-18. Status: Complete.
Read [EF-02](audit/02-efficiency.md#ef-02--p3-analysis-rebuilds-the-same-dependency-index-after-each-completion)
and `stage/analyze.go`, `analyze_execution_state.go`, and checkpoint tests.

View File

@@ -200,11 +200,11 @@ func artifactCfgMap(execution analyzeExecutionContext) map[string]config.Scripto
}
func staleAnalyzeDependents(
configured map[string]config.ScriptoriumArtifactConfig,
graph *artifactdeps.Graph,
changed string,
records map[string]manifest.AnalyzeArtifactRecord,
) {
staleAnalyzeDependentClosure(configured, changed, records, nil)
staleAnalyzeDependentClosure(graph, changed, records, nil)
}
func currentAnalyzeArtifactRecord(
@@ -284,46 +284,25 @@ func sameAnalyzeOutputIdentity(left, right manifest.AnalyzeArtifactRecord) bool
}
func staleUnscheduledAnalyzeDependents(
configured map[string]config.ScriptoriumArtifactConfig,
graph *artifactdeps.Graph,
changed string,
currentKeys map[string]struct{},
records map[string]manifest.AnalyzeArtifactRecord,
) {
staleAnalyzeDependentClosure(configured, changed, records, func(key string) bool {
staleAnalyzeDependentClosure(graph, changed, records, func(key string) bool {
_, evaluated := currentKeys[key]
return !evaluated
})
}
func staleAnalyzeDependentClosure(
configured map[string]config.ScriptoriumArtifactConfig,
graph *artifactdeps.Graph,
changed string,
records map[string]manifest.AnalyzeArtifactRecord,
eligible func(string) bool,
) {
reverse := make(map[string][]string, len(configured))
for key, artifactCfg := range configured {
for _, dependency := range artifacts.NormalizedDependencyKeys(artifactCfg.DependsOn) {
reverse[dependency] = append(reverse[dependency], key)
}
}
for key := range reverse {
sort.Strings(reverse[key])
}
queue := append([]string(nil), reverse[changed]...)
seen := make(map[string]struct{}, len(queue))
for len(queue) > 0 {
key := queue[0]
queue = queue[1:]
if _, visited := seen[key]; visited {
continue
}
seen[key] = struct{}{}
if eligible != nil && !eligible(key) {
continue
}
for _, key := range graph.Dependents(changed, eligible) {
staleAnalyzeRecord(records, key)
queue = append(queue, reverse[key]...)
}
}

View File

@@ -93,7 +93,7 @@ func (state *analyzeExecutionState) acceptArtifact(
prior, hadPrior := state.priorCurrentRecords[plan.Name]
if !hadPrior || !sameAnalyzeOutputIdentity(prior, record) {
staleUnscheduledAnalyzeDependents(
artifactCfgMap(state.execution),
state.execution.Graph,
plan.Name,
state.evaluatedKeys,
state.records,
@@ -229,7 +229,7 @@ func (state *analyzeExecutionState) failedResult(
}
}
state.records[item.Key] = record
staleAnalyzeDependents(artifactCfgMap(state.execution), item.Key, state.records)
staleAnalyzeDependents(state.execution.Graph, item.Key, state.records)
state.installManifestCollection()
return &StageResult{}
}