Skip to content

docs(core): close final S5 cross-contract consistency audit for R-15 (#445) - #584

Open
qnbs wants to merge 1 commit into
mainfrom
fix/s5-cross-contract-consistency-audit
Open

docs(core): close final S5 cross-contract consistency audit for R-15 (#445)#584
qnbs wants to merge 1 commit into
mainfrom
fix/s5-cross-contract-consistency-audit

Conversation

@qnbs

@qnbs qnbs commented Sep 2, 2026

Copy link
Copy Markdown
Owner

User description

Summary

Performs the final S5-A/S5-B1/S5-B2/S5-B3 cross-contract consistency audit for the R-15 Secure Storage Contract, per the AUTONOMOUS TERMINAL-CONVERGENCE DIRECTIVE's closing requirement. All four documents were read in full (3,174 + 184 + 246 + 104 lines) and checked for mutual agreement across 21 points: installation scope, secure anchor, root publication, RootKeyRef, key epochs, crash recovery, AuthoritySnapshot lifetime, marker/catalog authority, ordinary write admission, DISCOVER barrier, migration inventory, foreign-protected sources, plaintext-IDB representations, canonical destination payloads, source evidence/value equivalence, atomic-write temporaries, credentials, asset pairs, GC/retention, fault vectors, and the Core/platform boundary.

Two mechanical citation-drift findings, both corrected:

  1. R15-SECURE-STORAGE-CONTRACT.md Β§10.4.1 β€” the disposition-count paragraph still described atomic-write temporary files as "blocked pending S5-B1," directly contradicting the same section's own preceding paragraph, which already declares S5-B1 admitted for exactly this gap (surviving atomic-write-temporary reconciliation). Updated to reflect that this class is now reconciled via S5-B1's admitted mechanism.

  2. docs/native/r15/CHUNKED-LARGE-OBJECT-ENVELOPE.md Β§6 β€” the write-path crash-recovery paragraph cited "S5-B1's existing mechanism (Β§5)" for reconciling an orphaned R-15 write's own staging chunk. S5-B1 Β§5 is explicitly scoped to legacy pre-R15 temp files discovered during migration inventory, and its own defined outcomes (e.g. "treat it as the record's LEGACY_PLAINTEXT source for migration purposes") don't fit an already-operational R-15 write's own ciphertext staging debris β€” there's no migration or plaintext involved in that scenario. The parent contract's own Β§9 step 11 / Β§9.2 fault-point row already covers exactly this case (ordinary-write stale staging, reconciled via its operation_id/target_generation suffix, Β§3's atomic-write-temporary row). Both mechanisms agree on the same fail-closed behavior (preserve, never silently promote), so this was a wrong citation, not a safety defect. Corrected to cite the actually-applicable mechanism.

Every other cross-reference and shared formula was verified byte-for-byte where load-bearing β€” source_value_digest's formula is identical in both the parent and S5-B1; the marker-body is_chunked/chunk_count field ordering matches S5-B3's claims exactly (appended after content_digest/record_schema, never shifting existing offsets); Β§6.3's nonce/AAD domain-separation wording matches S5-B3's claimed fix; Β§5.3.3's reader-algorithm steps 2/7 and Β§3's reclamation-eligibility extension match S5-B2's integration exactly; Β§9.2's fault-point quotes S5-B3 cites are verbatim-accurate; the disposition registry's arithmetic (5 + 3 + 28 + 1 = 37, matching Β§3's inventory) checks out; and every document's status header agrees (all four admitted, none implementation-ready, no document claims a stale draft/proposed state relative to another).

No substantive design inconsistency was found.

Recorded S5_TERMINAL_R15_DESIGN_ADMITTED_MERGED_POSTMERGE_GREEN = TRUE in the parent contract's status header, Β§21 (S5 admission decision), and the migration ledger's row 10.

Test plan

  • pnpm run lint β€” pass
  • pnpm run docs:check β€” pass
  • pnpm run ci:prepush β€” pass (classified DOCS_ONLY)
  • CI: full required + advisory suite green

This PR is documentation-only (3 files under docs/native/) β€” no implementation, no production authority switch, no change to any admitted S5-A/S5-B1/S5-B2/S5-B3 semantics beyond the two citation corrections above.

Summary by Sourcery

Complete the final R-15 S5 cross-contract audit, correct two stale citations, and record the consistent design as admitted but not implementation-ready.

Bug Fixes:

  • Correct citation drift for atomic-write temporary reconciliation in the R-15 storage contract and chunked large-object recovery documentation.

Enhancements:

  • Close the final cross-contract consistency audit for the admitted R-15 S5-A/S5-B1/S5-B2/S5-B3 design and record the design as terminal while keeping implementation and production authority changes deferred.

Documentation:

  • Update the R-15 contract and migration ledger to reflect completed cross-contract validation and terminal design admission.

CodeAnt-AI Description

Close the R-15 secure-storage design audit and correct cross-document recovery references

What Changed

  • Marks the S5 cross-contract consistency audit as complete across the R-15 storage documents, while keeping production implementation and the authority switch disabled.
  • Corrects recovery guidance so orphaned staging chunks from active R-15 writes use ordinary-write cleanup rules rather than legacy migration discovery.
  • Updates the storage classification to show atomic-write temporary files are covered by the admitted reconciliation mechanism.
  • Records that no substantive design inconsistency was found and that current desktop data handling remains unchanged.

Impact

βœ… Clearer R-15 design status
βœ… Correct recovery guidance for interrupted writes
βœ… No change to current desktop storage behavior

πŸ’‘ Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.


Summary by cubic

Closes the final S5-A/S5-B1/S5-B2/S5-B3 cross-contract consistency audit for the R-15 secure storage contract and declares the S5 design program terminal (S5_TERMINAL = YES). Documentation-only change: no substantive design inconsistency was found, and the only edits are two corrected citation drifts plus the status flags in the parent contract, Β§21, and the migration ledger.

Bug Fixes

  • Corrected Β§10.4.1's disposition-count paragraph, which still described atomic-write temporary files as "blocked pending S5-B1" despite the same section already admitting S5-B1 for that gap.
  • Corrected CHUNKED-LARGE-OBJECT-ENVELOPE.md Β§6's crash-recovery citation, which pointed at S5-B1's migration-time discovery mechanism for an ordinary write's own orphaned staging chunk; the parent contract's Β§9 step 11 / Β§9.2 fault-point row is the applicable mechanism.

Written for commit df83115. Summary will update on new commits.

Review in cubic

…445)

