Add authenticated recovery envelopes and frontier validation #42

Merged
Collaborator

Summary

recovery_crypto.py      Bounded AES-256-GCM envelopes, single-use seal reservations and key custody
recovery_frontier.py    Canonical state encoding, authenticated markers and successor validation
pyproject.toml          Direct cryptography dependency
uv.lock                 cryptography 50.0.2 and cffi 2.1.1
tests/                  Envelope, custody and frontier contract tests

Evidence

  • The pristine base 9af46b3e passed 427 unit and 66 transport tests. The initial head cadca3566 passed 30 focused, 457 unit and 66 transport tests. The unit suite also passed on Python 3.12. Ruff, strict mypy and wheel and source builds passed.
  • uv lock --check --offline passed on cadca3566. The locked runtime reports cryptography 50.0.2, cffi 2.1.1 and bundled OpenSSL 4.0.3.
  • The AES-GCM allocation test passed on 143a3415. At the maximum frontier plaintext size, seal and open each peaked below the required output allocation plus 1 MiB. Open passes a memoryview of the ciphertext into AES-GCM.
  • The security review measured the largest decoded frontier at 1.81× plaintext resident and 3.04× plaintext at open peak. It measured approximately 130 MB with F, C and M decoded, against the 48 MiB charged by P09. E06 tracks the decoded object charge. Issue #43.
  • On 143a3415, 36 focused recovery tests, uv lock --check --offline, Ruff and strict mypy passed. Tests cover digest-before-key ordering, fixed refusals without exception chaining, marker revision and lifetime bounds, and the bounded newline scan. Removing the implicit frontier key obligation made its regression test fail. Round 1 dispositions.
  • The D8 test passed on 143a3415. After sealing and reopening M, it compares F's occurrence, fact, inventory and spent-command records byte for byte and preserves F's existing certificates and reserves. It derives C through one original admission and checks that M carries exactly C's lifetime usage. The full ledger comparison permits the encoded cancellation certificate and one completion command entry, with the successor revision and authenticated premise. The certificate cap and original deadline are asserted in the suite.
  • Advisory review on 2026-11-20 at 02:41–02:44 UTC. OSV PyPI version queries and GitHub Advisory Database pip queries returned zero entries for cryptography==50.0.2 and cffi==2.1.1. The locked environment reported OpenSSL 4.0.3, which pyca also documents for its Windows, macOS, and Linux wheels. OSV query API, GitHub Advisory Database queries, pyca wheel changelog.
  • For OpenSSL 4.0.3, the OSV query by upstream tag commit af1775b60dfa141a4ad762585052cabeb9f37e9e returned CVE-2026-124709, CVE-2026-35190, CVE-2026-88822, CVE-2026-88823, CVE-2026-95691, and CVE-2026-95692. The GitHub version and upstream repository advisory queries returned zero entries. OpenSSL's own affected ranges additionally list CVE-2026-107493 and CVE-2026-107496. The affected APIs are QUIC, TLS key-share processing, AES-GCM-SIV, PEM stack appending, and CMS encryption. The recovery code uses AESGCM and standard-library HMAC-SHA256, so these entries do not affect the recovery paths added here. OpenSSL 4.0.3 tag, OpenSSL 4.0 advisories.
  • E03, E05, E06, E07 and E10 have module-level evidence and remain open for integration. Child 7 still owes separate historical-key archive recovery, simultaneous maximum-copy measurements and a maximum archive restore. E09, E12 and E13 remain owed. E15 stays with #6.

Merge Danger

Door Two-way. A revert can remove the private modules and direct dependency.

Blast radius Recovery envelope and frontier modules.

Closes #31

Co-Authored-By: gpt-6.2-sol noreply@openai.com

