Skip to content

Implement feature 001 corporate signing MVP - #2

Draft
brettheap wants to merge 131 commits into
docs/opensig-foundationfrom
001-corporate-signing-mvp
Draft

brettheap wants to merge 131 commits into
docs/opensig-foundationfrom
001-corporate-signing-mvp

Conversation

@brettheap

@brettheap brettheap commented Nov 8, 2026 •

Copy link
Copy Markdown

Implement feature 001, the Apache-2.0 corporate signing MVP: openAutograph approval, openCryptograph PDF protection, bounded Hermes tools and synthetic healthcare consumer contracts.

Work in progress. T001 establishes a verified project-local Node 24.22.2 bootstrap, pinned build tooling and a fail-closed verification runner. Remaining application tasks are not complete. The contract validator is in progress.

T001 mechanical evidence: 27 runner self-tests passed (no skipped/todo cases), exact file scope and clean worktree checked, actual writer replies verified as claude-opus-5-5. Independent regression/validation reports remain pending. No signing-runtime, legal, production or blockchain acceptance is claimed.

Stacked on foundation #1. Canonical proposal/specification/tasks: opensoft/openSig-spec#2. All original code is Apache-2.0; the application dependency gate stays MIT/Apache-only. Platform-license scope and real deployment prerequisites remain open gates, not assumed passes.

The PR will be updated with the final implementation scope and acceptance evidence before it is marked ready. No production deployment or real signature request is part of this change.

Summary by Sourcery

Establish the project-local runtime and fail-closed verification foundation for the corporate signing MVP.

New Features:

  • Add a pinned Node.js 24.22.2 project bootstrap with cryptographically verified downloads and installation receipts.
  • Introduce a fail-closed verification framework with registered unit, contract, acceptance, aggregate, and release modes.
  • Add tooling self-tests covering verification behavior, environment validation, evidence handling, capability gates, and test ownership.

Enhancements:

  • Define project-local npm, TypeScript, lockfile, runtime, evidence, and verification conventions, including frozen runner governance.
  • Make verification outcomes explicit through structured result artifacts, tree digests, capability checks, and non-zero failure statuses.

Build:

  • Add project package metadata, exact development dependency pins, lockfile, Node version selection, npm configuration, and TypeScript configuration.

Documentation:

  • Document the local runtime bootstrap, verification commands, evidence requirements, exit statuses, and runner freeze rules.

Tests:

  • Add 27 verification-runner self-tests with no skipped or todo cases.

…nner

Implements T001 of 001-corporate-signing-mvp against spec plan.md
(commit 02142d9) sections Technical Context and Verification runner
contract.