Performed the final S5-A/S5-B1/S5-B2/S5-B3 cross-contract consistency
audit: read all four merged R-15 documents in full and verified mutual
agreement across every cross-reference, shared formula, and status flag.

Two mechanical citation-drift findings, both corrected here:
- R15-SECURE-STORAGE-CONTRACT.md's Β§10.4.1 disposition-count paragraph
  still described atomic-write temporary files as "blocked pending
  S5-B1", contradicting the same section's own preceding paragraph
  declaring S5-B1 admitted for exactly this gap.
- CHUNKED-LARGE-OBJECT-ENVELOPE.md's Β§6 crash-recovery paragraph cited
  S5-B1's migration-time discovery mechanism for reconciling an
  ordinary R-15 write's own orphaned staging chunk. S5-B1 Β§5 is scoped
  to legacy pre-R15 temp files found during migration inventory, and
  its own defined outcomes (e.g. "treat it as the record's
  LEGACY_PLAINTEXT source for migration purposes") don't fit an
  already-operational write's staging debris. The parent contract's
  own Β§9 step 11 / Β§9.2 fault-point row already covers this exact
  scenario; both paths agreed on the same fail-closed behavior, so
  this was a wrong citation, not a safety defect.

No substantive design inconsistency was found. Recorded
S5_TERMINAL_R15_DESIGN_ADMITTED_MERGED_POSTMERGE_GREEN = TRUE in the
parent contract's header/Β§21 and the migration ledger's row 10.
@codeant-ai

codeant-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown

πŸ€– CodeAnt AI β€” Review Status

Status Commit Started (UTC) Finished (UTC)
βœ… Reviewed your PR df83115 Sep 02, 2026 Β· 11:36 11:37

@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
worldscript-studio Ready Ready Preview Sep 2, 2026 11:37am UTC

@codeant-ai

codeant-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! πŸŽ‰

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X Β·
Reddit Β·
LinkedIn

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @qnbs, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 6 days and 2 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 74 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Learn how review limits work.

Review configuration:

βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Essentials

Run ID: 19655d64-e72e-433e-ac12-2be779acbe9f

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between b1718d7 and df83115.

πŸ“’ Files selected for processing (3)
  • docs/native/CORE-MIGRATION-LEDGER.md
  • docs/native/R15-SECURE-STORAGE-CONTRACT.md
  • docs/native/r15/CHUNKED-LARGE-OBJECT-ENVELOPE.md

Comment @coderabbitai help to get the list of available commands.

@what-the-diff

what-the-diff Bot commented Sep 2, 2026

Copy link
Copy Markdown

PR Summary

  • Update to CORE-MIGRATION-LEDGER document
    This update marks the completion of the final review for consistency across contracts for a protection feature (R-15) in desktop storage system. It now acknowledges the completion of S5_TERMINAL.

  • Changes to Admission Status in R15-SECURE-STORAGE-CONTRACT
    The S5_TERMINAL status has been changed to "YES" indicating completion. The document now includes the acknowledgment of the completion of the final consistency check between contracts.

  • Improvements to Reconciliation Process in R15-SECURE-STORAGE-CONTRACT
    The process of rectifying and verifying evidence and findings has been clarified, confirming that no major design inconsistency was found.

  • Revised Explanation of Recovery Procedures
    The document CHUNKED-LARGE-OBJECT-ENVELOPE.md now better explains how to recover data, emphasizing that this process doesn't presume consistency across different files. Also, the handling of leftover durably-staged chunks (orphaned) is further clarified.

@sourcery-ai

sourcery-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This documentation-only PR completes the final S5-A/S5-B1/S5-B2/S5-B3 consistency audit for R-15, fixes two citation-drift issues, and marks the design terminal/admitted without changing production authority, implementation readiness, or storage semantics.

File-Level Changes

Change Details Files
Closed the R-15 S5 cross-contract audit and promoted the design status to terminal while preserving the implementation boundary.
  • Set S5 terminal/admitted status flags in the migration ledger and parent contract.
  • Recorded that all four contracts are mutually consistent and that implementation readiness and production authority remain disabled.
  • Documented the completed audit scope and remaining implementation-gate evidence.],
  • files [
docs/native/CORE-MIGRATION-LEDGER.md
docs/native/R15-SECURE-STORAGE-CONTRACT.md
Corrected the parent contract’s atomic-write-temporary disposition text to match the admitted S5-B1 mechanism.
  • Replaced the stale β€œblocked pending S5-B1” wording with the reconciled disposition.
  • Kept the protected-class registry arithmetic and inventory total unchanged.
docs/native/R15-SECURE-STORAGE-CONTRACT.md
Corrected chunked-write crash-recovery documentation to reference ordinary R-15 staging reconciliation instead of migration-time legacy-temp discovery.
  • Aligned orphaned chunk handling with Β§9/Β§9.2 operation and generation suffix rules.
  • Clarified fail-closed preservation and non-promotion behavior.
  • Scoped S5-B1’s mechanism to legacy pre-R15 migration inventory.
docs/native/r15/CHUNKED-LARGE-OBJECT-ENVELOPE.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepsource-io

deepsource-io Bot commented Sep 2, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in b1718d7...df83115 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSourceΒ β†—

PR Report Card

Overall GradeΒ Β  SecurityΒ Β 

ReliabilityΒ Β 

ComplexityΒ Β 

HygieneΒ Β 

Code Review Summary

Analyzer Status Updated (UTC) Details
Docker Sep 2, 2026 11:36a.m. ReviewΒ β†—
Python Sep 2, 2026 11:36a.m. ReviewΒ β†—
Rust Sep 2, 2026 11:36a.m. ReviewΒ β†—
Shell Sep 2, 2026 11:36a.m. ReviewΒ β†—

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@codeant-ai

codeant-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown

🏁 CodeAnt Quality Gate Results

Commit: df83115c
Scan Time: 2026-09-02 11:38:29 UTC

βœ… Overall Status: PASSED

Quality Gate Details

Quality Gate Status Details
Secrets βœ… PASSED 0 secrets found
Duplicate Code βœ… PASSED 0.0% duplicated
SAST βœ… PASSED No security issues
Bugs βœ… PASSED Rating S: No bugs
IAC βœ… PASSED No IAC issues

View Full Results

@codeant-ai codeant-ai Bot added the size:XS This PR changes 0-9 lines, ignoring generated files label Sep 2, 2026
@cubic-dev-ai

cubic-dev-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown

We've triggered an ultrareview automatically β€” This final audit flips the R-15 secure-storage design to terminal/admitted and rewrites crash-recovery citation semantics across cross-contract specs, so a missed inconsistency could misguide implementation and threaten data integrity β€” worth a deeper pass.. I'll post findings when complete.

An ultrareview is cubic's deepest review, catching hard-to-find bugs in the most critical PRs. It runs a longer, multi-pass analysis using cubic's most capable review models, and typically takes around 30 minutes. It consumes your team's reviewed-lines allowance at 3Γ— the standard rate.

Automated ultrareviews are disabled by default. We triggered this run as part of your trial. Want cubic to do this for every high-risk PR? Enable auto-ultrareview in your settings.

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation updates correctly reflect completion of the S5 cross-contract consistency audit. The changes consistently update status flags across all affected documents, document the two mechanical citation-drift findings that were corrected, and maintain the accurate distinction that this is design admission only (S5_TERMINAL=YES) with no production implementation (IMPLEMENTATION_NOT_STARTED). No defects found.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No application code in the PR β€” skipped Code Health checks.

See analysis details in CodeScene

Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ultrareview completed in 5m 0s

3 issues found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid β€” if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/native/r15/CHUNKED-LARGE-OBJECT-ENVELOPE.md">

<violation number="1" location="docs/native/r15/CHUNKED-LARGE-OBJECT-ENVELOPE.md:92">
P1: Recovery is instructed to check the final-looking `<record-class>-chunk:...` locator even though Β§9 stages data under a separate operation/generation-suffixed temp name. Because the defined chunk locator carries no operation identity, recovery cannot reliably distinguish a discarded attempt's chunk from the current attempt; define a per-chunk temp naming rule and make recovery inspect that operation-specific name before applying Β§9.2.</violation>
</file>

<file name="docs/native/R15-SECURE-STORAGE-CONTRACT.md">

<violation number="1" location="docs/native/R15-SECURE-STORAGE-CONTRACT.md:2616">
P2: `Atomic-write temporary files` remain a `PROTECTED` class with no disposition or registry group, despite Β§10.4.1's one-disposition and Gate 7 rules. Define an explicit reconciliation disposition/group or revise the invariant and count before calling the audit complete.</violation>
</file>

<file name="docs/native/CORE-MIGRATION-LEDGER.md">

<violation number="1" location="docs/native/CORE-MIGRATION-LEDGER.md:20">
P2: Before the post-merge green verification exists, this row advertises the design as terminal. Keep `S5_TERMINAL` pending until the merge and required post-merge checks succeed, then update both status sources together.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Chunked writes follow Β§9's existing ordinary-write contract with one extension applied per chunk between steps 3 and 6 (serialize, stage, write, sync): each chunk is independently serialized under its own AAD (Β§2), written to its own staging file, and flushed/synced (Β§9 steps 3-5, applied once per chunk, in any order or concurrently β€” chunks do not depend on each other's staging order). Only once *every* chunk's staging file is independently durable does `chunk_set_digest` get computed over the complete set (Β§3) and step 9's marker commit proceed, naming that digest. `DURABLE_COMMIT_SUCCESS` (Β§9.1) is reported only after the marker commit itself is durable β€” never after "all chunks staged" as some separate, weaker success condition.