## Summary ```text recovery_crypto.py Bounded AES-256-GCM envelopes, single-use seal reservations and key custody recovery_frontier.py Canonical state encoding, authenticated markers and successor validation pyproject.toml Direct cryptography dependency uv.lock cryptography 50.0.2 and cffi 2.1.1 tests/ Envelope, custody and frontier contract tests ``` ## Evidence - The pristine base `9af46b3e` passed 427 unit and 66 transport tests. The initial head `cadca3566` passed 30 focused, 457 unit and 66 transport tests. The unit suite also passed on Python 3.12. Ruff, strict mypy and wheel and source builds passed. - `uv lock --check --offline` passed on `cadca3566`. The locked runtime reports `cryptography 50.0.2`, `cffi 2.1.1` and bundled OpenSSL 4.0.3. - The AES-GCM allocation test passed on `143a3415`. At the maximum frontier plaintext size, seal and open each peaked below the required output allocation plus 1 MiB. Open passes a memoryview of the ciphertext into AES-GCM. - The security review measured the largest decoded frontier at 1.81× plaintext resident and 3.04× plaintext at open peak. It measured approximately 130 MB with F, C and M decoded, against the 48 MiB charged by P09. E06 tracks the decoded object charge. [Issue #43](https://git.groupthink.asia/dev/attention-mind-mcp/issues/43). - On `143a3415`, 36 focused recovery tests, `uv lock --check --offline`, Ruff and strict mypy passed. Tests cover digest-before-key ordering, fixed refusals without exception chaining, marker revision and lifetime bounds, and the bounded newline scan. Removing the implicit frontier key obligation made its regression test fail. [Round 1 dispositions](https://git.groupthink.asia/dev/attention-mind-mcp/issues/31#issuecomment-43589). - The D8 test passed on `143a3415`. After sealing and reopening M, it compares F's occurrence, fact, inventory and spent-command records byte for byte and preserves F's existing certificates and reserves. It derives C through one original admission and checks that M carries exactly C's lifetime usage. The full ledger comparison permits the encoded cancellation certificate and one completion command entry, with the successor revision and authenticated premise. The certificate cap and original deadline are asserted in the suite. - Advisory review on 2026-11-20 at 02:41–02:44 UTC. OSV PyPI version queries and GitHub Advisory Database `pip` queries returned zero entries for `cryptography==50.0.2` and `cffi==2.1.1`. The locked environment reported OpenSSL 4.0.3, which pyca also documents for its Windows, macOS, and Linux wheels. [OSV query API](https://google.github.io/osv.dev/api/#tag/api/POST/v1/querybatch), [GitHub Advisory Database queries](https://docs.github.com/en/rest/security-advisories/global-advisories#list-global-security-advisories), [pyca wheel changelog](https://cryptography.io/en/50.0.2/changelog/#v50-0-2). - For OpenSSL 4.0.3, the OSV query by upstream tag commit `af1775b60dfa141a4ad762585052cabeb9f37e9e` returned CVE-2026-124709, CVE-2026-35190, CVE-2026-88822, CVE-2026-88823, CVE-2026-95691, and CVE-2026-95692. The GitHub version and upstream repository advisory queries returned zero entries. OpenSSL's own affected ranges additionally list CVE-2026-107493 and CVE-2026-107496. The affected APIs are QUIC, TLS key-share processing, AES-GCM-SIV, PEM stack appending, and CMS encryption. The recovery code uses `AESGCM` and standard-library HMAC-SHA256, so these entries do not affect the recovery paths added here. [OpenSSL 4.0.3 tag](https://github.com/openssl/openssl/releases/tag/openssl-4.0.3), [OpenSSL 4.0 advisories](https://openssl-library.org/news/vulnerabilities-4.0/). - E03, E05, E06, E07 and E10 have module-level evidence and remain open for integration. Child 7 still owes separate historical-key archive recovery, simultaneous maximum-copy measurements and a maximum archive restore. E09, E12 and E13 remain owed. E15 stays with #6. ## Merge Danger **Door** Two-way. A revert can remove the private modules and direct dependency. **Blast radius** Recovery envelope and frontier modules. Closes #31 Co-Authored-By: gpt-6.2-sol <noreply@openai.com>
Add authenticated recovery envelopes and frontier validation
All checks were successful
ci/woodpecker/pr/validation Pipeline was successful
cadca3566d
Implement bounded AES-GCM envelopes with purpose-separated keys, separate key custody, rotation, and single-use seal reservations. Add canonical frontier encoding, authenticated incarnation checks, cancellation marker validation, and successor retention rules. Declare cryptography as a direct dependency and keep the lock at 50.0.2.

All 30 focused tests, 457 unit tests, and 66 transport tests passed. The pristine baseline passed 427 unit tests and 66 transport tests. Python 3.12 also passed all unit tests. Lock validation, Ruff, strict mypy for src, and the wheel and source builds passed.

