Report imported built-in products in session inspection
This commit is contained in:
@@ -193,6 +193,9 @@ Reports definitions, dependencies, local availability/evidence, and optional
|
||||
remote publication state without reading artifact payload bodies. Without
|
||||
`--remote`, this command avoids remote artifact inspection. Remote entries use
|
||||
the selected publication inventory and current lock state.
|
||||
For built-ins, `recorded` identifies producer-output or supplied-product manifest
|
||||
evidence; supplied entries carry `manifest.supplied_product` provenance.
|
||||
Consumer resolution performs the corresponding payload validation.
|
||||
|
||||
## Session init
|
||||
|
||||
|
||||
@@ -92,7 +92,14 @@ entry ticket for otherwise valid artifact-only continuation.
|
||||
|
||||
## 3. P3: Include supplied built-ins in local artifact inspection
|
||||
|
||||
Status: Open
|
||||
Status: Complete
|
||||
|
||||
Resolution: built-in inspection reports canonical supplied records as recorded
|
||||
with supplied-product provenance, retaining its payload-free evidence view.
|
||||
A command-level regression checks both status and artifact inspection after an
|
||||
actual import, alongside local rendering evidence and absent intermediate
|
||||
products, and verifies that inspection leaves the manifest unchanged. Verified
|
||||
with `go test ./internal/app ./internal/doccheck`.
|
||||
|
||||
Affected stages: 3, 5, and 13.
|
||||
|
||||
|
||||
@@ -105,6 +105,72 @@ func TestSessionArtifactCommandIsLocalWithoutRemoteOption(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionInspectionReportsImportedAndLocalBuiltIns(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
pipeline, campaign, session := writeValidConfigFiles(t, t.TempDir())
|
||||
cfg, err := config.LoadWithSessionOptions(pipeline, campaign, session, config.SessionLoadOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fake := &storage.FakeBackend{}
|
||||
seedCommittedRestoreSnapshot(t, cfg, fake, "20260519T010203Z-a1b2c3d4", map[string][]byte{"transcripts/final.trimmed.json": []byte(`{"segments":[]}`)})
|
||||
if _, err := restoreSessionState(ctx, cfg, RestorePlanOptions{}, normalizeCommandDependencies(restoreCommandDependencies(fake))); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
paths := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
m, err := (&manifest.LocalStore{}).Load(ctx, paths.ManifestPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := artifacts.ResolveSessionArtifact(paths, m, artifacts.ArtifactTranscriptFinalTrimmed); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
markdown := filepath.Join(paths.TranscriptsDir, "final.trimmed.md")
|
||||
mustWriteTestFile(t, markdown, "# Local rendering\n")
|
||||
setCurrentBuiltInEvidence(t, m, "render", artifacts.TranscriptOutputKindFinalTrimmedMarkdown, artifacts.ArtifactTranscriptFinalTrimmedMarkdown, markdown)
|
||||
saveBoundedManifest(t, cfg, m)
|
||||
before, err := os.ReadFile(paths.ManifestPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
deps, _ := remoteSessionLoaderDependencies(fake)
|
||||
app, err := newApplication(deps, executePlan)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, command := range []string{"status", "artifacts"} {
|
||||
var out, diagnostic bytes.Buffer
|
||||
outcome := app.Execute(ctx, []string{"session", command, cfg.Session.SessionID, "--config", pipeline, "--campaign-file", campaign, "--session-file", session, "--format", "json"}, commandkit.Streams{Out: &out, Err: &diagnostic})
|
||||
if outcome.Status != 0 {
|
||||
t.Fatalf("%s: %v (%s)", command, outcome.Cause, diagnostic.String())
|
||||
}
|
||||
var report sessionStateReport
|
||||
if err := json.Unmarshal(out.Bytes(), &report); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
states := map[string]sessionArtifactState{}
|
||||
for _, entry := range report.Artifacts {
|
||||
states[entry.Source] = entry
|
||||
}
|
||||
imported := states[artifacts.ArtifactTranscriptFinalTrimmed]
|
||||
if imported.Availability != "recorded" || imported.Provenance != artifacts.ArtifactProvenanceSupplied {
|
||||
t.Fatalf("%s supplied product = %+v", command, imported)
|
||||
}
|
||||
if states[artifacts.ArtifactTranscriptFinalTrimmedMarkdown].Availability != "recorded" {
|
||||
t.Fatalf("%s local rendering = %+v", command, states[artifacts.ArtifactTranscriptFinalTrimmedMarkdown])
|
||||
}
|
||||
for _, source := range []string{artifacts.ArtifactTranscriptBase, artifacts.ArtifactTranscriptPolished, artifacts.ArtifactTranscriptFinal, artifacts.ArtifactBoundsSession} {
|
||||
if states[source].Availability != "unavailable" {
|
||||
t.Fatalf("%s invented intermediate product: %+v", command, states[source])
|
||||
}
|
||||
}
|
||||
}
|
||||
after, err := os.ReadFile(paths.ManifestPath)
|
||||
if err != nil || !bytes.Equal(before, after) {
|
||||
t.Fatalf("inspection changed the manifest: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionStateCommandReturnsPartialRemoteFailure(t *testing.T) {
|
||||
pipeline, campaign, session := writeValidConfigFiles(t, t.TempDir())
|
||||
failure := errors.New("synthetic remote failure")
|
||||
|
||||
@@ -152,7 +152,7 @@ func inspectSessionState(ctx context.Context, cfg *config.Config, status, remote
|
||||
state = "available"
|
||||
}
|
||||
if definition.Key == "" {
|
||||
state = builtinArtifactInspectionState(local, entry)
|
||||
state, entry.Provenance = builtinArtifactInspectionState(local, entry)
|
||||
}
|
||||
report.Artifacts = append(report.Artifacts, sessionArtifactState{artifactDefinitionReport: definition, Availability: state, Provenance: entry.Provenance})
|
||||
}
|
||||
@@ -241,20 +241,28 @@ func inspectSessionState(ctx context.Context, cfg *config.Config, status, remote
|
||||
}
|
||||
|
||||
// Built-in inspection reports manifest evidence without opening artifact payloads.
|
||||
func builtinArtifactInspectionState(local *manifest.Manifest, entry artifacts.CatalogEntry) string {
|
||||
func builtinArtifactInspectionState(local *manifest.Manifest, entry artifacts.CatalogEntry) (string, string) {
|
||||
if local == nil {
|
||||
return "unavailable"
|
||||
return "unavailable", ""
|
||||
}
|
||||
if local.SuppliedProducts != nil {
|
||||
if supplied, ok := local.SuppliedProducts.Products[entry.SourceID]; ok {
|
||||
if supplied.Path == entry.CanonicalRelPath {
|
||||
return "recorded", artifacts.ArtifactProvenanceSupplied
|
||||
}
|
||||
return "unavailable", ""
|
||||
}
|
||||
}
|
||||
record := local.Stages[entry.ProducerStage]
|
||||
if record == nil || record.Status != manifest.StatusSucceeded {
|
||||
return "unavailable"
|
||||
return "unavailable", ""
|
||||
}
|
||||
for _, output := range record.Outputs {
|
||||
if output.Kind == entry.OutputKind {
|
||||
return "recorded"
|
||||
return "recorded", ""
|
||||
}
|
||||
}
|
||||
return "unavailable"
|
||||
return "unavailable", ""
|
||||
}
|
||||
|
||||
func inspectPublishedOutputs(ctx context.Context, cfg *config.Config, store storage.ObjectStore, catalog *artifacts.ArtifactCatalog, current *RemoteCurrentState, locks []artifacts.RemoteLock, locksKnown bool, remoteState string) ([]sessionPublishedOutput, error) {
|
||||
|
||||
Reference in New Issue
Block a user