**Recovery never assumes cross-file atomicity.** On restart, before the marker names a `chunk_set_digest`, no chunk is authoritative regardless of how many are durably staged β€” this is the same rule Β§9.2's fault-point table already states for a whole-record staging file ("Before staging write... old authority remains valid" through "After directory sync, before marker advancement... new bytes are durable but marker metadata is stale"). Recovery re-derives which chunks are already durably staged by checking each expected `<record-class>-chunk:...` locator independently (never assuming a fixed promotion order), re-verifies each present chunk's own AEAD tag and content_digest, and either resumes staging the missing chunks and proceeding to the marker commit, or discards the entire partial set and restarts the write from the beginning β€” an orphaned durably-staged chunk from a discarded attempt is atomic-write-temporary debris, reconciled per S5-B1's existing mechanism (`docs/native/r15/MIGRATION-SOURCE-EVIDENCE.md` Β§5), never treated as a second valid candidate.
**Recovery never assumes cross-file atomicity.** On restart, before the marker names a `chunk_set_digest`, no chunk is authoritative regardless of how many are durably staged β€” this is the same rule Β§9.2's fault-point table already states for a whole-record staging file ("Before staging write... old authority remains valid" through "After directory sync, before marker advancement... new bytes are durable but marker metadata is stale"). Recovery re-derives which chunks are already durably staged by checking each expected `<record-class>-chunk:...` locator independently (never assuming a fixed promotion order), re-verifies each present chunk's own AEAD tag and content_digest, and either resumes staging the missing chunks and proceeding to the marker commit, or discards the entire partial set and restarts the write from the beginning β€” an orphaned durably-staged chunk from a discarded attempt is atomic-write-temporary debris, reconciled exactly as Β§9.2's fault-point table and Β§9 step 11 already reconcile any other ordinary write's stale staging β€” identified by its `operation_id`/`target_generation` suffix, per Β§3's atomic-write-temporary row β€” never S5-B1's migration-time discovery mechanism (`docs/native/r15/MIGRATION-SOURCE-EVIDENCE.md` Β§5), which is scoped to legacy pre-R15 temp files discovered during migration inventory, not an already-operational R-15 write's own staging debris; and never treated as a second valid candidate.