- scripts/fetch-node.sh: POSIX sh, idempotent, fail-closed fetch of the
  official node-v24.22.2-linux-x64 tarball into gitignored tools/. The
  clearsigned SHASUMS256.txt.asc is verified with gpg in an ephemeral
  GNUPGHOME holding only the embedded release key; the imported primary
  fingerprint and the valid-signature primary key must both equal
  5BE8A3F6C8A5C01D106C0AD820B1A390B168D356. The tarball SHA-256 must equal
  both the signed line (read from gpg's verified output) and the embedded
  constant 48cc0e21...aaf75. Writes tools/node.receipt.json; a second run
  re-checks the receipt, the node binary digest and --version and
  downloads nothing. Never uses the host Node.
- .node-version 24.22.2; package.json engines 24.22.2, scripts verify,
  typecheck and test (verify all-unit); .npmrc engine-strict, save-exact,
  ignore-scripts; exact devDependencies typescript 6.0.3 and @types/node
  24.19.2 (lockfile: typescript Apache-2.0, @types/node MIT,
  undici-types 7.24.6 MIT); tsconfig.json as planned.
- scripts/verify-modes.mjs: all 43 modes of the plan's registry,
  including us3-real-model (T041, in no aggregate); all-unit and
  acceptance-local components derived from the leaf modes.
- scripts/verify.mjs: engine and CLI. Exactly one mode, no flags, no
  relax path. Registry validation and completeness, ENV checks (runtime,
  platform, lockfile vs installed tree, test-filter and preload flags in
  NODE_OPTIONS or argv, vendored contract digest), two sentinels,
  synchronous capability probes, typecheck, explicit file expansion,
  node:test run() with process isolation per file in its own process
  group (per-file timeout kills the group and counts as FAIL), counting
  from the event stream (file-level wrapper entries never count as tests;
  "only" detected from its diagnostic), case ids, evidence freshness,
  labels, tree digest and mock identities, aggregates that stop at the
  first non-PASS, and the release mode that fails while any gate is open,
  naming every open gate on its status line.
- tests/tooling/verification-runner.test.mjs: the plan's 26 self-test
  cases plus case 27 (preload flags -> ENV_MISMATCH), with an after()
  guard requiring exactly 27 executed tests.
- .gitignore gains the planned Node, output, database, key and env
  patterns; AGENTS.md states the real commands and the freeze rule.

These three runner files are frozen at this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T08:44:49.336929Z 97a687e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sourcery-ai

sourcery-ai Bot commented Nov 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Defines the verification mode registry and its task, test, capability, evidence, and aggregate declarations that the runner relies on.

  • scripts/verify-modes.mjs L1-268

API

Implements the verification runner’s CLI and execution contract, including validation, isolation, status reporting, and evidence checks.

  • scripts/verify.mjs L1-1406

Configuration

Adds a pinned, verified Node bootstrap so project commands can use the required local runtime without relying on host Node.

  • scripts/fetch-node.sh L1-226

Sets the pinned runtime, package scripts and dependencies, TypeScript compiler options, and ignored local artifacts required by the project workflow.

  • .gitignore L13-29
  • .node-version L1
  • .npmrc L1-3
  • package.json L1-20
  • tsconfig.json L1-18

Documentation

Documents the established runtime and verification commands, evidence rules, and freeze policy for the runner.

  • AGENTS.md L24-43

Tests

Adds self-tests for runner argument handling, execution and failure statuses, evidence checks, registry completeness, and aggregation behavior.

  • tests/tooling/verification-runner.test.mjs L1-643

Lock files and vendored code

Records the exact dependency tree corresponding to the package manifest’s pinned development dependencies.

  • package-lock.json L1-51

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

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a71b3bc88e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +172 to +173
process.kill(pid, 0);
return false;

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 Badge Distinguish terminated zombies from running test processes

In Linux containers whose PID 1 does not reap orphaned children, killing the driver and test process group together leaves the test child as a zombie. process.kill(pid, 0) still succeeds for that terminated process, so RT-12 fails after its polling period even though the timeout correctly killed the group. I reproduced this in the provided container: 26 self-tests passed, while RT-12 failed with the child in state Z and parent PID 1. This makes the tooling verification gate fail in that environment; either reap the child before terminating its parent or distinguish zombies from live processes in this check.

AGENTS.md reference: AGENTS.md:L38-L39

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 7157401 (T001, A-007 runner round). processGone now treats a process in state Z or X in /proc/<pid>/stat as terminated, and RT-12 creates a real unreaped zombie to prove it. A mutant whose timeout kills only the driver and not its process group still fails RT-12. Independently re-checked. A follow-up hardening for hosts without /proc (fall back to signal 0 / ESRCH instead of treating ENOENT as gone) is in progress in the same runner round.

Implements T026 of 001-corporate-signing-mvp (tasks.md at spec 02142d9;
plan.md registry row no-secrets: unit, tests/no-secrets/**, minTests 8,
NS-01..NS-07).

- scripts/no-secrets.mjs scans every path from `git ls-files` plus
  `git diff --cached --name-only`: the index blob and, where it differs,
  the working-tree content. Untracked files are not scanned. Rules:
  private-key-pem (any PEM private-key type, indented or with escaped
  newlines), pkcs12-content (.p12/.pfx, PFX DER structure, base64-embedded
  DER), sqlite-database (database, WAL and journal headers), fixture-image
  (raster magic bytes, image extensions and SVG under any fixtures/
  directory), env-file (.env, .env.*, .envrc) and secret-assignment (known
  secret names assigned literal values; references and placeholders are
  not findings). Output names rule, file, source and line only, never
  matched content. Exit 0 clean, 1 findings, 2 usage or repository error.
- tests/no-secrets/no-secrets.test.mjs: NS-01..NS-07 plus staged versus
  working-tree scanning, error exits, and a scan requiring this repository
  to be clean. All positive samples are generated at runtime in temporary
  Git repositories (node:crypto keys, a node:sqlite database, PFX and
  image bytes built from their structure).

verify: no-secrets PASS exit=0 files=1 tests=10 pass=10 fail=0 skip=0 todo=0 cases=7/7

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1243e66db2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/no-secrets.mjs Outdated
// NAME (optionally quoted) followed by ":" or "=" (not "==", "=>", "=~") and a
// value: double-quoted, single-quoted, backtick (no interpolation) or bare.
const ASSIGNMENT =
/(?<![A-Za-z0-9_$.-])(["'`]?)([A-Za-z_][A-Za-z0-9_.-]*)\1[ \t]*(?::|=(?![=>~]))[ \t]*(?:"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'|`((?:[^`\\\r\n$]|\\.)*)`|([^\s"'`,;#&|)\]}]+))/g;

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 Badge Scan secret assignments with TypeScript type annotations

For typed declarations such as export const apiKey: string = 'credential-0123456789';, the regex treats string as the assigned value and never examines the actual literal. I reproduced this with a staged .ts file: it produces no finding, whereas the equivalent untyped declaration is detected. Since this repository targets TypeScript, ordinary typed credential declarations can silently pass the no-secrets gate. Recognize type annotations before the assignment operator so these literals are scanned too.

AGENTS.md reference: AGENTS.md:L20-L20

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Resolved in e2db5ac (T026 fix): typed declarations such as const apiKey: string = '…' are now scanned. Proving test: [NS-06] typed declarations, Go :=, flags, URL credentials and upper-case secrets are reported (tests/no-secrets/no-secrets.test.mjs). Recorded in the spec findings ledger (openSig-spec a05fcee, A-008).

Comment thread scripts/no-secrets.mjs Outdated
if (value.length < 8) return false;
if (value.includes('${')) return false;
if (REFERENCE_VALUE.test(value) || PLACEHOLDER_WORDS.test(value)) return false;
if (/^[A-Z][A-Z0-9_]*$/.test(value)) return false; // names another variable

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 Badge Preserve quote information when exempting variable references

When a quoted credential consists of uppercase letters, digits and underscores, this check incorrectly exempts it as a variable reference. For example, a staged JSON file containing {"password":"ABCD0123456789XYZ"} produces no finding, even though JSON strings cannot reference another variable. textFindings() discards the quoting distinction before calling this function, so the exemption also suppresses actual string literals in JavaScript and configuration files. Restrict the variable-name exemption to contexts that genuinely permit references instead of applying it to quoted literals.

AGENTS.md reference: AGENTS.md:L20-L20

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 7f68d48 (T026). textFindings() keeps the quoting information, so a quoted literal shaped like a variable name, such as {"password":"ABCD_0123456789XYZ"}, is reported. The reference exemption now applies only to unquoted reference contexts: OTHER_VAR, process.env.X, import.meta.env.X, ${VAR} and $VAR. Test: NS-09. An independent re-check over 2,964 generated assignments lost none of the earlier findings. A remaining narrow exemption, quoted literals containing ${, is being closed as NS-10.

Comment thread scripts/no-secrets.mjs
};

for (const path of paths) {
for (const finding of pathFindings(path)) add({ ...finding, file: path, source: 'path' });

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 Badge Skip path findings for files deleted from both trees

For a staged deletion of a previously tracked .env, .p12, or fixture image, stagedPaths() still includes the deleted pathname, and this unconditional call reports it even when neither an index entry nor a working-tree file remains. I reproduced an env-file finding after staging removal of .env. Consequently, a cleanup change cannot pass the no-secrets verification gate until after it is committed. Apply path rules only when the path still exists in the index or working tree, while continuing to scan either remaining copy.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 7f68d48 (T026). Path rules now apply only to paths that still exist in the index or the working tree, and any remaining copy is still scanned. Staged deletions of .env, a .p12 or a fixture image produce no findings. A copy kept by git rm --cached, or a file deleted only on disk, is still reported. Test: NS-08, independently re-checked.

Hardening round of T001 under spec plan.md amendment A-006 (spec
e35b968), fixing the regression review and validation run of a71b3bc.
Same files: list and verify command as T001; no mode added; the only
registry change is the L7 component order.

- M1: the tree digest is recomputed after test execution and before the
  evidence and committed-receipt checks (leaf and aggregate runs); a
  change gives EVIDENCE_MISSING "tree changed during run".
- M2: ENV_MISMATCH when package.json scripts.verify/test/typecheck or
  engines.node, .node-version, the three .npmrc keys, or any part of
  tsconfig.json (including noCheck) differ from the embedded frozen
  values.
- M3: self-tests for the release gate (FAIL naming all 7 gates, receipt
  release_ready false), aggregate CAPABILITY_ABSENT at top level, the
  aggregate receipt and committed-evidence mismatch (5), a real typecheck
  error (1) and a cancellation (1); EXPECTED_TESTS raised to 38. A
  cancellation is now also counted from the child's per-file summary,
  because an aborted test's error loses its failureType across the
  process boundary.
- L1: mock identities are found in string values at any depth.
- L3: the runner requires an empty process.execArgv.
- L4: a symlink under tests/ gives RUNNER_ERROR.
- L5: process.exitCode is set before the status line is written.
- L6: lockfile version/integrity drift is tested, and installed
  top-level packages missing from node_modules/.package-lock.json give
  ENV_MISMATCH.
- L7: acceptance-local components follow the task-line order of
  tasks.md (recipients before envelope-api).
- fetch-node.sh: GNUPGHOME is created under /tmp, /var/tmp or TMPDIR
  only when its path is at most 72 characters, so a long TMPDIR no
  longer breaks gpg ("File name too long", reproduced with a 175-char
  TMPDIR, rc=1 before, rc=0 after); gpg logs are printed on failure. F1:
  the cleanup trap is set right after the first mktemp. F2: bin/node
  (904a6d34...2a52) and the bundled npm tree (dfae9505...14f9) are
  embedded digests, checked at install and re-checked on every run. F3:
  every external tool used is prechecked.
- Unchanged by ruling: gate ids (real-ci, production-hermes), L2, the
  "verify: - USAGE" line, the single pinned signer fingerprint (F4).
- AGENTS.md: freeze rule now names the hardening commit and the frozen
  configuration values.

verify: tooling PASS exit=0 files=1 tests=38 pass=38 fail=0 skip=0 todo=0 cases=0/0
regression: no-secrets PASS exit=0 files=1 tests=10 pass=10 cases=7/7

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: f31842b080

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Implements T002 of 001-corporate-signing-mvp (tasks.md at spec e35b968;
plan.md registry row license-inventory: unit, tests/license-inventory/**,
minTests 14, LI-01..LI-10; Technical Context A-002 and Pending owner
decision on platform scope).

- scripts/license-policy.json allows exactly MIT and Apache-2.0.
- scripts/license-inventory.mjs classifies every locked package as
  shipped (production closure computed from package.json through each
  package's dependencies, optionalDependencies and peerDependencies by
  Node resolution over the lockfile, plus any package owning a file
  copied byte-for-byte into dist/) or non-shipped (devDependencies). It
  evaluates SPDX expressions (OR needs one fully allowed alternative,
  AND every term; WITH and + are not allowed; missing or unknown
  licenses fail), fails extra LICENSE*/NOTICE*/COPYING* files in shipped
  packages, writes CycloneDX 1.6 sbom.cdx.json, inventory.json and the
  platform inventory to .verify-out/, and regenerates or checks NOTICE.
  Exit 0 pass, 1 policy failure or stale NOTICE, 2 incomplete install
  or usage error.
- scripts/platform-inventory.mjs records the pinned Node runtime, ldd of
  its binary, the OpenSSL CLI, the Chromium builds and the pinned Hermes
  image; every item and the whole record are always POLICY-PENDING.
- NOTICE regenerated: the shipped closure is empty.
- docs/qualification.md (method, current result: gate PASS, 3 non-shipped
  packages) and docs/platform-inventory.md (items and 2026-11-08 snapshot).
- tests/license-inventory: LI-01..LI-10 on synthetic node_modules trees
  plus SPDX precedence, dist/ asset classification, incomplete-install
  exits, the code-leg gate and usage errors.

verify: license-inventory PASS exit=0 files=1 tests=15 pass=15 fail=0 skip=0 todo=0 cases=10/10
regression: no-secrets PASS 10/10 cases 7/7; tooling PASS 38/38

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b7a9bc7e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/license-inventory.mjs Outdated

const platform = collectPlatformInventory(options.root);
writePlatformInventory(options.out, platform);
writeJson(join(options.out, 'sbom.cdx.json'), renderCycloneDx(inventory));

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 Badge Propagate the final gate result into the SBOM

When dependency licenses pass but NOTICE is missing or stale, gate becomes FAIL, yet renderCycloneDx(inventory) still uses the earlier inventory.gate, which is PASS. I reproduced an exit-1 run whose inventory.json reports application_gate: FAIL while its SBOM reports opensig:application-gate: PASS. This leaves contradictory machine-readable qualification results and lets consumers of the SBOM mistake failed qualification for a pass. Pass the final gate result into the SBOM renderer after the NOTICE check.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Resolved in 6ec2b3e (T002 fix): renderCycloneDx now receives the final gate after the NOTICE check. Proving test: [LI-10] the SBOM and inventory.json carry one gate value, and the SBOM serial covers classifications (tests/license-inventory/license-inventory.test.mjs). Recorded in the spec findings ledger (openSig-spec a05fcee, A-008).

- package.json/package-lock.json: add devDependency playwright 1.61.1
  (playwright-core 1.61.1, optional darwin-only fsevents 2.3.2). Its
  browsers.json names chromium and chromium-headless-shell revision 1228
  (149.0.7827.55), the build present at the effective browsers path
  (PLAYWRIGHT_BROWSERS_PATH=/ms-playwright). No browser was downloaded.
  The package set is final: shipped closure empty, six non-shipped
  packages, all MIT or Apache-2.0.
- tests/qualification/dev-bytes.mjs: the "dev bytes not in distributable"
  check (whole-file asset copies and embedded dev-package file contents).
- tests/qualification/qualification.test.mjs: QL-01 shipped gate, QL-02
  exact pins, QL-03 synthetic dist with dev bytes fails, QL-04 revision
  match plus one headless launch on about:blank, QL-05 offline npm ci with
  ignore-scripts; records the non-shipped inventory and the dev tools'
  third-party notices; writes .verify-out/qualification/inventory.json
  bound to the tree digest.
- docs/qualification.md: complete package set, third-party notices of
  typescript and playwright(-core), both browser locations, the
  version-to-revision mapping, and the stale chromium-1243/1234 task note
  flagged for final reconciliation.

Verify: npm run verify -- qualification -> verify: qualification PASS
exit=0 files=1 tests=6 pass=6 fail=0 skip=0 todo=0 cases=5/5
(no-secrets, tooling and license-inventory also PASS)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd7dc418fa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

assert.equal(shell.revision, chromium.revision);

const configured = process.env.PLAYWRIGHT_BROWSERS_PATH;
const effective = configured && configured !== '0' ? resolve(configured) : join(homedir(), '.cache', 'ms-playwright');

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 Badge Honor hermetic Playwright browser paths in qualification

When PLAYWRIGHT_BROWSERS_PATH=0 is used for a project-local browser installation, QL-04 incorrectly looks under ~/.cache/ms-playwright. The frozen Chromium probe in scripts/verify.mjs resolves this setting to node_modules/playwright-core/.local-browsers, so an installation accepted by the runner can still fail qualification at the installation-marker checks (or the later executable-path assertion). Resolve the special 0 value consistently with that probe instead of treating it as an unset variable.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Resolved in cb0c4e0 (T027 fix; expectation updated in 3482aa2): QL-04 now resolves the effective browsers path the same way as the frozen runner and Playwright, including PLAYWRIGHT_BROWSERS_PATH=0. Proving test: [QL-04] the effective browsers path follows the frozen runner and Playwright, PLAYWRIGHT_BROWSERS_PATH=0 included (tests/qualification/qualification.test.mjs). Recorded in the spec findings ledger (openSig-spec a05fcee, A-008).

- src/storage/db/: openDatabase (absolute path, 0600 file, WAL,
  synchronous=FULL, foreign keys, trusted_schema off, defensive flag,
  busy timeout bounded to 1..30000 ms, default 5000); transaction() runs
  BEGIN IMMEDIATE ... COMMIT, rolls back on any throw and refuses nested or
  asynchronous callbacks; typed errors (busy, constraint kind, usage,
  migration). Tenant-scoped TenantStore helpers (insert, get, list, count,
  update, compareAndSet, delete) filter every statement on the store's
  tenant_id, inject tenant_id on insert, refuse caller-supplied tenant_id,
  check table/column names against the schema and the policy map, and
  require a transaction for writes. The only unscoped reads are the tenant
  registry and capability-hash resolution. A restricted writer path for the
  audit tables is kept out of index.ts. Migration runner: one BEGIN
  IMMEDIATE per migration with its schema_migrations record and
  user_version; refuses edited, renamed, gapped or newer-than-code applied
  migrations; an authorizer denies transaction control, savepoints,
  pragmas and ATTACH inside migration files.
- src/storage/schema/: migrations 0001..0007 create STRICT tables for every
  data-model entity (Principal is derived per request and persisted only
  as {kind, ref} columns), with composite tenant foreign keys, data-model
  checks and uniqueness, immutability/single-use/fencing triggers, and
  audit-chain linkage triggers; entities.ts maps entities to tables and
  write policies.
- tests/storage/: DB-01..DB-21, including cross-process writers, pinned
  migration digests (append-only), a complete synthetic tenant graph, and
  cross-tenant isolation.

Verify: npm run verify -- storage -> verify: storage PASS exit=0 files=4
tests=21 pass=21 fail=0 skip=0 todo=0 cases=0/0 (no-secrets also PASS)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 497fc1a52b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…b store

- src/storage/blobs/: BlobStore interface and FileBlobStore. Keys are
  tenants/<tenant_id>/sha256/<digest> (the T003 blob_ref form). A write
  goes to an exclusive 0600 temp file in the tenant's tmp directory, is
  fsynced, made read-only (0400) and closed, then published under its
  digest by link(2), which is atomic and never replaces an existing entry
  (the no-overwrite form of the rename step; Node has no
  RENAME_NOREPLACE). The digest directory is fsynced and the temp name
  removed. A repeat write verifies the existing blob and returns
  created=false; a corrupt existing blob is reported, never replaced.
  Reads open without following links (non-blocking), hash the whole
  content and refuse a mismatch, a size change, a link or a non-file.
  No cross-tenant deduplication. Streaming writes hash while writing and
  enforce the size limit and an optional expected digest. dispose()
  (retention) and sweepPartials() (leftover temp files) are the only
  removals. A narrow FsOps seam lets tests observe the write order.
- tests/blobs/: BL-01..BL-08: key layout and T003 schema acceptance,
  read verification, no overwrite (including six concurrent writer
  processes with exactly one publisher), no cross-tenant dedup, streaming
  limits, SIGKILL mid-write leaving no visible blob, input validation and
  link refusal, and the temp/fsync/publish/directory-fsync order with
  injected failures.

Verify: npm run verify -- blobs -> verify: blobs PASS exit=0 files=1
tests=8 pass=8 fail=0 skip=0 todo=0 cases=4/4 (no-secrets also PASS)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42fcaefdc0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/storage/blobs/file-store.ts Outdated
Comment on lines +244 to +247
if (created) {
this.#syncDirectory(this.#blobDir(tenantId));
} else {
const existing = this.#inspect(target, digest);

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 Badge Sync the blob directory before returning a deduplicated write

If an earlier writer links the blob but exits or encounters an error before syncing the directory, a retry takes the EEXIST branch and returns success without making that directory entry durable. Using the filesystem seam, I reproduced a directory-fsync failure followed by a successful retry with zero blob-directory fsync calls. A subsequent system crash can therefore lose a blob whose retry reported success. Sync the blob directory after verifying an existing entry as well as after creating one.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 5641716 on this branch (T028; cherry-picked from e6bb5b9): a deduplicated write now syncs the blob directory before returning. Test BL-10 (blobs mode) covers it. All 13 verify modes pass at 0bdfb83 on the pinned Node 24.22.2.

Brett Heap and others added 4 commits November 8, 2026 19:44
- src/domain/canonical/: the project's single RFC 8785 (JCS) module.
  canonicalize/canonicalBytes/canonicalDigest serialize plain JSON data
  with members sorted by UTF-16 code units, ECMAScript number
  serialization (-0 as 0, NaN/Infinity refused) and the RFC escape set
  with lowercase \u00xx; lone surrogates, undefined, functions, symbols,
  bigint, class instances, accessors, sparse arrays, cycles and excessive
  depth are refused. parseJson is a strict I-JSON parser (duplicate names,
  lone surrogates, non-double numbers, BOM refused; __proto__ kept as an
  own member).
- src/storage/audit/: AuditWriter, the one restricted writer (sole
  importer of restricted-writer.ts). event_digest = SHA-256(RFC 8785 of
  {schema, tenant_id, seq, type, actor, server_time, envelope_id,
  subject_digest, metadata, prev_digest}); appends run inside the caller's
  BEGIN IMMEDIATE transaction; redacted metadata limits; a cadence
  checkpoint every 100 events and a completion checkpoint per envelope.
  verifyChain recomputes digests and reports seq gaps, broken links, row
  edits, checkpoint mismatches, a truncated tail and a head mismatch
  against an externally recorded head; envelopeAuditRecords gives the
  contract AuditEventRecord shape.
- src/storage/retention/: strict tenant policy (NULL means retain;
  invalid fails closed); RetentionService with an injected clock disposes
  terminal envelopes past the window by writing a DisposalRecord and a
  retention.disposed audit event (subject_digest = RFC 8785 digest of the
  record) in one transaction, then removing unshared blobs via the blob
  store; resumes interrupted removals; never changes rows.
- tests/audit-chain/: AC-01..AC-05, RET-01 and RFC 8785 vector cases
  JCS-01..JCS-06 (section 3.2.4 and 3.2.3 examples, Appendix B numbers,
  escaping, refusals, strict parser, single-canonicalizer and
  single-writer boundary).

Verify: npm run verify -- audit-chain -> verify: audit-chain PASS exit=0
files=3 tests=12 pass=12 fail=0 skip=0 todo=0 cases=5/5 (no-secrets also
PASS)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes from the Phase 1 regression review (R1-R5):
- R1: typed declarations count as secret assignments (TypeScript
  `name: Type = '...'` including unions, generics and class fields; Python
  `name: str = "..."`, Final[...] / Optional[...]; Rust `&str`; Go typed var).
- R2: private-key PEM headers followed by key material in any layout:
  concatenated or joined string pieces, YAML line lists, one line separated
  by spaces, 16-character chunks.
- R3: the PEM and PKCS#12 rules run on all content, binary included, and on
  its UTF-16 decodings; UTF-16 text (with or without BOM) gets every rule.
- R4: base64-encoded PEM (all three byte alignments, wrapped or in JSON,
  and base64 of base64); base64 PKCS#12 widened to BER indefinite length
  (MI[A-T]) with every occurrence structurally checked.
- R5: --password=/-Dx.password= flags, URL userinfo passwords, upper-case
  base32 secrets, Go :=, .env-*/.env_*/*.env names, __fixtures__/,
  Fixtures/ and other fixture directory spellings; no longer flags shell
  command substitution ($(...), backticks, $VAR) or ternary branches.
- Type annotations parse unambiguously (no catastrophic backtracking).

Seven new runtime-generated test cases (NS-01 x2, NS-02, NS-04, NS-05,
NS-06 x2); each fails on the previous scanner.

verify: no-secrets PASS exit=0 files=1 tests=17 pass=17 fail=0 skip=0 todo=0 cases=7/7

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit a9b3775c358a85f9c8f63e87327014a5a232d8d5)
Fixes from the Phase 1 regression review (R6, R7, R8, R12):
- R6: a license text is any file whose name contains licence/license/
  notice/copying/copyright/third-party/thirdparty (source-code files
  excepted) and any file under licenses/ or licences/. Beyond one root
  LICENSE* (or COPYING*) and one root NOTICE*, each is an extra license
  file that fails a shipped package (bundle .LICENSE sidecars,
  ThirdPartyNotices.txt, licenses/OFL.txt, fonts/COPYRIGHT ...).
- R7: a multi-entry legacy `licenses` array is read as AND, never OR; an
  unreadable entry is unknown; `license` plus `licenses` is held to both.
- R8: any symbolic link (or non-regular file) in dist/, or dist itself as a
  link, fails the gate (dist-symlink); package and dist read errors stop
  the run with exit 2 instead of being skipped; a symlink inside a shipped
  package fails (package-symlink).
- R12: the SBOM carries the run's final gate value (NOTICE check included),
  the same as inventory.json; the SBOM serial covers a digest of every
  classification, license-file split and finding; a dual LICENSE-MIT +
  LICENSE-APACHE package passes when it declares exactly MIT and
  Apache-2.0 (OR or AND); a recognisable declared/text mismatch fails
  (license-text-mismatch).
- docs/qualification.md: gate description updated to match; the sidecar
  paragraph now states the rule matches them. Platform handling and
  POLICY-PENDING wording are unchanged.

Six new runtime-generated tests (LI-05, LI-06 x2, LI-07, LI-10, and the
dist/ symlink case); each fails on the previous tool. NOTICE unchanged.

verify: license-inventory PASS exit=0 files=1 tests=21 pass=21 fail=0 skip=0 todo=0 cases=10/10

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit e97f2f75ccd3a59e8d5c5eda295cce2ffa3b4d61)
Fixes from the Phase 1 regression review (R9, R10, R11, and the dev-bytes
half of R8):
- R9: the "dev bytes not in distributable" check now examines every dist/
  file as raw bytes and as what it decodes to (base64/base64url runs and
  data: URIs, gzip members anywhere with trailing data tolerated, .br as
  brotli; up to three levels), reporting embedded-bytes with the decoding
  path, and matches normalized 64-character chunk fingerprints of dev text
  files (comments and whitespace removed; license texts and idioms shared
  by three or more dev packages excluded) as embedded-chunks.
- R8: a symbolic link in dist/ is a finding (dist-symlink) and is never
  followed; read errors throw instead of being skipped.
- R11: QL-04 resolves the browsers path exactly as the frozen runner's
  chromium probe does (PLAYWRIGHT_BROWSERS_PATH=0 ->
  <playwright-core>/.local-browsers; empty -> default cache), pins the
  runner's expression by its exact text and cross-checks Playwright's own
  resolution for each setting.
- R10: pin kept (playwright 1.61.1 <-> chromium-1228 at the effective path);
  QL-04 computes the effective path instead of assuming /ms-playwright.
- docs/qualification.md: states exactly what QL-03 proves and does not,
  the forward requirement that the T035 build emit an input-provenance
  manifest (its check needs a tasks.md amendment), the browsers-path rules,
  and that the task line's chromium-1243/1234 note is superseded pending
  the orchestrator's tasks.md amendment. Platform wording unchanged.

Four new QL-03 tests (decodings, normalized chunks, dist symlink) and one
new QL-04 test; the QL-03 tests fail on the previous check.
package.json and package-lock.json are unchanged.

verify: qualification PASS exit=0 files=1 tests=10 pass=10 fail=0 skip=0 todo=0 cases=5/5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4556b0190d60d60c1aa5f66ee50e542322796c80)
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb0c4e009d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/storage/retention/service.ts Outdated
Comment on lines +104 to +108
const rows = [
...store.list('document_revisions', { blob_ref: ref }),
...ARTIFACT_REF_COLUMNS.flatMap((column) => store.list('final_artifacts', { [column]: ref })),
];
return rows.some((row) => !excluded.has(String(row['envelope_id'])));

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 Badge Preserve retained artifacts when excluding disposed envelopes

With scope: 'documents', a DisposalRecord does not mean the envelope's final artifacts may be deleted, but this predicate excludes their references anyway. If a completed envelope's final PDF is uploaded as another envelope's source document, disposing the first envelope and subsequently the second deletes that PDF despite the documents-only policy. I reproduced this with the storage fixtures: the first envelope's final-artifact row remained, but its PDF changed from ok to missing. Keep references to retained artifacts protective even when their envelope already has a DisposalRecord.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 173de1f on this branch (T029; cherry-picked from c35f18a): documents-scope disposal keeps blobs that a retained final artifact still references, and disposal filters by kind. Test RET-04 (audit-chain mode) covers it. All 13 verify modes pass at 0bdfb83.

Comment thread src/storage/retention/service.ts Outdated
Comment on lines +139 to +142
const candidates = store
.list('envelopes', { state: { op: 'in', values: [...TERMINAL_STATES] }, updated_at: { op: '<=', value: cutoff } }, { orderBy: [['id', 'asc']] })
.map((row) => String(row['id']))
.filter((id) => !disposed.has(id));

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 Badge Page eligible envelopes before filtering disposed entries

For a tenant with more than 10,000 eligible terminal envelopes, TenantStore.list() applies its default 10,000-row limit before this filter removes already-disposed entries. Because disposed envelopes remain unchanged, every subsequent run retrieves the same first page and never reaches the remaining envelopes. I reproduced 10,001 eligible envelopes producing 10,000 disposals on the first run and zero on the second, leaving one permanently unprocessed. Page through the eligible envelopes, and load disposal records without the corresponding first-page truncation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 173de1f (T029; cherry-picked from c35f18a) with the T003 keyset iterator in 4762a08 (cherry-picked from cb3af14): eligible envelopes are paged in full before disposed entries are filtered, so nothing is cut off at 10,000. Test RET-05 (audit-chain mode) covers it. All 13 verify modes pass at 0bdfb83.

Comment thread src/storage/audit/verify.ts Outdated
Comment on lines +91 to +92
const checkpoints = db.forTenant(tenantId).list('audit_checkpoints', {}, { orderBy: [['seq', 'asc']] });
for (const checkpoint of checkpoints) {

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 Badge Verify checkpoints beyond the first 10,000 rows

Once a tenant has more than 10,000 checkpoints, this call silently truncates them at TenantStore.list()'s default limit, so later checkpoints cannot detect a truncated chain or mismatched digest. I reproduced a valid chain with more than 10,000 checkpoints, deleted its final event while retaining that event's completion checkpoint, and received ok: true with no problems. Paginate all checkpoints, as eventRows() already does for events, using a cursor that also handles multiple checkpoints at the same sequence.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 173de1f (T029; cherry-picked from c35f18a): checkpoint verification iterates every row, not only the first 10,000. Test AC-06 (audit-chain mode) covers it. All 13 verify modes pass at 0bdfb83.

Brett Heap and others added 3 commits November 20, 2026 01:43
… and re-check every removal in its own transaction

The single reference-protection predicate (ReferenceProtection in
src/storage/retention/service.ts) gains FinalizationAttemptBlob records: given
the instant to judge attempts at (ProtectionOptions.attempts, which
BlobDisposer always passes), referenced() keeps a recorded ref unless its
attempt is collectable by data-model.md's rule, and the published attempt's
records protect exactly as its final artifact does. protects(), and so
backup's required-blob set, is unchanged. Every blob removal, after a
disposal's commit and in resume(), re-checks protection and removes the blob
inside one BEGIN IMMEDIATE transaction. A retention disposal with scope all
also proposes every ref the envelope's published attempt recorded, read
through jobs.ts, the composed PDF included; the predicate re-checks each (row
ATTEMPT-ALL). RET-09 shows a live attempt's re-written blob surviving orphan
collection, retention and resume(), the published attempt's records kept by
orphan collection and scope documents, and given up, composed PDF included,
by scope all. A-010 requests #59 (7) and #75 (2), (4).

verify: audit-chain PASS exit=0 files=4 tests=26 pass=26 fail=0 skip=0 todo=0 cases=5/5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… in flight on stop, and report run errors

Corrects T038 under A-010 requests #80 and #81, as one commit on 7a11d08.
1d824cf and 7a11d08 are kept unchanged as evidence.

RETRY-BOUND (request #80 (1)): an operator retry writes the job and its
envelope.finalization_retried event only on an actual transition: from
failed, at the attempt limit (the raise), or from retryable with a later
retry_at brought forward. A retry that finds the job retryable and due is
an accepted no-op: 202 with the envelope as it stands, the answer recorded
under its Idempotency-Key for replay, no job write and no audit event, all
in the retry's one transaction. The 202, the replay, the raise, the 100
ceiling and the refusals are unchanged. FEN-03 (extended) shows one
retried event per attempt for the probe's three sequences and at most
3N + 2 finalization events for N attempts.

FEN03-ROUTES (request #80 (2)): FEN-03's handler test no longer reads
ROUTES; it keeps the FINALIZATION_HANDLERS and withFinalizationHandlers
checks. routes.ts is untouched.

RUNNER-STOP (request #80 (3)): FinalizationRunner.stop() returns a promise,
starts no further run or attempt, aborts an attempt in flight through the
lease keeper's abort path (LeaseKeeper.abort(), cause stopped), so the
verify worker is terminated and the seal child killed, and resolves once
the attempt has unwound. The aborted attempt writes nothing more, records
no failure and is reclaimed at its lease expiry. FEN-01 (extended).

RUN-ERRORS (request #81 (7)): an optional onError receives a rejected
scheduled run and the loop carries on; an onError that throws is
contained, and no tick follows stop(). FEN-01 (extended).

F-1..F-3 (tests only): FEN-09 repeats the artifact key under another
envelope and takes over the artifact's rowid; FEN-05 reclaims at exactly
lease_expires_at; FEN-08 reaches publish step 3's checkpoint refusal,
directly and through the runner.

verify: completion PASS exit=0 files=10 tests=37 pass=37 fail=0 skip=0 todo=0 cases=3/3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…etry's instant fall behind the job's last write

RETRY-BOUND's instant (A-010 request #82), one commit on 73d6aba; 1d824cf,
7a11d08 and 73d6aba are kept unchanged as evidence.

The backward-clock rule: retryFinalization reads its clock first inside its
BEGIN IMMEDIATE transaction, and retryJob's transition test and every job
write it makes use at = max(clock, updated_at), the later of the clock and
the job's last write, compared as 0004's fixed-format ISO strings (a stored
updated_at in any other form is refused). A transition writes retry_at =
updated_at = at, so a later retry whose clock stepped back, was read stale
or runs skewed on another connection finds the job already due and writes
nothing: at most one envelope.finalization_retried per attempt, whatever the
clock does, and no job instant moves backwards. The idempotency record's
instants keep the clock reading, taken inside the transaction; the 202, the
replay, the raise, the ceiling, the refusals and the idempotency record are
unchanged. No schema change.

FEN-03 (extended): a retry behind the job's last write, from failed and from
retryable, writes one retried event and leaves the job row and the audit
chain byte-identical, and a first retry behind the last write writes that
instant; N2's regression: a retry exactly at retry_at is a no-op; two
connections, a retry committed at tB and another reading earlier, write one
event in all, every clock call is observed inside its transaction, and a
third connection cannot commit during a clock reading (a lock barrier
bounded by a 100 ms busy timeout).

verify: completion PASS exit=0 files=10 tests=40 pass=40 fail=0 skip=0 todo=0 cases=3/3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Brett Heap and others added 2 commits November 20, 2026 04:55
…caps

Row T016-TESTS (request #76), T016's test-only commit; tests/artifacts/ only.

PK-02 gains one row per builder refusal that had no test, each breaking a single link and
repairing every dependent digest so only the check under test can refuse, and asserting
the exact code and message:
- package.ts:444, the field manifest names another envelope (1 row);
- :445, the field manifest binds another document (1 row);
- :476, approvals out of ordinal order (2 rows: one approval, two swapped);
- :479, an approval that does not chain to the prior one (3 rows);
- :485, a consent text no approval names (1 row);
- :613, a tenant-chain prev_digest on seq 1, or missing on a later event (2 rows).

A two-approval package builds, with the chain, the document, field-manifest and consent
bindings over both approvals, the evidence digest and a contract ApprovalManifest; two
approvals with their own consent texts build too.

F4: each list cap the builder enforces is built at its owner's export and refused one
above, every cap imported from its owner: T007 MAX_FIELDS and MAX_PAGES, T010
MAX_FIELD_VALUES (field and date values), T008 ENVELOPE_MAX_RECIPIENTS (approvals and
consent texts) and MAX_CONSENT_TEXT_LENGTH.

chainWorld() now closes and removes its scratch database before rethrowing a failed seed,
so a failed before hook leaves no temporary directory (request #76's footprint note).

verify: artifacts PASS exit=0 files=3 tests=19 pass=19 fail=0 skip=0 todo=0 cases=5/5
Mutants on a scratch clone: 14 of 14 killed, among them the recheck's T6 (:479) and T7 (:445),
one per refusal, and the cap mutants, including an owner raising MAX_FIELDS.
Also: typecheck exit 0; no-secrets 29/29 PASS; targeted UB-06 1/1, JCS-06..08 3/3, DB-23 1/1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves D's recheck finding N1, confirmed at runtime: with package.ts:478 (an approval's
manifest_digest must name the manifest's field manifest) deleted, all 19 artifacts tests
still passed. PK-02 requires that each broken link the builder can see is refused, and the
check runs per approval, so it is now tested at both positions.

PK-02 gains two rows in its links test, each asserting the exact code and message:
- one approval whose manifest_digest names another field manifest: cross-link,
  "approval-manifest.approvals[0] binds another field manifest";
- a two-approval input whose second approval does: cross-link,
  "approval-manifest.approvals[1] binds another field manifest".
In both, a new rechained() helper recomputes each approval digest and relinks the chain,
and the evidence digest is recomputed, so only :478 can refuse.

verify: artifacts PASS exit=0 files=3 tests=19 pass=19 fail=0 skip=0 todo=0 cases=5/5
Mutants on a scratch clone, both killed: :478 deleted (the first-approval row), and :478
guarded to the first approval (only the second-approval row).
Also: typecheck exit 0; no-secrets 29/29 PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

…nd a flag-gated fault hook

Adds the test-only fault hook and the recovery suite for T038's runner,
without changing T038's behaviour (request #79 (3)).

- src/domain/finalization/fault-hook.ts: faultPoint(phase) holds only when
  the process was started with --opensig-test-fault-hook=<phase>:<FIFO>,
  by a blocking read of that owner-only FIFO, and never kills its own
  process; without the flag every call returns at once (REC-01). The calls
  sit at T038's marked hook lines: in src/jobs/finalize.ts after the grant
  (reserve), before the anchor (compose), at the starts of seal and verify,
  before the sealed and evidence records (store PDF, store evidence) and
  after the publish commit (outbox); in src/domain/finalization/publish.ts
  before COMMIT (publish). Nothing else in src/ changes.
- tests/recovery/: SC003-01..SC003-08 (a SIGKILL at each phase),
  SC003-09..SC003-16 (a stale-lease barrier at each phase) and
  SC003-17..SC003-20 (void, decline, expiry and an operator retry against a
  running finalization). Every runner is its own OS process on one fixed
  instant, through T038's test entry with fake compose, seal, verify and
  package steps only; I1..I10 hold after each case.
- Request #79's rulings: recovery is two runner children (B reclaims at
  the strict lease expiry, C takes the further attempt at the retry_at B
  wrote; none where B finds the job succeeded); the child entry is
  tests/recovery/support/runner-child.mjs; the only src/ is the hook and
  its calls; tests/completion/support/world.mjs is imported read-only;
  SC003-17's void and SC003-18's decline assert 409 state_conflict; the
  children's timers never fire.
- Extra case IDs, never required: REC-01 (the hook inert without the flag,
  with a static check that it reads only that flag), REC-02 (the attempt
  limit; with request #80 (1) and request #82, a second retry before the
  next attempt answers 202 and writes neither the job nor an audit event)
  and REC-03 (row RUNSTOP-TESTS, request #82 (4): a child stops the runner
  during a fake compose; the attempt ends lost with nothing recorded after
  the held check, no second envelope is claimed, and a second tenant is
  neither reclaimed nor claimed).

Verify: verify: recovery PASS exit=0 files=5 tests=23 pass=23 fail=0 skip=0 todo=0 cases=20/20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Brett Heap and others added 2 commits November 20, 2026 14:01
…nchor

FV-DIGEST (request #85, spec 5dac677): readSealRecords now recomputes
T010's exported fieldValuesDigest over each approval's stored
field_values and the date values derived from its own server_time,
right after the approval_digest comparison, in the same loop. A
mismatch fails the attempt before the seal anchor with the
non-retryable StepFailure manifest_invalid.field-values-digest. Every
existing refusal keeps its code, and valid data gives the same bytes.
No T010 file changes; its export is only imported.

Regression (tests/completion/, FEN-07 extended):
- R0: one and two recipients with a date field publish while the
  runner clock is a UTC day past server_time;
- R1-R3: a forged field_values_digest under a consistent
  approval_digest, at ordinal 1 of 1, 1 of 2 and 2 of 2, fails after
  one attempt with one envelope.finalization_failed, no seal anchor,
  no compose call, no attempt record, the envelope still finalizing;
- R4-R5: the approval-digest refusal at ordinals 1 and 2.
The two-recipient seed is a new opt-in helper
(tests/completion/support/sealable.mjs); seedSealable is unchanged.

Mutants MV1-MV9 killed: the comparison deleted (R1), made against
itself (R1), the recompute without date_values (R0), the runner clock
for the date (R0), the first approval only (R3), the check after
compose (R1), the refusal retryable (R1), a wrong reason (R1), and the
approval-digest comparison deleted (R4).

verify: completion PASS exit=0 files=10 tests=43 pass=43 fail=0 skip=0 todo=0 cases=3/3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LEASE-TOKEN-TEST (request #86, spec c8c3f8f; FEN-05 extended): after
the old lease expires and is reclaimed, the job is leased to the same
owner under the next fencing token. The stale holder's
recordAttemptBlob returns false, and writeSealAnchor and
writeCompletionCheckpoint return null before any anchor or checkpoint
exists; the job, the audit chain (its count and head), the attempt
records and the checkpoints are unchanged. The same owner's current
attempt then records and anchors, so the refusal is the token's.
Test only.

Mutants killed by the extended FEN-05: M09 (leaseHeld ignoring the
attempt token), and the lease check removed from writeSealAnchor,
from writeCompletionCheckpoint and from recordAttemptBlob.

verify: completion PASS exit=0 files=10 tests=44 pass=44 fail=0 skip=0 todo=0 cases=3/3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Brett Heap and others added 2 commits November 20, 2026 15:29
…er, and refuse the fault-hook flag at startup

Row ARTIFACT-ROUTES, the T031 US2 composition slot:

- ROUTES installs T016's ARTIFACT_HANDLERS and T038's FINALIZATION_HANDLERS
  through withArtifactHandlers and withFinalizationHandlers. The composed
  server installs T016's ArtifactApi and T038's FinalizationRetryApi in both
  listeners' locals, with one shared AuditWriter.
- The composition builds T038's FinalizationRunner from exactly the values
  startup validated, starts it once both listeners are bound, wires its
  onError to a bounded finalization_run_failed warning, and awaits its stop()
  at shutdown right after the listeners close (SEC-16 extended).
- Request #81: src/server/finalization.ts checks OPENSIG_SEAL_KEY_FILE,
  OPENSIG_SEAL_CERT_FILE and OPENSIG_TRUST_ANCHORS_FILE before anything is
  composed. The seal pair is set together or not at all; the key file's
  custody is checked (KEY-02, no symbolic link, a regular owner-only file of
  bounded size) and its bytes are never read; the certificate file holds
  exactly one PEM RSA-3072 certificate; a set anchors file holds 1 to 32 PEM
  certificates that T014 accepts. Without the pair no runner is composed and
  the server says so (finalization_not_configured).
- Request #86, SEC-12 extended (its fault-flag case): the first startup check
  refuses any command-line argument equal to T015's FAULT_HOOK_FLAG or
  starting with it and "=", well-formed or not, naming the flag and the rule,
  never the value. Nothing is composed, no listener binds, the runner never
  starts and the entrypoint exits 1. The constant is imported read-only; no
  T015 file changes.
- SEC-04 and SEC-05 are amended without weakening: no T016 or T038 route is
  left null, the 501 check moves to an operation that is still unwired, the
  artifact and retry routes fail closed (500) without their locals, sit
  behind the origin allowlist and answer 404 through the relay with no audit
  event. SEC-07's retry shows the allowed admin reaching T038's handler.
- SC002-26's world (tests/api/envelopes/support.mjs) gains only the artifact
  and retry APIs in the app's locals (+6/-0), as row ARTIFACT-ROUTES admits.
- Row T031RACE-TESTS rides here: the hold-marker assertion, a SIGINT case
  and a start-failure case with a signal sent during it.

verify: server PASS exit=0 files=13 tests=54 pass=54 fail=0 skip=0 todo=0 cases=6/6

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Row N1 of the fresh recheck of the T031 composition slot (request #81: the
finalization runner starts once, after both listeners bind).

SEC-12's runner case now starts the composed server with the relay socket
set, records every server whose listen() is called during the start and,
when the runner's start() is called, whether each of them is listening. It
asserts two listeners, both listening, so a runner started before the TCP
bind, or between the TCP and the relay bind, fails it. Only the test file
changes, and every other assertion keeps its meaning.

Mutants, on scratch copies: M-R1 (the runner's start, with its
not-configured branch, moved before the TCP listen) is killed with
"listening []"; the runner's start moved between the TCP and the relay bind
is killed with "listening [true]".

N2 (M-R3, the composed runner given `anchors: []`) is caught by a
separately identified extra control in T017, through the composed runner
configured with the matching anchor, by the orchestrator's ruling recorded
in request #88.

verify: server PASS exit=0 files=13 tests=54 pass=54 fail=0 skip=0 todo=0 cases=6/6

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Brett Heap and others added 2 commits November 20, 2026 18:58
Exercise ten local synthetic flows and SC005-01 and SC005-02 through normal
composed entry points, with the independent oracle and the #78 bounds.
Record indicative-local timing, exact browser document bodies, package
contracts, tamper controls and the composed runner matching-anchor proof.

Keep the historical cleanup-counter and CDP transport corrections explicit,
preserve prior failed candidates and the UNCONFIRMED checkbox cause, and
reserve M-R3 for the fresh independent recheck.

verify: us2-local PASS exit=0 files=4 tests=16 pass=16 fail=0 skip=0 todo=0 cases=12/12

Co-Authored-By: Codex GPT-6.1 Sol <noreply@openai.com>
Copy the random fixture blob and complement byte 100, then assert equal
length and changed content before writing. Label all three OR-07 rejection
sites without changing their predicates or the no-directory guarantee.

Apply the exact test-only patch bound by A-010 request #91. Preserve the
original acceptance failure; its exact failing site remains UNCONFIRMED.
No writer runtime or tests were invoked for this correction. Full paired
acceptance and the fresh recheck remain separate gates.

Co-Authored-By: Codex GPT-6.1 Sol <noreply@openai.com>
@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b35c18ced0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/verifier/trust.ts
Comment on lines +119 to +120
function issuedBy(child: X509Certificate, issuer: X509Certificate, at: Date): boolean {
return issuer.ca && validAt(issuer, at) && child.checkIssued(issuer) && child.verify(issuer.publicKey);

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 Badge Enforce certificate path-length constraints before declaring trust

When an embedded intermediate CA has basicConstraints: CA:true, pathLenConstraint:0, this issuer check still permits another intermediate beneath it: issuer.ca, checkIssued() and signature verification do not enforce the path-length constraint. I reproduced a root → constrained intermediate → subordinate CA → signer chain for which verifyPdf() returns integrity: 'valid' and trust: 'trusted'. This lets a CA certificate establish trust beyond the delegation permitted by the configured anchor's chain. Track and enforce path-length constraints across the candidate path before returning anchor-chain.

Useful? React with 👍 / 👎.

@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: ccd6ff10a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@brettheap

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 97a687eace

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant