4.5 KiB
07 — Transactional state and local artifact cache
Implementation status: IMPLEMENTED & VERIFIED (2026-11-26). See STATE and VERIFICATION for implemented files and observed checks.
Requirements and ownership
- Requirements: R-007, R-014, R-015.
- Delivery phase: Core correctness foundation.
- Intended configured role: astra_implementer at XHigh; fresh astra_reviewer acceptance.
- Dependencies: 03 action schema; 04 identities; 05 manifests; coordinated protocol with 06 publication.
- Proposed exclusive implementation scope: src/state/, src/cache/, include/vbs/state/, tests/state/; root owns schema migrations and shared version constants.
Before dispatch, reconcile these paths with the real HEAD, write a full task spec, lint it, and transfer shared-file ownership explicitly. Paths that do not yet exist are NEW. Source-disjoint work still coordinates shared state, ports and build directories.
Design and interfaces
- Store successful action identities, discovered inputs, artifact digests, graph generations and ownership claims in transactional state. Use a verified Void::Sqlite adapter with prepared statements, explicit transaction boundaries and schema versioning.
- Use SHA-256-addressed immutable blobs/manifests. An action key includes command order, environment policy, toolchain, inputs, lookup guards, output expectations and metadata/path policy.
- Keep reusable artifact cache separate from dependency binary packages and user install destinations. Verify expected outputs and relevant blob integrity; missing or externally changed outputs invalidate reuse.
- Publish objects before committing references. Recovery can discard/rebuild uncommitted outputs, collect orphaned objects and repair projection pointers; it must not invent a successful record.
- Coordinate short write transactions and per-action/profile leases. GC considers active runs and reachable generations/locks, and cannot remove in-use artifacts or another project's uncontrolled files.
- Treat opaque BMI/PCH and other path-sensitive artifacts conservatively: include physical path/toolchain context unless relocation has a tested format-aware proof.
Implementation sequence
- Verify Sqlite implementation semantics needed for rollback, errors, concurrency and migrations; add local adapter tests.
- Implement versioned schema, CAS I/O and action identity canonicalization.
- Integrate success publication/recovery and explicit corruption/schema-mismatch behavior.
- Add retention, quota, GC and explainable reuse/miss diagnostics.
Failure behavior and boundaries
- Database busy/corrupt/newer-schema cases have explicit recovery/error paths; do not silently delete user data.
- No success record for failed, cancelled, truncated or partially published action.
- Never put credentials or unrestricted process environments into lock/log/state records.
- Clock-dependent/custom opaque actions are nonreusable unless their declared model provides the required determinism.
Acceptance scenarios
- Crash injection before/after every publication boundary; resume yields correct outputs.
- Corrupt/missing blobs, modified outputs, schema migration rollback and concurrent writers.
- Identity changes for command ordering, flags, response files, toolchain, env, headers and namespace guards.
- GC under active builds; quota failure; no deletion outside owned cache.
- No-op build performs no target actions while retaining required input verification.
Verification and integration gate
NEW SQLite/CAS unit tests and crash subprocess fixtures. Compare cold/clean/warm/unchanged builds for output behavior and actual action counts; cache-hit percentage alone is not correctness evidence.
Acceptance requires observed results for these scenarios, the affected regression suite, reviewed cross-component contracts, and a fresh independent review. Record unrun checks and environment limitations; tests passing alone do not waive an invariant. No merge, push or deployment is authorized by a review verdict.
VoidLibrary reuse and upstream candidates
Void::Sqlite, Binary/Data helpers as suitable, focused SHA-256 adapter. Upstream candidates include transactional publication and bounded serialization; validate rather than assume header promises.
Shared invariants and input/publication policies are defined in ARCHITECTURE; requirement authority is REQUIREMENTS. Return implementation evidence to VERIFICATION.