@cubic-dev-ai cubic-dev-ai Bot Sep 2, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Recovery is instructed to check the final-looking <record-class>-chunk:... locator even though Β§9 stages data under a separate operation/generation-suffixed temp name. Because the defined chunk locator carries no operation identity, recovery cannot reliably distinguish a discarded attempt's chunk from the current attempt; define a per-chunk temp naming rule and make recovery inspect that operation-specific name before applying Β§9.2.

Prompt for AI agents
Check if this issue is valid β€” if so, understand the root cause and fix it. At docs/native/r15/CHUNKED-LARGE-OBJECT-ENVELOPE.md, line 92:

<comment>Recovery is instructed to check the final-looking `<record-class>-chunk:...` locator even though Β§9 stages data under a separate operation/generation-suffixed temp name. Because the defined chunk locator carries no operation identity, recovery cannot reliably distinguish a discarded attempt's chunk from the current attempt; define a per-chunk temp naming rule and make recovery inspect that operation-specific name before applying Β§9.2.</comment>

<file context>
@@ -89,7 +89,7 @@ A record's chunked-vs-whole-record status is fixed at first write and MUST NOT c
 Chunked writes follow Β§9's existing ordinary-write contract with one extension applied per chunk between steps 3 and 6 (serialize, stage, write, sync): each chunk is independently serialized under its own AAD (Β§2), written to its own staging file, and flushed/synced (Β§9 steps 3-5, applied once per chunk, in any order or concurrently β€” chunks do not depend on each other's staging order). Only once *every* chunk's staging file is independently durable does `chunk_set_digest` get computed over the complete set (Β§3) and step 9's marker commit proceed, naming that digest. `DURABLE_COMMIT_SUCCESS` (Β§9.1) is reported only after the marker commit itself is durable β€” never after "all chunks staged" as some separate, weaker success condition.
 
-**Recovery never assumes cross-file atomicity.** On restart, before the marker names a `chunk_set_digest`, no chunk is authoritative regardless of how many are durably staged β€” this is the same rule Β§9.2's fault-point table already states for a whole-record staging file ("Before staging write... old authority remains valid" through "After directory sync, before marker advancement... new bytes are durable but marker metadata is stale"). Recovery re-derives which chunks are already durably staged by checking each expected `<record-class>-chunk:...` locator independently (never assuming a fixed promotion order), re-verifies each present chunk's own AEAD tag and content_digest, and either resumes staging the missing chunks and proceeding to the marker commit, or discards the entire partial set and restarts the write from the beginning β€” an orphaned durably-staged chunk from a discarded attempt is atomic-write-temporary debris, reconciled per S5-B1's existing mechanism (`docs/native/r15/MIGRATION-SOURCE-EVIDENCE.md` Β§5), never treated as a second valid candidate.
+**Recovery never assumes cross-file atomicity.** On restart, before the marker names a `chunk_set_digest`, no chunk is authoritative regardless of how many are durably staged β€” this is the same rule Β§9.2's fault-point table already states for a whole-record staging file ("Before staging write... old authority remains valid" through "After directory sync, before marker advancement... new bytes are durable but marker metadata is stale"). Recovery re-derives which chunks are already durably staged by checking each expected `<record-class>-chunk:...` locator independently (never assuming a fixed promotion order), re-verifies each present chunk's own AEAD tag and content_digest, and either resumes staging the missing chunks and proceeding to the marker commit, or discards the entire partial set and restarts the write from the beginning β€” an orphaned durably-staged chunk from a discarded attempt is atomic-write-temporary debris, reconciled exactly as Β§9.2's fault-point table and Β§9 step 11 already reconcile any other ordinary write's stale staging β€” identified by its `operation_id`/`target_generation` suffix, per Β§3's atomic-write-temporary row β€” never S5-B1's migration-time discovery mechanism (`docs/native/r15/MIGRATION-SOURCE-EVIDENCE.md` Β§5), which is scoped to legacy pre-R15 temp files discovered during migration inventory, not an already-operational R-15 write's own staging debris; and never treated as a second valid candidate.
 
 ## 7. Required proof (headless, before production admission)
