When the retained-Evidence cache could not keep an over-budget result,
the CLI delivered its summary with rerun arguments. Rerunning a
non-idempotent operation does not reproduce it: an extraction that
created its output root refuses the same root. Each CLI delivery now
knows whether its contract is idempotent, and a non-idempotent result the
cache does not keep is delivered complete.
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
* feat(cli): retain over-budget partial observations from failed CLI runs
When a failed CLI command carries an over-budget partial observation without
--evidence_output, retain the complete partial Evidence in the private
retained-Evidence cache instead of dropping it to a rerun-only fallback.
- Pass the composed source closure into budgetFailurePartialEvidence so cited
source records are written into the retained bundle alongside the partial
observation.
- Report the retained path, byte size, and record_sha256 under
details.diagnostics.evidence_bundle, set details.partial_observation_delivery
to retained: "cache-file" with a paging cursor, and keep all failure facts
(code, message, failure_kind, retryable, remediation, limits, existing
diagnostics) unchanged.
- Honor --no-retain and REA_CLI_RETAINED_EVIDENCE_BYTES=0, fall back to
retained: "not-retained" with rerun arguments and redacted retention_failure
on uncommitted write errors, preserve the original failure and committed
cache receipt on post-commit staging cleanup failures, and keep cancelled
failures on the no-publication contract.
- Document the behavior in docs/reference/limits-and-recovery.md and add
boundary and CLI acceptance tests.
Fixes#14618
* fix(cli): preserve pre-commit cleanup ownership and surviving oversized cache receipts
Address two gaps in the shared retainOverBudgetEvidence path that affected
both successful (deliverRetainedSummary) and failed (budgetFailurePartialEvidence)
CLI retention:
- Preserve pre-commit writer errors whose staging cleanup stayed incomplete
(including exists failures with unfinished cleanup), reporting cleanup_incomplete
and remaining resources via projectFailure on successes and via
refusedPartialPublication (keeping execution_failure and complete inline
partial_observation) on failures.
- When removing an oversized retained cache bundle fails (fileRemains), carry
the surviving file metadata through RetentionStop.remainingFile, record the
complete receipt (path, bytes, record_sha256), and report retained: "cache-file"
with its paging cursor and retention_failure instead of a not-retained fallback.
- Simplify refusedPartialPublication back to a plain delivery value now that
retainOverBudgetEvidence tracks the attempted cache path directly.
- Add public CLI tests for both paths (success and failure) using
evidencePublicationPreload.mjs and update docs/reference/limits-and-recovery.md.
* fix(cli): key retained bundles by complete source closure
* chore(format): format retained evidence publication
* fix(cli): canonicalize retained bundle cache keys
* test(cli): compare retained bundle bytes directly
---------
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
* feat(cli)!: keep over-budget CLI results recoverable by default
An over-budget CLI result without --evidence_output now saves its
complete Evidence to a private retained-Evidence cache under the user
cache directory and returns the summary with the file's path, size and
digest, so it pages with inspect-analysis-view without a rerun.
Files are named by the complete record's Evidence ID, created
exclusively as 0600 by the Evidence bundle writer in a 0700 directory
the user owns, reused by repeat runs and never overwritten. Each
retention removes records unused for 7 days, then the least recently
used over delivery.cli_retained_evidence_bytes (REA_CLI_RETAINED_EVIDENCE_BYTES,
default 256 MiB). --no-retain or a 0 setting writes nothing; a record
that cannot be kept falls back to the rerun arguments with the reason.
Fixes#14594
BREAKING CHANGE: An over-budget CLI result without --evidence_output is
now saved to REA's private retained-Evidence cache and reported as
{summary, evidence_bundle, delivery} with delivery.retained cache-file,
instead of writing nothing. Pass --no-retain, or set
REA_CLI_RETAINED_EVIDENCE_BYTES=0, to write nothing as before.
* fix(cli): key retained Evidence by its content and keep its owner's facts
Review fixes for default CLI retention:
- Name files by the SHA-256 of the complete record's exact JSON, since
the Evidence ID leaves out caller paths; report it as
evidence_bundle.sha256.
- Remove a bundle that outgrows the cache after the write.
- Renew a record's age when inspect-analysis-view reads it.
- Re-check a record's use time before evicting it.
- Never use a cache whose path holds a value marked sensitive, and
redact retention failure reasons.
- Report a save that committed but then failed with its receipt and
cleanup owner, as --evidence_output does.
- Request source records whenever the cache may receive a bundle.
- Refresh the advertised-schema summaries for the new setting.
* fix(cli): withdraw the receipt of a bundle the cache discards
A bundle that outgrew the cache was removed after the writer had already
recorded its publication receipt, so output recovery could name a
missing file. Retention now withdraws that receipt whenever it keeps
nothing, unless the file committed and its failure is reported.
* fix(cli): retain publication receipt when removing an oversized retained bundle fails