201 lines
12 KiB
Markdown
201 lines
12 KiB
Markdown
# CAT-13: Accurate S3 Planning and Preflight Checks
|
|
|
|
Status: Complete
|
|
|
|
## Purpose and scope
|
|
|
|
Implement [CAT-13](audit/catalog.md#cat-13--p2-give-s3-session-planning-the-evidence-needed-for-truthful-reuse-decisions)
|
|
and the [approved planning/preflight decision](audit/discussion.md#3-inspect-s3-when-planning-and-preflighting).
|
|
Planning must receive the S3 identity evidence needed to predict preparation
|
|
reuse accurately. Preflight must use its existing preparation checks and report
|
|
source-access failures accurately.
|
|
|
|
The original analysis is [FC-03](audit/01-correctness.md#fc-03--p2-session-planning-reports-reusable-s3-preparation-as-changed).
|
|
Read those linked sections, rather than the full audit, before starting. The
|
|
original audit reports remain historical evidence; update disposition and
|
|
completion information in the catalog and discussion document.
|
|
|
|
Complete the stages in order. Each stage is sized for one focused coding-agent
|
|
prompt. Follow [development guidance](../development.md) and the applicable
|
|
agent, architecture, testing, and documentation policies. Commit each completed
|
|
unit with a concise plain-English message. This plan authorizes neither pushing
|
|
nor releasing.
|
|
|
|
## Selected behavior
|
|
|
|
Use the existing shared audio selection, prepared-copy validation, semantic
|
|
configuration checks, and S3 key/size/entity-tag comparison. Supply the missing
|
|
storage collaborator rather than creating another identity implementation.
|
|
|
|
| Evidence observed when checking recorded preparation | Planning result | Execution and standalone preflight |
|
|
| --- | --- | --- |
|
|
| Current remote identities and prepared copies match | Reuse preparation; retain eligible downstream reuse | Reuse preparation |
|
|
| Successfully observed identities differ, or existing prepared-copy checks fail | Schedule preparation and its normal dependent invalidation | Run preparation using existing invalidation rules |
|
|
| Source inspection fails or supplies insufficient identity evidence | Conservatively schedule preparation with an explicit unverified-source reason and useful cause | Preserve the existing normal preparation attempt; persistent failure prevents readiness |
|
|
|
|
The third row preserves today's conservative rerun policy. Its reason must
|
|
identify inability to verify sources, rather than assert that their content
|
|
changed. Dependent work in that plan follows the projected preparation rerun;
|
|
it does not certify a remote content change. A successful preparation attempt
|
|
after a transient inspection failure may still allow preflight to succeed.
|
|
Cancellation and object-store construction errors retain ordinary error
|
|
propagation and command failure reporting.
|
|
|
|
Planning obtains read-only S3 evidence for a selected, successful preparation
|
|
reuse candidate. Forced preparation, preparation without recorded success,
|
|
local-audio sessions, and ranges excluding preparation do not acquire an audio
|
|
identity-check dependency solely for this feature. Existing configuration
|
|
acquisition behavior remains unchanged.
|
|
|
|
The planning projection reads identities and existing files and models changes
|
|
in its cloned manifest. It does not execute preparation, download audio, write
|
|
remote objects, create session/run state, persist a manifest, acquire execution
|
|
locks, or invoke downstream readiness checks. These are boundaries of this
|
|
projection; standalone preflight retains its existing locked, mutating workflow.
|
|
|
|
This work adds no configuration fields, CLI flags, report actions, manifest
|
|
schema, retained remote snapshot, or guarantee that sources remain unchanged
|
|
between planning and execution. Session restore, publication/checkpoint changes,
|
|
audio discovery changes, and other audit findings remain separate work.
|
|
|
|
## Stage 1: Distinguish unverifiable preparation sources from changed sources
|
|
|
|
Status: Complete
|
|
|
|
Read `internal/stage/prepare_resume.go` and its focused tests, especially
|
|
`TestPrepareResumeValidatesCurrentS3ObjectIdentity`. Review the existing
|
|
`ResumeValidation` result and source discovery errors before editing.
|
|
|
|
1. Keep confirmed source/prepared-copy mismatches on the existing non-resumable
|
|
path. Preserve the current key/size/entity-tag and checksum interpretation.
|
|
2. Replace the generic changed-input reason used when
|
|
`currentPrepareSourceInputs` returns an error with an accurate explanation
|
|
that the sources could not be verified, including useful error context.
|
|
Keep the existing non-resumable result and normal rerun policy.
|
|
3. Preserve cancellation propagation and existing environment/configuration
|
|
errors. Use the current result/error mechanisms; a new error taxonomy or
|
|
workflow state is unnecessary.
|
|
4. Extend the preparation-resume tests with an unavailable S3 listing and
|
|
insufficient identity evidence. Verify that these cannot authorize reuse
|
|
and that their reasons distinguish uncertainty from an observed mismatch.
|
|
Retain representative unchanged and changed identity coverage.
|
|
|
|
Validation: `go test ./internal/stage`. Test semantic diagnostic content rather
|
|
than complete error sentences. This stage changes explanations, not the
|
|
conditions under which preparation runs.
|
|
|
|
## Stage 2: Supply object storage to read-only session planning
|
|
|
|
Status: Complete
|
|
|
|
Read `internal/app/plan_command.go`, `plan.go`, `semantic_resume.go`,
|
|
`object_store.go`, and the preparation branch of `runner_stage_execution.go`.
|
|
Use the existing `commandDependencies.newObjectStore` composition seam and
|
|
Narratio's object-store contract.
|
|
|
|
1. Pass the command-owned storage dependency to plan construction. After
|
|
loading the manifest and validating bounded prerequisites, construct the
|
|
storage collaborator when S3 preparation is selected, has recorded success,
|
|
and is a reuse candidate rather than forced work. A simple eligibility
|
|
check is sufficient; do not duplicate source comparison or fingerprinting.
|
|
2. Give `projectSelectedWork` an explicit optional object-store dependency and
|
|
populate its `stage.Env.ObjectStore`. Continue to use
|
|
`evaluateStageResume` and the normal pre-execution decision/modeling logic.
|
|
The shared validator performs the actual read-only listing when required.
|
|
3. Update all projection callers and relevant tests for the dependency:
|
|
`buildSessionPlan`, `inspectInvocationRequirements`, and
|
|
`assessSessionReadiness`. Runtime callers pass their already composed
|
|
`runtime.env.ObjectStore`; they do not create another client for projection.
|
|
Ranges without an S3 preparation check may pass no store.
|
|
4. Propagate initialization errors with context through existing command
|
|
failure reporting. Listing/identity-inspection failures use Stage 1's
|
|
conservative, explicitly unverified result. Honor the invocation context.
|
|
5. Add an application-level regression using a prepared S3 session and the
|
|
existing fake storage boundary. For identical source evidence, compare the
|
|
plan's preparation/dependent decisions with actual execution reuse. Change
|
|
a remote identity and verify normal rerun/invalidation is projected and
|
|
execution agrees. Include unavailable inspection and construction failure.
|
|
6. Exercise the command's injected dependency path so the regression proves
|
|
that production planning can reach the store, rather than only testing a
|
|
projection manually supplied with one. Preserve coverage of local-audio,
|
|
forced/new preparation, and downstream-only planning without introducing
|
|
unnecessary remote requirements.
|
|
|
|
Validation: `go test ./internal/app ./internal/stage ./internal/audio`.
|
|
Use real temporary prepared files and manifests and a fake external store.
|
|
Prove that planning leaves authoritative manifest bytes, prepared files, and
|
|
the session tree unchanged, including failure paths. Observe that identity
|
|
planning performs no audio download or remote mutation. Reuse existing
|
|
no-workspace/no-subprocess tests instead of duplicating their entire coverage.
|
|
|
|
## Stage 3: Verify S3 checks through the existing preflight workflow
|
|
|
|
Status: Complete
|
|
|
|
Read `internal/app/session_readiness.go`, `runner_composition.go`,
|
|
`runner_preflight.go`, and `session_readiness_test.go`. Standalone preflight
|
|
already executes or reuses preparation under the session lock, which supplies
|
|
the store and performs the relevant S3 check.
|
|
|
|
1. Exercise standalone preflight with prepared S3 audio using the existing
|
|
command dependencies and readiness test fixtures. Verify unchanged sources
|
|
reuse preparation and do not redownload verified prepared audio.
|
|
2. Change a selected remote object's identity and verify preflight prepares
|
|
current input, persists the normal preparation evidence, and invalidates
|
|
dependent success according to the existing rules.
|
|
3. Make source inspection persistently fail. Verify the preparation diagnostic
|
|
identifies the failed verification/access rather than proven content drift,
|
|
the eventual preparation error remains visible, and readiness fails. Keep
|
|
existing behavior for independent checks and retained progress. A downstream
|
|
provider failure after successful reuse remains a separate failure.
|
|
4. Cover cancellation at the remote inspection boundary with the existing
|
|
context/error conventions. Consolidate coverage already provided by Stage 2
|
|
or existing tests rather than asserting the same behavior at every layer.
|
|
5. Fix only integration gaps these checks expose. Reuse the preparation and
|
|
composed-store paths; no separate S3 readiness probe, redundant listing
|
|
pass, or new preflight lifecycle is needed. Do not redefine preflight as
|
|
read-only or prohibit its existing downloads, manifest updates, and probes.
|
|
|
|
Validation: `go test ./internal/app ./internal/stage ./internal/audio`.
|
|
Keep the tests offline and credential-free. Assert outcomes and evidence,
|
|
using transfer observations only to protect real reuse/read-only behavior;
|
|
avoid incidental exact call counts or ordering.
|
|
|
|
## Stage 4: Document the boundary and close CAT-13
|
|
|
|
Status: Complete
|
|
|
|
1. Update [CLI planning semantics](../cli.md#session-plan) to explain read-only
|
|
remote source inspection, existing action/reason reporting for unverified
|
|
inputs, and the observation-time limitation. Distinguish object-storage
|
|
composition from executing stage adapters and downstream inspection.
|
|
2. Update [operations](../operations.md#prompt-requirements-preflight) for the
|
|
operator-facing difference between planning and preflight where necessary.
|
|
Keep command syntax in the CLI reference and operational workflows in
|
|
operations; link rather than repeat their contracts.
|
|
3. Update the focused planning description in
|
|
[Internal Overview](../internal/overview.md),
|
|
[Preparation Internals](../internal/stage-prepare.md), and
|
|
[Preflight Internals](../internal/preflight.md) only where their owned
|
|
explanations need the new collaborator or diagnostic distinction.
|
|
4. Run the repository checks with the maintained Go toolchain:
|
|
|
|
```sh
|
|
GOTOOLCHAIN=go1.27.4 go test ./...
|
|
GOTOOLCHAIN=go1.27.4 go test -race ./...
|
|
GOTOOLCHAIN=go1.27.4 go vet ./...
|
|
GOTOOLCHAIN=go1.27.4 go build ./...
|
|
```
|
|
|
|
5. Review the final diff against the selected behavior above. Confirm no new
|
|
remote-resume protocol, audio-selection rules, freshness guarantee, or
|
|
access-failure prohibition was added.
|
|
6. After successful validation, mark CAT-13 closed in the audit catalog and
|
|
record completion in discussion topic 3, linking to the implementing commits
|
|
and relevant regression coverage. Mark the implementation stages complete.
|
|
Leave unrelated audit statuses and pending roadmaps unchanged.
|
|
|
|
Completion means unchanged S3 preparation is truthfully reusable in plans and
|
|
preflight; observed changes schedule the existing replacement path; unavailable
|
|
evidence is identified accurately; and planning leaves session state untouched.
|