</file context>
Fix with cubic

`RETAIN_APPROVED_SEPARATE_PROTECTED_AUTHORITY` classes, 28 `MIGRATE_TO_R15` classes, and 1 class
(atomic-write temporary files, above) blocked pending S5-B1 rather than assigned to any of the three
groups β€” 37 `PROTECTED` classes in all, matching Β§3's inventory result exactly. Adding, removing, or
(atomic-write temporary files, above) reconciled via S5-B1's admitted mechanism rather than assigned

@cubic-dev-ai cubic-dev-ai Bot Sep 2, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Atomic-write temporary files remain a PROTECTED class with no disposition or registry group, despite Β§10.4.1's one-disposition and Gate 7 rules. Define an explicit reconciliation disposition/group or revise the invariant and count before calling the audit complete.

Prompt for AI agents
Check if this issue is valid β€” if so, understand the root cause and fix it. At docs/native/R15-SECURE-STORAGE-CONTRACT.md, line 2616:

<comment>`Atomic-write temporary files` remain a `PROTECTED` class with no disposition or registry group, despite Β§10.4.1's one-disposition and Gate 7 rules. Define an explicit reconciliation disposition/group or revise the invariant and count before calling the audit complete.</comment>

<file context>
@@ -2613,8 +2613,8 @@ AI telemetry; AI benchmark history.
 `RETAIN_APPROVED_SEPARATE_PROTECTED_AUTHORITY` classes, 28 `MIGRATE_TO_R15` classes, and 1 class
-(atomic-write temporary files, above) blocked pending S5-B1 rather than assigned to any of the three
-groups β€” 37 `PROTECTED` classes in all, matching Β§3's inventory result exactly. Adding, removing, or
+(atomic-write temporary files, above) reconciled via S5-B1's admitted mechanism rather than assigned
+to any of the three groups β€” 37 `PROTECTED` classes in all, matching Β§3's inventory result exactly. Adding, removing, or
 reclassifying a Β§3 row requires updating this registry in the same change; a `PROTECTED` row with no
</file context>
Fix with cubic