Exact advisory queries for cryptography 50.0.2, cffi 2.1.1, and bundled OpenSSL 4.0.3 returned no matches in OSV at 2026-11-20T02:55:46Z or GitHub Advisory at 2026-11-20T02:44:40Z. OpenSSL's published 4.0.3 advisories concern paths outside the AES-GCM and HMAC operations used here. [OpenSSL advisory index](https://openssl-library.org/news/vulnerabilities/index.html)

E03, E05, E06, E07, and E10 have module-level evidence and remain open. Separate historical-key archive recovery, simultaneous maximum-copy measurements, and maximum archive success remain child 7 integration evidence. E09, E12, and E13 remain owed. E15 stays with #6.

Closes #31
Co-Authored-By: gpt-6.2-sol <noreply@openai.com>
Tighten recovery envelope and marker validation
All checks were successful
ci/woodpecker/pr/validation Pipeline was successful
143a3415d8
Require exact recovery digests and validate API inputs
All checks were successful
ci/woodpecker/pr/validation Pipeline was successful
6b3845fe67
Pin digest construction and normalize crypto input refusals
All checks were successful
ci/woodpecker/pr/validation Pipeline was successful
5e2757fa1b
Validate key obligations and contain resolver failures
All checks were successful
ci/woodpecker/pr/validation Pipeline was successful
f353463360
Test malformed resolver FoundationError arguments
All checks were successful
ci/woodpecker/pr/validation Pipeline was successful
b9361ceb87

This was generated by AI during the merge gate.

Merge gate record: PR #42 (#31), head b9361ceb87

Gate run by minds-guide@voyager under the operator's standing grant (delegation operator-word-d982c2768589). The approved spec is the #31 spec rebaselined onto 9af46b3e, amended once at round 1 under the operator rulings below (amended copy sha256 8e706b171dd0c74da7232472200767c979d14ef77d0ac50dc74424b9c9b63e42). mind-spec confirmed that the amended copy has no clash with the canonical.

Reviews. Three independent sub-agents with no shared context reviewed a detached worktree at each exact head. Each round after the first was a delta review.

Round Head Spec Standards Security (§19)
1 cadca356 FAIL: SP1, SP2 (should-fix), SP3 (nit) FAIL: S2, S3 (should-fix), S6 (nit); S1, S4 and S5 dropped because the spec names those forms FAIL: L1, L2 (low), I3, I4 (info)
2 143a3415 PASS, 0 FAIL: S3 class not complete, 2 nits FAIL: R2-SEC1 (low, a regression from the I4 change)
3 6b3845fe FAIL: R3-1 (should-fix), 1 nit FAIL: nits only PASS, 0
4 5e2757fa PASS, 0 PASS PASS, 0
5 f3534633 FAIL: R5-1 (should-fix, test gap) PASS PASS, 0
6 b9361ceb PASS, 0 Not re-run: test-only delta Not re-run: test-only delta

Round 5 hardened two inputs that two reviewers flagged as one class. Open risk 1 (D7) freezes recovery_crypto.py for the later #6 children, so a fix now costs less than a write-set expansion later.

