Look up family identities without copying catalogs
This commit is contained in:
@@ -244,6 +244,12 @@ configuration algorithms.
|
|||||||
|
|
||||||
## 6. P3: Avoid cloning the complete family catalog for individual origins
|
## 6. P3: Avoid cloning the complete family catalog for individual origins
|
||||||
|
|
||||||
|
Status: Completed. Resume reports, checkpoint records, and analysis diagnostics
|
||||||
|
use a constant-time member lookup returning only scalar family/character identity.
|
||||||
|
Origin lookup work is `O(L)` with no whole-catalog copies. Detached full records
|
||||||
|
remain available through the existing catalog-copy API. Focused analysis, family,
|
||||||
|
planning, and catalog tests pass.
|
||||||
|
|
||||||
Stages: 5 and 11; artifact evidence in Stage 15.
|
Stages: 5 and 11; artifact evidence in Stage 15.
|
||||||
|
|
||||||
Locations: `internal/stage/analyze_resume.go:88–103`,
|
Locations: `internal/stage/analyze_resume.go:88–103`,
|
||||||
|
|||||||
@@ -75,6 +75,16 @@ func ArtifactFamilies(catalog *ArtifactCatalog) ArtifactFamilyCatalog {
|
|||||||
return cloneArtifactFamilyCatalog(catalog.Families)
|
return cloneArtifactFamilyCatalog(catalog.Families)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ArtifactFamilyIdentity returns a member's scalar provenance without copying
|
||||||
|
// the family catalog or exposing its mutable dependency and input collections.
|
||||||
|
func ArtifactFamilyIdentity(catalog *ArtifactCatalog, key string) (family, characterID string, ok bool) {
|
||||||
|
if catalog == nil {
|
||||||
|
return "", "", false
|
||||||
|
}
|
||||||
|
member, ok := catalog.Families.Members[key]
|
||||||
|
return member.Family, member.CharacterID, ok
|
||||||
|
}
|
||||||
|
|
||||||
// CampaignsConfig configures the local campaign registry.
|
// CampaignsConfig configures the local campaign registry.
|
||||||
type CampaignsConfig struct {
|
type CampaignsConfig struct {
|
||||||
Root string `yaml:"root" json:"root"`
|
Root string `yaml:"root" json:"root"`
|
||||||
|
|||||||
@@ -176,12 +176,11 @@ func (analyzeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*S
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func analyzeArtifactOrigin(execution analyzeExecutionContext, key string) (config.ArtifactFamilyMemberOrigin, bool) {
|
func analyzeArtifactOrigin(execution analyzeExecutionContext, key string) (family, characterID string, ok bool) {
|
||||||
if execution.Env == nil || execution.Env.Config == nil || execution.Env.Config.Pipeline == nil {
|
if execution.Env == nil || execution.Env.Config == nil || execution.Env.Config.Pipeline == nil {
|
||||||
return config.ArtifactFamilyMemberOrigin{}, false
|
return "", "", false
|
||||||
}
|
}
|
||||||
origin, ok := config.ArtifactFamilies(execution.Env.Config.ArtifactCatalog).Members[key]
|
return config.ArtifactFamilyIdentity(execution.Env.Config.ArtifactCatalog, key)
|
||||||
return origin, ok
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func artifactCfgMap(execution analyzeExecutionContext) map[string]config.ScriptoriumArtifactConfig {
|
func artifactCfgMap(execution analyzeExecutionContext) map[string]config.ScriptoriumArtifactConfig {
|
||||||
@@ -242,9 +241,9 @@ func currentAnalyzeArtifactRecord(
|
|||||||
Logs: dedupeAndSortPaths(result.Logs),
|
Logs: dedupeAndSortPaths(result.Logs),
|
||||||
GeneratedConfigs: dedupeAndSortPaths(result.GeneratedConfigs),
|
GeneratedConfigs: dedupeAndSortPaths(result.GeneratedConfigs),
|
||||||
}
|
}
|
||||||
if origin, ok := analyzeArtifactOrigin(execution, plan.Name); ok {
|
if family, characterID, ok := analyzeArtifactOrigin(execution, plan.Name); ok {
|
||||||
record.Family = origin.Family
|
record.Family = family
|
||||||
record.CharacterID = origin.CharacterID
|
record.CharacterID = characterID
|
||||||
}
|
}
|
||||||
if err := manifest.ValidateAnalyzeArtifactCollection(
|
if err := manifest.ValidateAnalyzeArtifactCollection(
|
||||||
manifest.AnalyzeStateContractVersion,
|
manifest.AnalyzeStateContractVersion,
|
||||||
|
|||||||
@@ -166,9 +166,9 @@ func (state *analyzeExecutionState) checkpointCollection(
|
|||||||
func (state *analyzeExecutionState) collectDiagnostics(name string, result *analyzeArtifactExecutionResult) {
|
func (state *analyzeExecutionState) collectDiagnostics(name string, result *analyzeArtifactExecutionResult) {
|
||||||
state.logs = append(state.logs, result.Logs...)
|
state.logs = append(state.logs, result.Logs...)
|
||||||
state.generatedConfigs = append(state.generatedConfigs, result.GeneratedConfigs...)
|
state.generatedConfigs = append(state.generatedConfigs, result.GeneratedConfigs...)
|
||||||
if origin, ok := analyzeArtifactOrigin(state.execution, name); ok {
|
if family, characterID, ok := analyzeArtifactOrigin(state.execution, name); ok {
|
||||||
result.Metadata["family"] = origin.Family
|
result.Metadata["family"] = family
|
||||||
result.Metadata["character_id"] = origin.CharacterID
|
result.Metadata["character_id"] = characterID
|
||||||
}
|
}
|
||||||
state.artifactMetadata = append(state.artifactMetadata, result.Metadata)
|
state.artifactMetadata = append(state.artifactMetadata, result.Metadata)
|
||||||
for _, reused := range result.ReusedArtifacts {
|
for _, reused := range result.ReusedArtifacts {
|
||||||
@@ -197,9 +197,9 @@ func (state *analyzeExecutionState) failedResult(
|
|||||||
UpdatedAt: time.Now().UTC(),
|
UpdatedAt: time.Now().UTC(),
|
||||||
Error: NonResumable(cause.Error()).Reason,
|
Error: NonResumable(cause.Error()).Reason,
|
||||||
}
|
}
|
||||||
if origin, ok := analyzeArtifactOrigin(state.execution, item.Key); ok {
|
if family, characterID, ok := analyzeArtifactOrigin(state.execution, item.Key); ok {
|
||||||
record.Family = origin.Family
|
record.Family = family
|
||||||
record.CharacterID = origin.CharacterID
|
record.CharacterID = characterID
|
||||||
}
|
}
|
||||||
if fingerprint != "" {
|
if fingerprint != "" {
|
||||||
record.FingerprintVersion = manifest.AnalyzeFingerprintContractVersion
|
record.FingerprintVersion = manifest.AnalyzeFingerprintContractVersion
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ func exportAnalyzeResumeItems(items []analyzePlanItem, catalog *config.ArtifactC
|
|||||||
entry := AnalyzeResumeArtifact{
|
entry := AnalyzeResumeArtifact{
|
||||||
Key: item.Key, Role: string(item.Role), Reason: string(item.Reason), Forced: item.Forced,
|
Key: item.Key, Role: string(item.Role), Reason: string(item.Reason), Forced: item.Forced,
|
||||||
}
|
}
|
||||||
if origin, ok := config.ArtifactFamilies(catalog).Members[item.Key]; ok {
|
if family, characterID, ok := config.ArtifactFamilyIdentity(catalog, item.Key); ok {
|
||||||
entry.Family, entry.CharacterID = origin.Family, origin.CharacterID
|
entry.Family, entry.CharacterID = family, characterID
|
||||||
}
|
}
|
||||||
result = append(result, entry)
|
result = append(result, entry)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user