| 8 | AI services | TS, `services/ai/` (44 files, 5,401 lines), mixed portability (retry/routing/error-taxonomy renderer-neutral vs. `computeShaderFactory.ts`/`webGpuDetectorService.ts`/`.wgsl` inherently WebGPU-coupled) | Mixed | Medium-high (API keys) | Low-medium | Medium | Uncertain β€” too large/mixed to assess narrowly | **Out of scope for all of Wave 2** | None proposed | None |
| 9 | Project state-shape compatibility adapter | TS, `features/project/coreBoundaryAdapter.ts` at the Core boundary + Rust, `crates/worldscript-project` schema | High at the boundary β€” production Redux `EntityState` must be translated without importing Redux into Core | Low | High β€” ID/order preservation is part of project identity | Medium | High β€” every native renderer needs the same conversion contract | **2 β€” Wave 2 prerequisite before G1 evaluation** | **In progress β€” typed adapter, fixtures, and the first observation-only desktop shadow caller are locally proven; no authority switch**; normalizes array or Redux `EntityState` to renderer-neutral arrays and reconstructs the TS-side shape only at the integration boundary. The Rust verdict is partial because unknown fields are not rejected, and the envelope's `schemaVersion` is synthesized rather than persisted. | `tests/unit/features/project/coreBoundaryAdapter.test.ts` covers array and `EntityState` inputs, round-trip ID/order preservation, and rejection of duplicate IDs, missing references, and orphaned entities for both characters and worlds; the envelope fixture is accepted by Rust after migration and validation |
| 10 | R-15 protected desktop storage contract | **Design only (S5-A baseline)**, `docs/native/R15-SECURE-STORAGE-CONTRACT.md`; current desktop records remain TS/Tauri filesystem authority | High β€” future Core must serve Tauri and Qt without renderer-private crypto semantics | High | High β€” durability, migration, and identity binding protect user data | High | **Highest β€” cross-renderer security/durability contract** | **3 β€” S5-A, S5-B1, S5-B2, and S5-B3 all admitted; final cross-contract audit pending** | **S5_A_ADMITTED=YES / S5_B1_ADMITTED=YES / S5_B2_ADMITTED=YES / S5_B3_ADMITTED=YES / S5_IMPLEMENTATION_READY=NO / S5_TERMINAL=NO (pending audit)**; inventory, identity/AAD envelope, key epochs, fail-closed reads, durable replacement, crash-resumable migration, unified admission, race-free `AuthoritySnapshot` acquisition/lifetime (`docs/native/r15/AUTHORITY-SNAPSHOT-LIFETIME.md`), canonical migration source/payload evidence (`docs/native/r15/MIGRATION-SOURCE-EVIDENCE.md`), and the chunked large-object envelope (`docs/native/r15/CHUNKED-LARGE-OBJECT-ENVELOPE.md`) are all specified. No production authority switch or plaintext migration is claimed. | Final S5 cross-contract consistency audit (mutual reference integrity across all four documents); then headless Core vectors, fault-injection tests, per-record migration tests, packaged durability evidence, and explicit #357/#359/#360/#361 reconciliation required before implementation gates can close |
| 10 | R-15 protected desktop storage contract | **Design only (S5-A baseline)**, `docs/native/R15-SECURE-STORAGE-CONTRACT.md`; current desktop records remain TS/Tauri filesystem authority | High β€” future Core must serve Tauri and Qt without renderer-private crypto semantics | High | High β€” durability, migration, and identity binding protect user data | High | **Highest β€” cross-renderer security/durability contract** | **3 β€” S5-A, S5-B1, S5-B2, and S5-B3 all admitted; final cross-contract audit complete, S5_TERMINAL** | **S5_A_ADMITTED=YES / S5_B1_ADMITTED=YES / S5_B2_ADMITTED=YES / S5_B3_ADMITTED=YES / S5_IMPLEMENTATION_READY=NO / S5_TERMINAL=YES**; inventory, identity/AAD envelope, key epochs, fail-closed reads, durable replacement, crash-resumable migration, unified admission, race-free `AuthoritySnapshot` acquisition/lifetime (`docs/native/r15/AUTHORITY-SNAPSHOT-LIFETIME.md`), canonical migration source/payload evidence (`docs/native/r15/MIGRATION-SOURCE-EVIDENCE.md`), and the chunked large-object envelope (`docs/native/r15/CHUNKED-LARGE-OBJECT-ENVELOPE.md`) are all specified. No production authority switch or plaintext migration is claimed. | Final S5 cross-contract consistency audit (mutual reference integrity across all four documents) is complete β€” two mechanical citation-drift findings were corrected (a stale disposition-count note in Β§10.4.1, and S5-B3's mis-citation of S5-B1's migration-time mechanism for its own ordinary-write staging debris), no substantive inconsistency was found. Headless Core vectors, fault-injection tests, per-record migration tests, packaged durability evidence, and explicit #357/#359/#360/#361 reconciliation are still required before implementation gates can close |

@cubic-dev-ai cubic-dev-ai Bot Sep 2, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Before the post-merge green verification exists, this row advertises the design as terminal. Keep S5_TERMINAL pending until the merge and required post-merge checks succeed, then update both status sources together.

Prompt for AI agents
Check if this issue is valid β€” if so, understand the root cause and fix it. At docs/native/CORE-MIGRATION-LEDGER.md, line 20:

<comment>Before the post-merge green verification exists, this row advertises the design as terminal. Keep `S5_TERMINAL` pending until the merge and required post-merge checks succeed, then update both status sources together.</comment>