Operator rulings (section 6).

  • L1 (_fail inside except keeps the library exception as __context__) and I3 (an unbounded newline search before the class cap): fix before merge. Both are fixed. No refusal carries a cause or a context, and the newline search stops at 65,536 bytes.
  • L2 (the decoded frontier object graph is not charged under P09): correct the claim and carry the charge to E06. The PR body records the measured factors, and #43 tracks the charge.
  • I4 (loss-drill codes came from unauthenticated header fields): compare the digest first. The spec amendment moves the digest check before key resolution, with the code envelope_replayed.
  • SP2 (check_marker accepted a refund of C's admission): tighten and record the residual. The marker must have revision == F+1 and F <= lifetime <= F+1. Open risk 7 records the residual: a refund by one is not detectable on the path with no PREPARED payload.
  • R2-SEC1 (a None expected digest skipped the digest check): fix before merge. EnvelopeExpectation now validates the digest, and the comparison in open_envelope is unconditional.

Red side. The guide and the Spec reviewer measured each fix with mutations in a separate copy of the tree. At round 5, 64 of 67 mutations turned a test red. Two of the three survivors (N3o and R5i) are equivalent mutants. The third was R5h, which removed the argument-shape fallback in _resolve, and became R5-1. At round 6 the new parametrised test fails 3 of 4 cases under R5h and passes 4 of 4 at the head.

Spec conditions from Half-A.

  • D8 (P05.1 ledger reading): met. build_marker asserts the ledger parts in one exact equality, and a mutation of each part turns the test red.
  • uv lock --check --offline: green at each head.
  • The memoryview no-copy test: green. Open passes a memoryview of the ciphertext into AES-GCM.
  • Advisory query (spec line 63): the PR body records OSV and GitHub Advisory queries with their timestamp. cryptography 50.0.2 and cffi 2.1.1 have no entries. The bundled OpenSSL 4.0.3 has 8 published advisories, all fixed in 4.0.4. They cover PEM stack appending, QUIC (3), TLS 1.3 key share, CMS encryption and AES-GCM-SIV (2). None affects AES-GCM or HMAC, so the condition to bump or hold does not fire. The new modules import only AESGCM and InvalidTag.
  • Module scope (acceptance criterion 289): the PR body states that E03, E05, E06, E07 and E10 have module-level evidence only and stay open for child 7.

CI. Pipeline 53 is success on the exact head b9361ceb, and the raw logs were audited:

  • 4 steps, 0 failure signatures;
  • quality is clean;
  • unit: 481 passed;
  • real-http-transport: 66 passed.

Integrate. The locked-environment integrate on the exact head b9361ceb has these results:

  • readyForMerge and lensReadyForMerge are true, and testResult is green.
  • verifiedCommitSha is b9361ceb, with 0 rework rounds.
  • The approved spec sha256 is 8e706b17.
  • The forbidden-mutation check is clean over the 6 Primary Files.
  • All 7 verification receipts passed.

The integrate raised two warnings. This comment answers the first, because it is the posted review record. PR body line 21 answers the second, because it states the module-scope limit.

Observations (not findings).

  • This PR does not change the resolved dependency set. cryptography 50.0.2 was already locked on main through pyjwt and joserfc, and the lock diff adds only the direct specifier. 50.0.2 is the latest release on PyPI, so no release with OpenSSL 4.0.4 exists yet. The OpenSSL advisories above are therefore a repository-wide dependency matter, not a property of this PR.
  • A third-party key resolver can pass any string code through _resolve. The resolver supplies key material, so it is inside the trust boundary.
  • A transient resolver error now reads as key_unavailable. Child 5 (#33) and Restore (#35) must not treat key_unavailable as permanent key loss.

Merge. Pinned to head b9361ceb with codex-svd pinned-merge, which refuses while a live SVD run holds this repository.

> *This was generated by AI during the merge gate.* ## Merge gate record: PR #42 (#31), head b9361ceb87c1a71129c29eb4c4d29e99ecbd74c9 Gate run by minds-guide@voyager under the operator's standing grant (delegation `operator-word-d982c2768589`). The approved spec is the #31 spec rebaselined onto 9af46b3e, amended once at round 1 under the operator rulings below (amended copy sha256 `8e706b171dd0c74da7232472200767c979d14ef77d0ac50dc74424b9c9b63e42`). mind-spec confirmed that the amended copy has no clash with the canonical. **Reviews.** Three independent sub-agents with no shared context reviewed a detached worktree at each exact head. Each round after the first was a delta review. | Round | Head | Spec | Standards | Security (§19) | | --- | --- | --- | --- | --- | | 1 | cadca356 | FAIL: SP1, SP2 (should-fix), SP3 (nit) | FAIL: S2, S3 (should-fix), S6 (nit); S1, S4 and S5 dropped because the spec names those forms | FAIL: L1, L2 (low), I3, I4 (info) | | 2 | 143a3415 | PASS, 0 | FAIL: S3 class not complete, 2 nits | FAIL: R2-SEC1 (low, a regression from the I4 change) | | 3 | 6b3845fe | FAIL: R3-1 (should-fix), 1 nit | FAIL: nits only | PASS, 0 | | 4 | 5e2757fa | PASS, 0 | PASS | PASS, 0 | | 5 | f3534633 | FAIL: R5-1 (should-fix, test gap) | PASS | PASS, 0 | | 6 | b9361ceb | PASS, 0 | Not re-run: test-only delta | Not re-run: test-only delta | Round 5 hardened two inputs that two reviewers flagged as one class. Open risk 1 (D7) freezes `recovery_crypto.py` for the later #6 children, so a fix now costs less than a write-set expansion later. **Operator rulings (section 6).** - L1 (`_fail` inside `except` keeps the library exception as `__context__`) and I3 (an unbounded newline search before the class cap): fix before merge. Both are fixed. No refusal carries a cause or a context, and the newline search stops at 65,536 bytes. - L2 (the decoded frontier object graph is not charged under P09): correct the claim and carry the charge to E06. The PR body records the measured factors, and #43 tracks the charge. - I4 (loss-drill codes came from unauthenticated header fields): compare the digest first. The spec amendment moves the digest check before key resolution, with the code `envelope_replayed`. - SP2 (`check_marker` accepted a refund of C's admission): tighten and record the residual. The marker must have `revision == F+1` and `F <= lifetime <= F+1`. Open risk 7 records the residual: a refund by one is not detectable on the path with no PREPARED payload. - R2-SEC1 (a `None` expected digest skipped the digest check): fix before merge. `EnvelopeExpectation` now validates the digest, and the comparison in `open_envelope` is unconditional. **Red side.** The guide and the Spec reviewer measured each fix with mutations in a separate copy of the tree. At round 5, 64 of 67 mutations turned a test red. Two of the three survivors (N3o and R5i) are equivalent mutants. The third was R5h, which removed the argument-shape fallback in `_resolve`, and became R5-1. At round 6 the new parametrised test fails 3 of 4 cases under R5h and passes 4 of 4 at the head. **Spec conditions from Half-A.** - D8 (P05.1 ledger reading): met. `build_marker` asserts the ledger parts in one exact equality, and a mutation of each part turns the test red. - `uv lock --check --offline`: green at each head. - The memoryview no-copy test: green. Open passes a memoryview of the ciphertext into AES-GCM. - Advisory query (spec line 63): the PR body records OSV and GitHub Advisory queries with their timestamp. `cryptography` 50.0.2 and `cffi` 2.1.1 have no entries. The bundled OpenSSL 4.0.3 has 8 published advisories, all fixed in 4.0.4. They cover PEM stack appending, QUIC (3), TLS 1.3 key share, CMS encryption and AES-GCM-SIV (2). None affects AES-GCM or HMAC, so the condition to bump or hold does not fire. The new modules import only `AESGCM` and `InvalidTag`. - Module scope (acceptance criterion 289): the PR body states that E03, E05, E06, E07 and E10 have module-level evidence only and stay open for child 7. **CI.** Pipeline 53 is `success` on the exact head b9361ceb, and the raw logs were audited: - 4 steps, 0 failure signatures; - quality is clean; - unit: 481 passed; - real-http-transport: 66 passed. **Integrate.** The locked-environment integrate on the exact head b9361ceb has these results: - `readyForMerge` and `lensReadyForMerge` are true, and `testResult` is green. - `verifiedCommitSha` is b9361ceb, with 0 rework rounds. - The approved spec sha256 is 8e706b17. - The forbidden-mutation check is clean over the 6 Primary Files. - All 7 verification receipts passed. The integrate raised two warnings. This comment answers the first, because it is the posted review record. PR body line 21 answers the second, because it states the module-scope limit. **Observations (not findings).** - This PR does not change the resolved dependency set. `cryptography` 50.0.2 was already locked on main through pyjwt and joserfc, and the lock diff adds only the direct specifier. 50.0.2 is the latest release on PyPI, so no release with OpenSSL 4.0.4 exists yet. The OpenSSL advisories above are therefore a repository-wide dependency matter, not a property of this PR. - A third-party key resolver can pass any string code through `_resolve`. The resolver supplies key material, so it is inside the trust boundary. - A transient resolver error now reads as `key_unavailable`. Child 5 (#33) and Restore (#35) must not treat `key_unavailable` as permanent key loss. **Merge.** Pinned to head b9361ceb with `codex-svd pinned-merge`, which refuses while a live SVD run holds this repository.
svc-svd-writer deleted branch feat/svd-dev-attention-mind-mcp-31-dd-469-6-child-3-7-encrypt-3b223369 2026-11-20 04:37:21 +00:00
Sign in to join this conversation.
No description provided.