<file context>
@@ -17,7 +17,7 @@ scope shifts β€” it is a living decision record, not a one-time snapshot.
 | 8 | AI services | TS, `services/ai/` (44 files, 5,401 lines), mixed portability (retry/routing/error-taxonomy renderer-neutral vs. `computeShaderFactory.ts`/`webGpuDetectorService.ts`/`.wgsl` inherently WebGPU-coupled) | Mixed | Medium-high (API keys) | Low-medium | Medium | Uncertain β€” too large/mixed to assess narrowly | **Out of scope for all of Wave 2** | None proposed | None |
 | 9 | Project state-shape compatibility adapter | TS, `features/project/coreBoundaryAdapter.ts` at the Core boundary + Rust, `crates/worldscript-project` schema | High at the boundary β€” production Redux `EntityState` must be translated without importing Redux into Core | Low | High β€” ID/order preservation is part of project identity | Medium | High β€” every native renderer needs the same conversion contract | **2 β€” Wave 2 prerequisite before G1 evaluation** | **In progress β€” typed adapter, fixtures, and the first observation-only desktop shadow caller are locally proven; no authority switch**; normalizes array or Redux `EntityState` to renderer-neutral arrays and reconstructs the TS-side shape only at the integration boundary. The Rust verdict is partial because unknown fields are not rejected, and the envelope's `schemaVersion` is synthesized rather than persisted. | `tests/unit/features/project/coreBoundaryAdapter.test.ts` covers array and `EntityState` inputs, round-trip ID/order preservation, and rejection of duplicate IDs, missing references, and orphaned entities for both characters and worlds; the envelope fixture is accepted by Rust after migration and validation |
-| 10 | R-15 protected desktop storage contract | **Design only (S5-A baseline)**, `docs/native/R15-SECURE-STORAGE-CONTRACT.md`; current desktop records remain TS/Tauri filesystem authority | High β€” future Core must serve Tauri and Qt without renderer-private crypto semantics | High | High β€” durability, migration, and identity binding protect user data | High | **Highest β€” cross-renderer security/durability contract** | **3 β€” S5-A, S5-B1, S5-B2, and S5-B3 all admitted; final cross-contract audit pending** | **S5_A_ADMITTED=YES / S5_B1_ADMITTED=YES / S5_B2_ADMITTED=YES / S5_B3_ADMITTED=YES / S5_IMPLEMENTATION_READY=NO / S5_TERMINAL=NO (pending audit)**; inventory, identity/AAD envelope, key epochs, fail-closed reads, durable replacement, crash-resumable migration, unified admission, race-free `AuthoritySnapshot` acquisition/lifetime (`docs/native/r15/AUTHORITY-SNAPSHOT-LIFETIME.md`), canonical migration source/payload evidence (`docs/native/r15/MIGRATION-SOURCE-EVIDENCE.md`), and the chunked large-object envelope (`docs/native/r15/CHUNKED-LARGE-OBJECT-ENVELOPE.md`) are all specified. No production authority switch or plaintext migration is claimed. | Final S5 cross-contract consistency audit (mutual reference integrity across all four documents); then headless Core vectors, fault-injection tests, per-record migration tests, packaged durability evidence, and explicit #357/#359/#360/#361 reconciliation required before implementation gates can close |
+| 10 | R-15 protected desktop storage contract | **Design only (S5-A baseline)**, `docs/native/R15-SECURE-STORAGE-CONTRACT.md`; current desktop records remain TS/Tauri filesystem authority | High β€” future Core must serve Tauri and Qt without renderer-private crypto semantics | High | High β€” durability, migration, and identity binding protect user data | High | **Highest β€” cross-renderer security/durability contract** | **3 β€” S5-A, S5-B1, S5-B2, and S5-B3 all admitted; final cross-contract audit complete, S5_TERMINAL** | **S5_A_ADMITTED=YES / S5_B1_ADMITTED=YES / S5_B2_ADMITTED=YES / S5_B3_ADMITTED=YES / S5_IMPLEMENTATION_READY=NO / S5_TERMINAL=YES**; inventory, identity/AAD envelope, key epochs, fail-closed reads, durable replacement, crash-resumable migration, unified admission, race-free `AuthoritySnapshot` acquisition/lifetime (`docs/native/r15/AUTHORITY-SNAPSHOT-LIFETIME.md`), canonical migration source/payload evidence (`docs/native/r15/MIGRATION-SOURCE-EVIDENCE.md`), and the chunked large-object envelope (`docs/native/r15/CHUNKED-LARGE-OBJECT-ENVELOPE.md`) are all specified. No production authority switch or plaintext migration is claimed. | Final S5 cross-contract consistency audit (mutual reference integrity across all four documents) is complete β€” two mechanical citation-drift findings were corrected (a stale disposition-count note in Β§10.4.1, and S5-B3's mis-citation of S5-B1's migration-time mechanism for its own ordinary-write staging debris), no substantive inconsistency was found. Headless Core vectors, fault-injection tests, per-record migration tests, packaged durability evidence, and explicit #357/#359/#360/#361 reconciliation are still required before implementation gates can close |
 
 ## Decisions this table records
</file context>
Fix with cubic

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.

πŸ“’ Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant