@warpgogol/forge 9.5.0 → 9.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +30 -0
- package/README.uk.md +30 -0
- package/bin/cli.ts +19 -50
- package/dist/bin/cli.js +18 -43
- package/dist/bin/cli.js.map +1 -1
- package/dist/os/codebase/codebase.module.d.ts +3 -0
- package/dist/os/codebase/codebase.module.d.ts.map +1 -0
- package/dist/os/codebase/codebase.module.js +53 -0
- package/dist/os/codebase/codebase.module.js.map +1 -0
- package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts +15 -0
- package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts.map +1 -0
- package/dist/os/codebase/handlers/codebase-measure-symbols.js +97 -0
- package/dist/os/codebase/handlers/codebase-measure-symbols.js.map +1 -0
- package/dist/os/codebase/handlers/codebase-measure.d.ts +22 -0
- package/dist/os/codebase/handlers/codebase-measure.d.ts.map +1 -0
- package/dist/os/codebase/handlers/codebase-measure.js +435 -0
- package/dist/os/codebase/handlers/codebase-measure.js.map +1 -0
- package/dist/os/codebase/index.d.ts +4 -0
- package/dist/os/codebase/index.d.ts.map +1 -0
- package/dist/os/codebase/index.js +13 -0
- package/dist/os/codebase/index.js.map +1 -0
- package/dist/os/codebase/types.d.ts +35 -0
- package/dist/os/codebase/types.d.ts.map +1 -0
- package/dist/os/codebase/types.js +17 -0
- package/dist/os/codebase/types.js.map +1 -0
- package/dist/os/core/handlers/package-health.d.ts +6 -4
- package/dist/os/core/handlers/package-health.d.ts.map +1 -1
- package/dist/os/core/handlers/package-health.js +15 -20
- package/dist/os/core/handlers/package-health.js.map +1 -1
- package/dist/os/correctness/anchors.d.ts +24 -0
- package/dist/os/correctness/anchors.d.ts.map +1 -0
- package/dist/os/correctness/anchors.js +156 -0
- package/dist/os/correctness/anchors.js.map +1 -0
- package/dist/os/correctness/audit/bindings-verify-substance.d.ts +7 -0
- package/dist/os/correctness/audit/bindings-verify-substance.d.ts.map +1 -0
- package/dist/os/correctness/audit/bindings-verify-substance.js +145 -0
- package/dist/os/correctness/audit/bindings-verify-substance.js.map +1 -0
- package/dist/os/correctness/audit/differential.d.ts +7 -0
- package/dist/os/correctness/audit/differential.d.ts.map +1 -0
- package/dist/os/correctness/audit/differential.js +105 -0
- package/dist/os/correctness/audit/differential.js.map +1 -0
- package/dist/os/correctness/audit/ledger-orphans.d.ts +6 -0
- package/dist/os/correctness/audit/ledger-orphans.d.ts.map +1 -0
- package/dist/os/correctness/audit/ledger-orphans.js +71 -0
- package/dist/os/correctness/audit/ledger-orphans.js.map +1 -0
- package/dist/os/correctness/audit/ledger.d.ts +29 -0
- package/dist/os/correctness/audit/ledger.d.ts.map +1 -0
- package/dist/os/correctness/audit/ledger.js +72 -0
- package/dist/os/correctness/audit/ledger.js.map +1 -0
- package/dist/os/correctness/audit/run.d.ts +27 -0
- package/dist/os/correctness/audit/run.d.ts.map +1 -0
- package/dist/os/correctness/audit/run.js +184 -0
- package/dist/os/correctness/audit/run.js.map +1 -0
- package/dist/os/correctness/audit/schema-db.d.ts +32 -0
- package/dist/os/correctness/audit/schema-db.d.ts.map +1 -0
- package/dist/os/correctness/audit/schema-db.js +166 -0
- package/dist/os/correctness/audit/schema-db.js.map +1 -0
- package/dist/os/correctness/audit/snapshot.d.ts +34 -0
- package/dist/os/correctness/audit/snapshot.d.ts.map +1 -0
- package/dist/os/correctness/audit/snapshot.js +190 -0
- package/dist/os/correctness/audit/snapshot.js.map +1 -0
- package/dist/os/correctness/audit/sql-scanner.d.ts +28 -0
- package/dist/os/correctness/audit/sql-scanner.d.ts.map +1 -0
- package/dist/os/correctness/audit/sql-scanner.js +279 -0
- package/dist/os/correctness/audit/sql-scanner.js.map +1 -0
- package/dist/os/correctness/audit/sql-schema-conform.d.ts +17 -0
- package/dist/os/correctness/audit/sql-schema-conform.d.ts.map +1 -0
- package/dist/os/correctness/audit/sql-schema-conform.js +163 -0
- package/dist/os/correctness/audit/sql-schema-conform.js.map +1 -0
- package/dist/os/correctness/audit/state-transitions-coverage.d.ts +19 -0
- package/dist/os/correctness/audit/state-transitions-coverage.d.ts.map +1 -0
- package/dist/os/correctness/audit/state-transitions-coverage.js +263 -0
- package/dist/os/correctness/audit/state-transitions-coverage.js.map +1 -0
- package/dist/os/correctness/audit/tests/git-fixture.d.ts +15 -0
- package/dist/os/correctness/audit/tests/git-fixture.d.ts.map +1 -0
- package/dist/os/correctness/audit/tests/git-fixture.js +85 -0
- package/dist/os/correctness/audit/tests/git-fixture.js.map +1 -0
- package/dist/os/correctness/audit/types.d.ts +58 -0
- package/dist/os/correctness/audit/types.d.ts.map +1 -0
- package/dist/os/correctness/audit/types.js +34 -0
- package/dist/os/correctness/audit/types.js.map +1 -0
- package/dist/os/correctness/correctness.module.d.ts +3 -0
- package/dist/os/correctness/correctness.module.d.ts.map +1 -0
- package/dist/os/correctness/correctness.module.js +173 -0
- package/dist/os/correctness/correctness.module.js.map +1 -0
- package/dist/os/correctness/gate/frozen.d.ts +52 -0
- package/dist/os/correctness/gate/frozen.d.ts.map +1 -0
- package/dist/os/correctness/gate/frozen.js +322 -0
- package/dist/os/correctness/gate/frozen.js.map +1 -0
- package/dist/os/correctness/gate/origin.d.ts +28 -0
- package/dist/os/correctness/gate/origin.d.ts.map +1 -0
- package/dist/os/correctness/gate/origin.js +139 -0
- package/dist/os/correctness/gate/origin.js.map +1 -0
- package/dist/os/correctness/gate/repo.d.ts +25 -0
- package/dist/os/correctness/gate/repo.d.ts.map +1 -0
- package/dist/os/correctness/gate/repo.js +88 -0
- package/dist/os/correctness/gate/repo.js.map +1 -0
- package/dist/os/correctness/gate/run.d.ts +22 -0
- package/dist/os/correctness/gate/run.d.ts.map +1 -0
- package/dist/os/correctness/gate/run.js +430 -0
- package/dist/os/correctness/gate/run.js.map +1 -0
- package/dist/os/correctness/gate/runner.d.ts +18 -0
- package/dist/os/correctness/gate/runner.d.ts.map +1 -0
- package/dist/os/correctness/gate/runner.js +123 -0
- package/dist/os/correctness/gate/runner.js.map +1 -0
- package/dist/os/correctness/gate/tests/gate-fixture.d.ts +36 -0
- package/dist/os/correctness/gate/tests/gate-fixture.d.ts.map +1 -0
- package/dist/os/correctness/gate/tests/gate-fixture.js +153 -0
- package/dist/os/correctness/gate/tests/gate-fixture.js.map +1 -0
- package/dist/os/correctness/gate/types.d.ts +102 -0
- package/dist/os/correctness/gate/types.d.ts.map +1 -0
- package/dist/os/correctness/gate/types.js +64 -0
- package/dist/os/correctness/gate/types.js.map +1 -0
- package/dist/os/correctness/handlers/audit.d.ts +4 -0
- package/dist/os/correctness/handlers/audit.d.ts.map +1 -0
- package/dist/os/correctness/handlers/audit.js +95 -0
- package/dist/os/correctness/handlers/audit.js.map +1 -0
- package/dist/os/correctness/handlers/gate.d.ts +4 -0
- package/dist/os/correctness/handlers/gate.d.ts.map +1 -0
- package/dist/os/correctness/handlers/gate.js +62 -0
- package/dist/os/correctness/handlers/gate.js.map +1 -0
- package/dist/os/correctness/handlers/validate.d.ts +19 -0
- package/dist/os/correctness/handlers/validate.d.ts.map +1 -0
- package/dist/os/correctness/handlers/validate.js +367 -0
- package/dist/os/correctness/handlers/validate.js.map +1 -0
- package/dist/os/correctness/index.d.ts +8 -0
- package/dist/os/correctness/index.d.ts.map +1 -0
- package/dist/os/correctness/index.js +23 -0
- package/dist/os/correctness/index.js.map +1 -0
- package/dist/os/correctness/manifest-schema.d.ts +155 -0
- package/dist/os/correctness/manifest-schema.d.ts.map +1 -0
- package/dist/os/correctness/manifest-schema.js +110 -0
- package/dist/os/correctness/manifest-schema.js.map +1 -0
- package/dist/os/correctness/references.d.ts +22 -0
- package/dist/os/correctness/references.d.ts.map +1 -0
- package/dist/os/correctness/references.js +129 -0
- package/dist/os/correctness/references.js.map +1 -0
- package/dist/os/correctness/tests/fixture-workspace.d.ts +23 -0
- package/dist/os/correctness/tests/fixture-workspace.d.ts.map +1 -0
- package/dist/os/correctness/tests/fixture-workspace.js +104 -0
- package/dist/os/correctness/tests/fixture-workspace.js.map +1 -0
- package/dist/os/correctness/workspace.d.ts +32 -0
- package/dist/os/correctness/workspace.d.ts.map +1 -0
- package/dist/os/correctness/workspace.js +147 -0
- package/dist/os/correctness/workspace.js.map +1 -0
- package/dist/os/flow/correctness-step.d.ts +19 -0
- package/dist/os/flow/correctness-step.d.ts.map +1 -0
- package/dist/os/flow/correctness-step.js +133 -0
- package/dist/os/flow/correctness-step.js.map +1 -0
- package/dist/os/flow/digest.d.ts +18 -0
- package/dist/os/flow/digest.d.ts.map +1 -1
- package/dist/os/flow/digest.js +28 -1
- package/dist/os/flow/digest.js.map +1 -1
- package/dist/os/flow/flow.module.d.ts.map +1 -1
- package/dist/os/flow/flow.module.js +17 -3
- package/dist/os/flow/flow.module.js.map +1 -1
- package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-digest.js +11 -1
- package/dist/os/flow/handlers/flow-digest.js.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.d.ts +11 -0
- package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.js +90 -5
- package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
- package/dist/os/flow/post-rebase-regen.d.ts +33 -0
- package/dist/os/flow/post-rebase-regen.d.ts.map +1 -0
- package/dist/os/flow/post-rebase-regen.js +120 -0
- package/dist/os/flow/post-rebase-regen.js.map +1 -0
- package/dist/os/flow/preflight.d.ts.map +1 -1
- package/dist/os/flow/preflight.js +11 -15
- package/dist/os/flow/preflight.js.map +1 -1
- package/dist/os/flow/publish.d.ts.map +1 -1
- package/dist/os/flow/publish.js +23 -4
- package/dist/os/flow/publish.js.map +1 -1
- package/dist/os/flow/registry.d.ts +4 -4
- package/dist/os/flow/tests/helpers.d.ts +9 -1
- package/dist/os/flow/tests/helpers.d.ts.map +1 -1
- package/dist/os/flow/tests/helpers.js +36 -2
- package/dist/os/flow/tests/helpers.js.map +1 -1
- package/dist/os/friction/types.d.ts +2 -2
- package/dist/os/gate-run/status.d.ts +12 -0
- package/dist/os/gate-run/status.d.ts.map +1 -1
- package/dist/os/gate-run/status.js +24 -3
- package/dist/os/gate-run/status.js.map +1 -1
- package/dist/os/program/schemas.d.ts +3 -3
- package/dist/os/queue/types.d.ts +2 -2
- package/dist/os/rfc/handlers/implement-stamp-promotes.d.ts +8 -0
- package/dist/os/rfc/handlers/implement-stamp-promotes.d.ts.map +1 -0
- package/dist/os/rfc/handlers/implement-stamp-promotes.js +65 -0
- package/dist/os/rfc/handlers/implement-stamp-promotes.js.map +1 -0
- package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.js +15 -2
- package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.js +26 -5
- package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
- package/dist/os/rfc/rfc.module.d.ts.map +1 -1
- package/dist/os/rfc/rfc.module.js +18 -6
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/os/rfc/types.d.ts +12 -3
- package/dist/os/rfc/types.d.ts.map +1 -1
- package/dist/os/rfc/types.js +5 -2
- package/dist/os/rfc/types.js.map +1 -1
- package/dist/os/rfc/verify-workspace.d.ts +12 -0
- package/dist/os/rfc/verify-workspace.d.ts.map +1 -1
- package/dist/os/rfc/verify-workspace.js +155 -0
- package/dist/os/rfc/verify-workspace.js.map +1 -1
- package/dist/os/system/task-schemas.d.ts +1 -1
- package/dist/os/system/tests/helpers.d.ts.map +1 -1
- package/dist/os/system/tests/helpers.js +6 -1
- package/dist/os/system/tests/helpers.js.map +1 -1
- package/dist/os/werkstatt/handlers/schema.d.ts +1 -1
- package/dist/src/command-modules.d.ts +4 -0
- package/dist/src/command-modules.d.ts.map +1 -0
- package/dist/src/command-modules.js +42 -0
- package/dist/src/command-modules.js.map +1 -0
- package/dist/src/config/forge-config.d.ts +16 -1
- package/dist/src/config/forge-config.d.ts.map +1 -1
- package/dist/src/config/forge-config.js +27 -11
- package/dist/src/config/forge-config.js.map +1 -1
- package/dist/src/correctness/index.d.ts +32 -0
- package/dist/src/correctness/index.d.ts.map +1 -0
- package/dist/src/correctness/index.js +157 -0
- package/dist/src/correctness/index.js.map +1 -0
- package/dist/src/correctness/schema-hash.d.ts +15 -0
- package/dist/src/correctness/schema-hash.d.ts.map +1 -0
- package/dist/src/correctness/schema-hash.js +44 -0
- package/dist/src/correctness/schema-hash.js.map +1 -0
- package/dist/src/knowledge/schema.d.ts +1 -1
- package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
- package/dist/src/onboarding/agents-generate.js +20 -3
- package/dist/src/onboarding/agents-generate.js.map +1 -1
- package/dist/src/onboarding/create.d.ts +7 -0
- package/dist/src/onboarding/create.d.ts.map +1 -1
- package/dist/src/onboarding/create.js +62 -9
- package/dist/src/onboarding/create.js.map +1 -1
- package/docs/reference/correctness-audit.md +91 -0
- package/docs/reference/correctness-gate.md +102 -0
- package/docs/reference/correctness-manifest.md +142 -0
- package/docs/reference/forge-yaml.md +15 -0
- package/os/codebase/codebase.module.ts +57 -0
- package/os/codebase/handlers/codebase-measure-symbols.ts +131 -0
- package/os/codebase/handlers/codebase-measure.ts +503 -0
- package/os/codebase/index.ts +21 -0
- package/os/codebase/types.ts +55 -0
- package/os/core/handlers/package-health.test.ts +24 -2
- package/os/core/handlers/package-health.ts +16 -19
- package/os/correctness/anchors.ts +182 -0
- package/os/correctness/audit/bindings-verify-substance.test.ts +79 -0
- package/os/correctness/audit/bindings-verify-substance.ts +155 -0
- package/os/correctness/audit/differential.test.ts +113 -0
- package/os/correctness/audit/differential.ts +131 -0
- package/os/correctness/audit/ledger-orphans.test.ts +96 -0
- package/os/correctness/audit/ledger-orphans.ts +84 -0
- package/os/correctness/audit/ledger.test.ts +65 -0
- package/os/correctness/audit/ledger.ts +103 -0
- package/os/correctness/audit/run.ts +220 -0
- package/os/correctness/audit/schema-db.ts +208 -0
- package/os/correctness/audit/snapshot.ts +211 -0
- package/os/correctness/audit/sql-scanner.test.ts +84 -0
- package/os/correctness/audit/sql-scanner.ts +289 -0
- package/os/correctness/audit/sql-schema-conform.test.ts +170 -0
- package/os/correctness/audit/sql-schema-conform.ts +178 -0
- package/os/correctness/audit/state-transitions-coverage.test.ts +141 -0
- package/os/correctness/audit/state-transitions-coverage.ts +271 -0
- package/os/correctness/audit/tests/git-fixture.ts +98 -0
- package/os/correctness/audit/types.ts +91 -0
- package/os/correctness/correctness-capture.test.ts +107 -0
- package/os/correctness/correctness-chain.test.ts +232 -0
- package/os/correctness/correctness-coverage.test.ts +86 -0
- package/os/correctness/correctness-mode.test.ts +108 -0
- package/os/correctness/correctness-substrate.test.ts +64 -0
- package/os/correctness/correctness.module.ts +182 -0
- package/os/correctness/gate/anchor-events.test.ts +77 -0
- package/os/correctness/gate/freeze-coverage.test.ts +218 -0
- package/os/correctness/gate/freeze-diff.test.ts +110 -0
- package/os/correctness/gate/frozen.ts +399 -0
- package/os/correctness/gate/gate-mode.test.ts +76 -0
- package/os/correctness/gate/hardening.test.ts +175 -0
- package/os/correctness/gate/oracle-edit.test.ts +83 -0
- package/os/correctness/gate/oracle-origin.test.ts +142 -0
- package/os/correctness/gate/origin.ts +175 -0
- package/os/correctness/gate/repo.ts +102 -0
- package/os/correctness/gate/run.ts +547 -0
- package/os/correctness/gate/runner.ts +136 -0
- package/os/correctness/gate/substrate-attestation.test.ts +71 -0
- package/os/correctness/gate/tests/gate-fixture.ts +205 -0
- package/os/correctness/gate/tier-high.test.ts +92 -0
- package/os/correctness/gate/types.ts +144 -0
- package/os/correctness/handlers/audit.ts +107 -0
- package/os/correctness/handlers/gate.ts +75 -0
- package/os/correctness/handlers/validate.ts +514 -0
- package/os/correctness/index.ts +24 -0
- package/os/correctness/manifest-schema.ts +174 -0
- package/os/correctness/references.ts +143 -0
- package/os/correctness/tests/fixture-workspace.ts +119 -0
- package/os/correctness/workspace.ts +167 -0
- package/os/flow/correctness-step.ts +166 -0
- package/os/flow/digest.ts +40 -1
- package/os/flow/flow.module.ts +18 -3
- package/os/flow/handlers/flow-digest.ts +11 -1
- package/os/flow/handlers/flow-integrate.ts +117 -5
- package/os/flow/post-rebase-regen.ts +170 -0
- package/os/flow/preflight.ts +11 -19
- package/os/flow/publish.ts +23 -4
- package/os/flow/tests/flow-detachable.test.ts +31 -0
- package/os/flow/tests/flow-digest-correctness-trail.test.ts +55 -0
- package/os/flow/tests/flow-integrate-correctness-gate.test.ts +275 -0
- package/os/flow/tests/flow-integrate.post-rebase-regen.test.ts +234 -0
- package/os/flow/tests/flow-integrate.test.ts +10 -9
- package/os/flow/tests/helpers.ts +45 -24
- package/os/gate-run/status.ts +36 -3
- package/os/gate-run/tests/gate-run-status.test.ts +114 -0
- package/os/rfc/handlers/implement-stamp-promotes.test.ts +214 -0
- package/os/rfc/handlers/implement-stamp-promotes.ts +79 -0
- package/os/rfc/handlers/implement-stamp.ts +16 -2
- package/os/rfc/handlers/validate-rules.ts +43 -5
- package/os/rfc/rfc.module.ts +19 -6
- package/os/rfc/types.ts +16 -2
- package/os/rfc/verify-workspace-manifest.test.ts +55 -0
- package/os/rfc/verify-workspace.ts +167 -0
- package/os/system/tests/helpers.ts +6 -1
- package/package.json +41 -1
- package/profiles/typescript.yaml +16 -0
- package/skills/_shared/agent-operating-model.md +4 -0
- package/skills/fo/fo-idea-audit/SKILL.md +4 -0
- package/skills/fo/fo-idea-create-rfc/SKILL.md +6 -2
- package/skills/fo/fo-idea-implement/SKILL.md +8 -2
- package/skills/fo/fo-review/SKILL.md +16 -2
- package/src/command-modules.ts +62 -0
- package/src/config/forge-config.ts +37 -11
- package/src/correctness/index.ts +192 -0
- package/src/correctness/schema-hash.ts +59 -0
- package/src/onboarding/agents-generate.ts +20 -3
- package/src/onboarding/create.ts +59 -9
- package/src/tests/agents-generate-detach.test.ts +126 -0
- package/src/tests/codebase-measure-rfc-1581.test.ts +260 -0
- package/src/tests/command-modules.test.ts +34 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1580 review REVIEW-CODE-2026-11-13-04 regressions — rebinding an
|
|
4
|
+
oracle (the RFC-1571 AC-7 shape) is a weakening, a declared L3 without
|
|
5
|
+
captures never covers, a substrate raise is a weakening, a reworded or
|
|
6
|
+
duplicated anchor is caught, requirement origin needs an acceptance that
|
|
7
|
+
predates the base, and an oracle timeout is CORR-GATE-07.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>Not a contract source of truth — gate/run.ts owns behaviour.</item>
|
|
10
|
+
</non-goals>
|
|
11
|
+
</MODULE_CONTRACT>
|
|
12
|
+
<CHANGE_SUMMARY>
|
|
13
|
+
<item>RFC-1580: review regressions.</item>
|
|
14
|
+
<item>RFC-1580: close review REVIEW-CODE-2026-11-13-04 findings
|
|
15
|
+
|
|
16
|
+
F1 bootstrap degrade only on an exact unknown-command stderr line with no JSON; F2 review records count only from a verifier-trailer commit naming them; F3 any frozen substrate change or dropped capture is a weakening, declared L3 needs loaded captures; F4 requirement origin needs acceptance before --base; F5 anchor events only for L2+ runs; F6 proof oracles via proof.check only, non-self; F7 bundle naming; F8/F9 limitations; F10 every anchor copy; F11 base entry refs; F12 unreadable base manifest refuses; F13 dirty worktree warning; F14 source/statement diffs; F15 process-group kill; F16 run root cleanup; F20 review dir stripped, blob hashes. Regression tests for spoofing, plain-commit review, L3, requirement origin, rewording, timeout, formal tier, rebind, real-gate pass, accept-weakening. DEV-1..DEV-6 recorded in the RFC.</item>
|
|
17
|
+
</CHANGE_SUMMARY>
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
21
|
+
|
|
22
|
+
import { runCorrectnessGate } from "./run.ts";
|
|
23
|
+
import {
|
|
24
|
+
L1_ORACLE,
|
|
25
|
+
ORACLE_PATH,
|
|
26
|
+
makeGateFixture,
|
|
27
|
+
manifestYaml,
|
|
28
|
+
type GateFixture,
|
|
29
|
+
} from "./tests/gate-fixture.ts";
|
|
30
|
+
|
|
31
|
+
const fixtures: GateFixture[] = [];
|
|
32
|
+
afterEach(() => fixtures.splice(0).forEach((f) => f.cleanup()));
|
|
33
|
+
const fx = (o: Parameters<typeof makeGateFixture>[0] = {}) => {
|
|
34
|
+
const f = makeGateFixture(o);
|
|
35
|
+
fixtures.push(f);
|
|
36
|
+
return f;
|
|
37
|
+
};
|
|
38
|
+
const gate = async (f: GateFixture) => {
|
|
39
|
+
const out = await runCorrectnessGate(f.root, { base: f.base, bundleDir: `${f.root}/.bundles` });
|
|
40
|
+
if (!out.ok) throw new Error(out.usageError);
|
|
41
|
+
return out.result;
|
|
42
|
+
};
|
|
43
|
+
const msgs = (r: { violations: { rule: string; message: string }[] }, rule: string) =>
|
|
44
|
+
r.violations.filter((v) => v.rule === rule).map((v) => v.message);
|
|
45
|
+
const MARK = "@ai-" + "invariant";
|
|
46
|
+
|
|
47
|
+
describe("gate hardening", () => {
|
|
48
|
+
it("rebinding a frozen oracle to an easier test is refused as a weakening (RFC-1571 AC-7 shape)", async () => {
|
|
49
|
+
const f = fx();
|
|
50
|
+
f.write("test/easier.oracle.ts", "// always green\n");
|
|
51
|
+
f.write(
|
|
52
|
+
"docs/correctness.yaml",
|
|
53
|
+
manifestYaml({}).replace(`check: test:${ORACLE_PATH}`, "check: test:test/easier.oracle.ts"),
|
|
54
|
+
);
|
|
55
|
+
f.write(
|
|
56
|
+
"apps/api/src/dispatch.ts",
|
|
57
|
+
f.read("apps/api/src/dispatch.ts").replace(ORACLE_PATH, "test/easier.oracle.ts"),
|
|
58
|
+
);
|
|
59
|
+
f.commit("rebind the oracle");
|
|
60
|
+
const r = await gate(f);
|
|
61
|
+
expect(msgs(r, "CORR-GATE-02").some((m) => /lost \(or rebound\) oracle/.test(m))).toBe(true);
|
|
62
|
+
expect(r.status).toBe("fail");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("raising a frozen oracle's substrate is a weakening", async () => {
|
|
66
|
+
const f = fx();
|
|
67
|
+
f.write(
|
|
68
|
+
"docs/correctness.yaml",
|
|
69
|
+
manifestYaml({ substrate: "L1" }).replace("substrate: L1", "substrate: L3"),
|
|
70
|
+
);
|
|
71
|
+
f.commit("over-declare");
|
|
72
|
+
expect(
|
|
73
|
+
msgs(await gate(f), "CORR-GATE-02").some((m) => /substrate changed from L1 to L3/.test(m)),
|
|
74
|
+
).toBe(true);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("a declared L3 without captures never covers (counted as L0)", async () => {
|
|
78
|
+
// The base already declares L3 — no weakening involved, only the claim.
|
|
79
|
+
const g = fx({ oracle: "// asserts nothing on any handle\n" });
|
|
80
|
+
g.write("docs/correctness.yaml", manifestYaml({}).replace("substrate: L1", "substrate: L3"));
|
|
81
|
+
g.git(["add", "-A"]);
|
|
82
|
+
g.git(["commit", "-qm", "declare L3"]);
|
|
83
|
+
const out = await runCorrectnessGate(g.root, {
|
|
84
|
+
base: g.git(["rev-parse", "HEAD"]),
|
|
85
|
+
bundleDir: `${g.root}/.bundles`,
|
|
86
|
+
});
|
|
87
|
+
if (!out.ok) throw new Error(out.usageError);
|
|
88
|
+
expect(
|
|
89
|
+
msgs(out.result, "CORR-GATE-04").some((m) => /declares L3 without captures/.test(m)),
|
|
90
|
+
).toBe(true);
|
|
91
|
+
expect(out.result.violations.map((v) => v.rule)).toContain("CORR-GATE-08");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("a reworded anchor and a duplicate copy keeping the old text are both caught", async () => {
|
|
95
|
+
const f = fx();
|
|
96
|
+
const original = f.read("apps/api/src/dispatch.ts");
|
|
97
|
+
f.write(
|
|
98
|
+
"apps/api/src/dispatch.ts",
|
|
99
|
+
original.replace("exactly once", "at least once") +
|
|
100
|
+
`// ${MARK}[INV-dispatch-01]: dispatch moves an approved candidate to queued exactly once\n// (checked-by: test:${ORACLE_PATH})\n`,
|
|
101
|
+
);
|
|
102
|
+
f.commit("reword the anchor, keep a decoy copy");
|
|
103
|
+
expect(
|
|
104
|
+
msgs(await gate(f), "CORR-GATE-02").some((m) => /INV-dispatch-01 statement changed/.test(m)),
|
|
105
|
+
).toBe(true);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("requirement origin needs an RFC accepted before the integration base", async () => {
|
|
109
|
+
const rfc = (status: string) =>
|
|
110
|
+
`---\nid: RFC-0005\ntitle: "x"\nstatus: ${status}\n---\n\n# RFC-0005\n\n## Acceptance criteria\n\n- [ ] AC-3: THE dispatch SHALL queue (evidence: probe:AC-3)\n`;
|
|
111
|
+
const entry = ` - id: CM-lifecycle-01\n source: rfc-ac\n ref: RFC-0005/AC-3\n seam: data\n anchors: [INV-dispatch-01]\n oracles:\n - check: test:test/req.oracle.ts\n substrate: L1\n`;
|
|
112
|
+
const anchorWith = (f: GateFixture) =>
|
|
113
|
+
f.write(
|
|
114
|
+
"apps/api/src/dispatch.ts",
|
|
115
|
+
f
|
|
116
|
+
.read("apps/api/src/dispatch.ts")
|
|
117
|
+
.replace(
|
|
118
|
+
`(checked-by: test:${ORACLE_PATH})`,
|
|
119
|
+
`(checked-by: test:${ORACLE_PATH}, test:test/req.oracle.ts)`,
|
|
120
|
+
),
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
// Accepted on develop first, oracle written afterwards and unchanged since acceptance → requirement.
|
|
124
|
+
const early = fx();
|
|
125
|
+
early.write("docs/rfcs/rfc-0005-dispatch.md", rfc("draft"));
|
|
126
|
+
early.git(["add", "-A"]);
|
|
127
|
+
early.git(["commit", "-qm", "draft"]);
|
|
128
|
+
early.write("test/req.oracle.ts", L1_ORACLE);
|
|
129
|
+
early.write("docs/rfcs/rfc-0005-dispatch.md", rfc("accepted"));
|
|
130
|
+
early.git(["add", "-A"]);
|
|
131
|
+
early.git(["commit", "-qm", "accept with oracle"]);
|
|
132
|
+
const base = early.git(["rev-parse", "HEAD"]);
|
|
133
|
+
anchorWith(early);
|
|
134
|
+
early.write("docs/correctness.yaml", manifestYaml({}, entry));
|
|
135
|
+
early.commit("add the entry");
|
|
136
|
+
const ok = await runCorrectnessGate(early.root, { base, bundleDir: `${early.root}/.bundles` });
|
|
137
|
+
if (!ok.ok) throw new Error(ok.usageError);
|
|
138
|
+
expect(ok.result.violations.filter((v) => v.rule === "CORR-GATE-03")).toEqual([]);
|
|
139
|
+
|
|
140
|
+
// Accepted inside the session together with its test → self.
|
|
141
|
+
const late = fx();
|
|
142
|
+
late.write("test/req.oracle.ts", L1_ORACLE);
|
|
143
|
+
late.write("docs/rfcs/rfc-0005-dispatch.md", rfc("accepted"));
|
|
144
|
+
anchorWith(late);
|
|
145
|
+
late.write("docs/correctness.yaml", manifestYaml({}, entry));
|
|
146
|
+
late.commit("accept, test, and entry in one session");
|
|
147
|
+
expect(
|
|
148
|
+
(await gate(late)).violations.some(
|
|
149
|
+
(v) => v.rule === "CORR-GATE-03" && v.entry === "CM-lifecycle-01",
|
|
150
|
+
),
|
|
151
|
+
).toBe(true);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("an oracle that outlives its timeout is CORR-GATE-07 with the timeout class", async () => {
|
|
155
|
+
const f = fx({ oracle: "setTimeout(() => {}, 60000);\n" });
|
|
156
|
+
f.write(
|
|
157
|
+
"forge.yaml",
|
|
158
|
+
f
|
|
159
|
+
.read("forge.yaml")
|
|
160
|
+
.replace(" tier: standard\n", " tier: standard\n oracleTimeoutMs: 500\n"),
|
|
161
|
+
);
|
|
162
|
+
f.git(["add", "-A"]);
|
|
163
|
+
f.git(["commit", "-qm", "short timeout"]);
|
|
164
|
+
const out = await runCorrectnessGate(f.root, {
|
|
165
|
+
base: f.git(["rev-parse", "HEAD"]),
|
|
166
|
+
bundleDir: `${f.root}/.bundles`,
|
|
167
|
+
});
|
|
168
|
+
if (!out.ok) throw new Error(out.usageError);
|
|
169
|
+
expect(
|
|
170
|
+
msgs(out.result, "CORR-GATE-07").some((m) =>
|
|
171
|
+
/timed out after 500ms \(timeout class\)/.test(m),
|
|
172
|
+
),
|
|
173
|
+
).toBe(true);
|
|
174
|
+
}, 30_000);
|
|
175
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1580 AC-4: a frozen oracle file changed by a session commit without the verifier trailer pair is CORR-GATE-02; the same change in a verifier-trailer commit is not.</purpose>
|
|
4
|
+
<non-goals>
|
|
5
|
+
<item>Not a contract source of truth — gate/run.ts owns behaviour.</item>
|
|
6
|
+
</non-goals>
|
|
7
|
+
</MODULE_CONTRACT>
|
|
8
|
+
<CHANGE_SUMMARY>
|
|
9
|
+
<item>RFC-1580: initial suite.</item>
|
|
10
|
+
<item>RFC-1580: correctness.gate and the flow.integrate step
|
|
11
|
+
|
|
12
|
+
Add os/correctness/gate (frozen set at --base, weakening diff incl. byte changes without verifier trailers and frozen exempt mode, git-derived oracle origin with forge/oracle-review@1 records, argv oracle runner with timeout, schema-hash substrate attestation, anchor events, tier high/formal, forge/correctness-bundle@1), the correctness.gate command, test-side helpers @warpgogol/forge/correctness, bindings.paths.oracleReviewsDir, and flow.integrate spawning the primary install's gate after hooks/integration-gate.sh (FLOW-INT-18, --accept-weakening with an X-Correctness-Weakening trailer commit). Flow and system test primaries get a stand-in forge binary; integration warnings now survive the cleanup report.</item>
|
|
13
|
+
</CHANGE_SUMMARY>
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
17
|
+
|
|
18
|
+
import { runCorrectnessGate } from "./run.ts";
|
|
19
|
+
import {
|
|
20
|
+
L1_ORACLE,
|
|
21
|
+
MOCK_ORACLE,
|
|
22
|
+
ORACLE_PATH,
|
|
23
|
+
lifecycleOracle,
|
|
24
|
+
makeGateFixture,
|
|
25
|
+
manifestYaml,
|
|
26
|
+
reviewYaml,
|
|
27
|
+
type GateFixture,
|
|
28
|
+
} from "./tests/gate-fixture.ts";
|
|
29
|
+
|
|
30
|
+
const fixtures: GateFixture[] = [];
|
|
31
|
+
afterEach(() => fixtures.splice(0).forEach((f) => f.cleanup()));
|
|
32
|
+
const fx = (o: Parameters<typeof makeGateFixture>[0] = {}) => {
|
|
33
|
+
const f = makeGateFixture(o);
|
|
34
|
+
fixtures.push(f);
|
|
35
|
+
return f;
|
|
36
|
+
};
|
|
37
|
+
const gate = async (f: GateFixture, acceptWeakening?: string) => {
|
|
38
|
+
const out = await runCorrectnessGate(f.root, {
|
|
39
|
+
base: f.base,
|
|
40
|
+
bundleDir: `${f.root}/.bundles`,
|
|
41
|
+
acceptWeakening,
|
|
42
|
+
});
|
|
43
|
+
if (!out.ok) throw new Error(out.usageError);
|
|
44
|
+
return out.result;
|
|
45
|
+
};
|
|
46
|
+
const rules = (r: { violations: { rule: string }[] }) => r.violations.map((v) => v.rule);
|
|
47
|
+
void [L1_ORACLE, MOCK_ORACLE, ORACLE_PATH, lifecycleOracle, manifestYaml, reviewYaml];
|
|
48
|
+
|
|
49
|
+
describe("oracle edits", () => {
|
|
50
|
+
it("AC-4: a frozen oracle edited in a plain commit is a weakening", async () => {
|
|
51
|
+
const f = fx();
|
|
52
|
+
f.write(ORACLE_PATH, `${L1_ORACLE}// tweak\n`);
|
|
53
|
+
f.commit("simplify the oracle");
|
|
54
|
+
const v = (await gate(f)).violations.find((x) => x.rule === "CORR-GATE-02");
|
|
55
|
+
expect(v?.message, "any byte change of a frozen oracle is a weakening").toMatch(
|
|
56
|
+
new RegExp(`frozen file ${ORACLE_PATH} changed`),
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("the same edit committed with the verifier trailer pair is not a weakening", async () => {
|
|
61
|
+
const f = fx();
|
|
62
|
+
f.write(ORACLE_PATH, `${L1_ORACLE}// verifier rewrite\n`);
|
|
63
|
+
f.git(["add", "-A"]);
|
|
64
|
+
f.git([
|
|
65
|
+
"commit",
|
|
66
|
+
"-qm",
|
|
67
|
+
"test: verifier oracle\n\nX-Expectation-Origin: independent-verifier\nX-Verifier-Report: docs/correctness/reviews/r.yaml",
|
|
68
|
+
]);
|
|
69
|
+
const r = await gate(f);
|
|
70
|
+
expect(rules(r)).not.toContain("CORR-GATE-02");
|
|
71
|
+
expect(r.status, JSON.stringify(r.violations)).toBe("pass");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("a deleted frozen anchor is a weakening", async () => {
|
|
75
|
+
const f = fx();
|
|
76
|
+
f.write("apps/api/src/dispatch.ts", "export function dispatch(): void {}\n");
|
|
77
|
+
f.commit("remove the anchor");
|
|
78
|
+
const msgs = (await gate(f)).violations
|
|
79
|
+
.filter((x) => x.rule === "CORR-GATE-02")
|
|
80
|
+
.map((x) => x.message);
|
|
81
|
+
expect(msgs.some((m) => /frozen anchor INV-dispatch-01 was removed/.test(m))).toBe(true);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1580 AC-9: an oracle added in the session without a committed forge/oracle-review@1 record naming its current sha256 is self — CORR-GATE-03 for its entry; a record with a stale hash does not count.</purpose>
|
|
4
|
+
<non-goals>
|
|
5
|
+
<item>Not a contract source of truth — gate/run.ts owns behaviour.</item>
|
|
6
|
+
</non-goals>
|
|
7
|
+
</MODULE_CONTRACT>
|
|
8
|
+
<CHANGE_SUMMARY>
|
|
9
|
+
<item>RFC-1580: initial suite.</item>
|
|
10
|
+
<item>RFC-1580: correctness.gate and the flow.integrate step
|
|
11
|
+
|
|
12
|
+
Add os/correctness/gate (frozen set at --base, weakening diff incl. byte changes without verifier trailers and frozen exempt mode, git-derived oracle origin with forge/oracle-review@1 records, argv oracle runner with timeout, schema-hash substrate attestation, anchor events, tier high/formal, forge/correctness-bundle@1), the correctness.gate command, test-side helpers @warpgogol/forge/correctness, bindings.paths.oracleReviewsDir, and flow.integrate spawning the primary install's gate after hooks/integration-gate.sh (FLOW-INT-18, --accept-weakening with an X-Correctness-Weakening trailer commit). Flow and system test primaries get a stand-in forge binary; integration warnings now survive the cleanup report.</item>
|
|
13
|
+
<item>RFC-1580: close review REVIEW-CODE-2026-11-13-04 findings
|
|
14
|
+
|
|
15
|
+
F1 bootstrap degrade only on an exact unknown-command stderr line with no JSON; F2 review records count only from a verifier-trailer commit naming them; F3 any frozen substrate change or dropped capture is a weakening, declared L3 needs loaded captures; F4 requirement origin needs acceptance before --base; F5 anchor events only for L2+ runs; F6 proof oracles via proof.check only, non-self; F7 bundle naming; F8/F9 limitations; F10 every anchor copy; F11 base entry refs; F12 unreadable base manifest refuses; F13 dirty worktree warning; F14 source/statement diffs; F15 process-group kill; F16 run root cleanup; F20 review dir stripped, blob hashes. Regression tests for spoofing, plain-commit review, L3, requirement origin, rewording, timeout, formal tier, rebind, real-gate pass, accept-weakening. DEV-1..DEV-6 recorded in the RFC.</item>
|
|
16
|
+
</CHANGE_SUMMARY>
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
20
|
+
|
|
21
|
+
import { runCorrectnessGate } from "./run.ts";
|
|
22
|
+
import {
|
|
23
|
+
L1_ORACLE,
|
|
24
|
+
MOCK_ORACLE,
|
|
25
|
+
ORACLE_PATH,
|
|
26
|
+
lifecycleOracle,
|
|
27
|
+
makeGateFixture,
|
|
28
|
+
manifestYaml,
|
|
29
|
+
reviewYaml,
|
|
30
|
+
verifierCommit,
|
|
31
|
+
type GateFixture,
|
|
32
|
+
} from "./tests/gate-fixture.ts";
|
|
33
|
+
|
|
34
|
+
const fixtures: GateFixture[] = [];
|
|
35
|
+
afterEach(() => fixtures.splice(0).forEach((f) => f.cleanup()));
|
|
36
|
+
const fx = (o: Parameters<typeof makeGateFixture>[0] = {}) => {
|
|
37
|
+
const f = makeGateFixture(o);
|
|
38
|
+
fixtures.push(f);
|
|
39
|
+
return f;
|
|
40
|
+
};
|
|
41
|
+
const gate = async (f: GateFixture, acceptWeakening?: string) => {
|
|
42
|
+
const out = await runCorrectnessGate(f.root, {
|
|
43
|
+
base: f.base,
|
|
44
|
+
bundleDir: `${f.root}/.bundles`,
|
|
45
|
+
acceptWeakening,
|
|
46
|
+
});
|
|
47
|
+
if (!out.ok) throw new Error(out.usageError);
|
|
48
|
+
return out.result;
|
|
49
|
+
};
|
|
50
|
+
const rules = (r: { violations: { rule: string }[] }) => r.violations.map((v) => v.rule);
|
|
51
|
+
void [
|
|
52
|
+
L1_ORACLE,
|
|
53
|
+
MOCK_ORACLE,
|
|
54
|
+
ORACLE_PATH,
|
|
55
|
+
lifecycleOracle,
|
|
56
|
+
manifestYaml,
|
|
57
|
+
reviewYaml,
|
|
58
|
+
verifierCommit,
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
const NEW_ORACLE = "test/new.oracle.ts";
|
|
62
|
+
const NEW_ENTRY = ` - id: CM-dispatch-02
|
|
63
|
+
source: req
|
|
64
|
+
ref: REQ-01
|
|
65
|
+
seam: data
|
|
66
|
+
anchors: [INV-dispatch-01]
|
|
67
|
+
oracles:
|
|
68
|
+
- check: test:${NEW_ORACLE}
|
|
69
|
+
substrate: L1
|
|
70
|
+
`;
|
|
71
|
+
const addEntry = (f: GateFixture) => {
|
|
72
|
+
f.write(NEW_ORACLE, L1_ORACLE);
|
|
73
|
+
f.write(
|
|
74
|
+
"apps/api/src/dispatch.ts",
|
|
75
|
+
f
|
|
76
|
+
.read("apps/api/src/dispatch.ts")
|
|
77
|
+
.replace(
|
|
78
|
+
`(checked-by: test:${ORACLE_PATH})`,
|
|
79
|
+
`(checked-by: test:${ORACLE_PATH}, test:${NEW_ORACLE})`,
|
|
80
|
+
),
|
|
81
|
+
);
|
|
82
|
+
f.write("docs/correctness.yaml", manifestYaml({}, NEW_ENTRY));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
describe("oracle origin", () => {
|
|
86
|
+
it("AC-9: a session-added oracle without a review record is self (CORR-GATE-03)", async () => {
|
|
87
|
+
const f = fx();
|
|
88
|
+
addEntry(f);
|
|
89
|
+
f.commit("add entry with its oracle");
|
|
90
|
+
const r = await gate(f);
|
|
91
|
+
const v = r.violations.find((x) => x.rule === "CORR-GATE-03");
|
|
92
|
+
expect(v?.entry, "a self oracle never covers").toBe("CM-dispatch-02");
|
|
93
|
+
expect(r.status).toBe("fail");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("a review record committed by the verifier workflow makes it verified", async () => {
|
|
97
|
+
const f = fx();
|
|
98
|
+
addEntry(f);
|
|
99
|
+
f.commit("add entry with its oracle");
|
|
100
|
+
const rel = "docs/correctness/reviews/2026-11-13-new.yaml";
|
|
101
|
+
f.write(rel, reviewYaml([{ check: `test:${NEW_ORACLE}`, content: L1_ORACLE }]));
|
|
102
|
+
verifierCommit(f.git, rel);
|
|
103
|
+
const r = await gate(f);
|
|
104
|
+
expect(rules(r)).not.toContain("CORR-GATE-03");
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("a review record the implementer commits without the verifier trailer pair does not count", async () => {
|
|
108
|
+
const f = fx();
|
|
109
|
+
addEntry(f);
|
|
110
|
+
f.write(
|
|
111
|
+
"docs/correctness/reviews/2026-11-13-new.yaml",
|
|
112
|
+
reviewYaml([{ check: `test:${NEW_ORACLE}`, content: L1_ORACLE }]),
|
|
113
|
+
);
|
|
114
|
+
f.commit("add entry, oracle, and its review");
|
|
115
|
+
expect(rules(await gate(f)), "a self-written record must never verify an oracle").toContain(
|
|
116
|
+
"CORR-GATE-03",
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("a verifier commit whose X-Verifier-Report names another file does not count", async () => {
|
|
121
|
+
const f = fx();
|
|
122
|
+
addEntry(f);
|
|
123
|
+
f.commit("add entry");
|
|
124
|
+
f.write(
|
|
125
|
+
"docs/correctness/reviews/2026-11-13-new.yaml",
|
|
126
|
+
reviewYaml([{ check: `test:${NEW_ORACLE}`, content: L1_ORACLE }]),
|
|
127
|
+
);
|
|
128
|
+
verifierCommit(f.git, "docs/correctness/reviews/other.yaml");
|
|
129
|
+
expect(rules(await gate(f))).toContain("CORR-GATE-03");
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("a review record with a stale hash does not count", async () => {
|
|
133
|
+
const f = fx();
|
|
134
|
+
addEntry(f);
|
|
135
|
+
f.write(
|
|
136
|
+
"docs/correctness/reviews/2026-11-13-new.yaml",
|
|
137
|
+
reviewYaml([{ check: `test:${NEW_ORACLE}`, content: "old bytes" }]),
|
|
138
|
+
);
|
|
139
|
+
f.commit("add entry with a stale review");
|
|
140
|
+
expect(rules(await gate(f))).toContain("CORR-GATE-03");
|
|
141
|
+
});
|
|
142
|
+
});
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1580: oracle origin from git only — `verified` (the last commit
|
|
4
|
+
touching the check file carries the RFC-1333 verifier trailer pair, or a
|
|
5
|
+
committed `forge/oracle-review@1` record names the check with its current
|
|
6
|
+
sha256 and `verdict: pass`), `requirement` (an `rfc-ac` / `fixed-input`
|
|
7
|
+
entry whose check file is byte-identical to its state at the governing RFC's
|
|
8
|
+
`accepted` commit, RFC-1330 range), `self` (everything else). A `self`
|
|
9
|
+
oracle never covers an entry.</purpose>
|
|
10
|
+
<non-goals>
|
|
11
|
+
<item>No second origin derivation — RFC-1330 `resolveImplementationRange` and `hasVerifierTrailers` are reused.</item>
|
|
12
|
+
<item>Never writes review records or trailers — only the clean-context verifier workflow commits them.</item>
|
|
13
|
+
</non-goals>
|
|
14
|
+
</MODULE_CONTRACT>
|
|
15
|
+
<CHANGE_SUMMARY>
|
|
16
|
+
<item>RFC-1580: initial origin derivation.</item>
|
|
17
|
+
<item>RFC-1580: correctness.gate and the flow.integrate step
|
|
18
|
+
|
|
19
|
+
Add os/correctness/gate (frozen set at --base, weakening diff incl. byte changes without verifier trailers and frozen exempt mode, git-derived oracle origin with forge/oracle-review@1 records, argv oracle runner with timeout, schema-hash substrate attestation, anchor events, tier high/formal, forge/correctness-bundle@1), the correctness.gate command, test-side helpers @warpgogol/forge/correctness, bindings.paths.oracleReviewsDir, and flow.integrate spawning the primary install's gate after hooks/integration-gate.sh (FLOW-INT-18, --accept-weakening with an X-Correctness-Weakening trailer commit). Flow and system test primaries get a stand-in forge binary; integration warnings now survive the cleanup report.</item>
|
|
20
|
+
<item>RFC-1580: close review REVIEW-CODE-2026-11-13-04 findings
|
|
21
|
+
|
|
22
|
+
F1 bootstrap degrade only on an exact unknown-command stderr line with no JSON; F2 review records count only from a verifier-trailer commit naming them; F3 any frozen substrate change or dropped capture is a weakening, declared L3 needs loaded captures; F4 requirement origin needs acceptance before --base; F5 anchor events only for L2+ runs; F6 proof oracles via proof.check only, non-self; F7 bundle naming; F8/F9 limitations; F10 every anchor copy; F11 base entry refs; F12 unreadable base manifest refuses; F13 dirty worktree warning; F14 source/statement diffs; F15 process-group kill; F16 run root cleanup; F20 review dir stripped, blob hashes. Regression tests for spoofing, plain-commit review, L3, requirement origin, rewording, timeout, formal tier, rebind, real-gate pass, accept-weakening. DEV-1..DEV-6 recorded in the RFC.</item>
|
|
23
|
+
</CHANGE_SUMMARY>
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { parse as parseYaml } from "yaml";
|
|
27
|
+
|
|
28
|
+
import { hasVerifierTrailers, resolveImplementationRange } from "../../rfc/verification-origin.ts";
|
|
29
|
+
import { normalizeCheckRef, normalizeRelPath } from "../workspace.ts";
|
|
30
|
+
import { sha256, type GateRepo } from "./repo.ts";
|
|
31
|
+
import { oracleReviewSchema, type OracleOrigin } from "./types.ts";
|
|
32
|
+
|
|
33
|
+
export interface ReviewedOracle {
|
|
34
|
+
check: string;
|
|
35
|
+
sha256: string;
|
|
36
|
+
record: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Passing oracle rows from review records committed at `head` under `dir`. */
|
|
40
|
+
export async function readReviewRecords(
|
|
41
|
+
repo: GateRepo,
|
|
42
|
+
head: string,
|
|
43
|
+
dir: string,
|
|
44
|
+
): Promise<ReviewedOracle[]> {
|
|
45
|
+
const listing = await repo.git.run([
|
|
46
|
+
"ls-tree",
|
|
47
|
+
"-r",
|
|
48
|
+
"-z",
|
|
49
|
+
"--name-only",
|
|
50
|
+
head,
|
|
51
|
+
"--",
|
|
52
|
+
normalizeRelPath(dir),
|
|
53
|
+
]);
|
|
54
|
+
const out: ReviewedOracle[] = [];
|
|
55
|
+
for (const rel of (listing ?? "").split("\0").filter((l) => /\.ya?ml$/.test(l))) {
|
|
56
|
+
const text = await repo.show(head, rel);
|
|
57
|
+
if (!text) continue;
|
|
58
|
+
// A record counts only when the verifier workflow committed it: the last
|
|
59
|
+
// commit touching it carries the trailer pair and its X-Verifier-Report
|
|
60
|
+
// names this very record (so it also surfaces in flow.digest).
|
|
61
|
+
const last = await repo.lastCommitBody(head, rel);
|
|
62
|
+
if (!last || !hasVerifierTrailers(last.body)) continue;
|
|
63
|
+
const reported = /^X-Verifier-Report:\s*(\S+)\s*$/m.exec(last.body)?.[1];
|
|
64
|
+
if (!reported || normalizeRelPath(reported) !== normalizeRelPath(rel)) continue;
|
|
65
|
+
let doc: unknown;
|
|
66
|
+
try {
|
|
67
|
+
doc = parseYaml(text);
|
|
68
|
+
} catch {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const parsed = oracleReviewSchema.safeParse(doc);
|
|
72
|
+
if (!parsed.success || parsed.data.verdict !== "pass") continue;
|
|
73
|
+
for (const o of parsed.data.oracles) {
|
|
74
|
+
if (o.verdict === "pass")
|
|
75
|
+
out.push({ check: normalizeCheckRef(o.check), sha256: o.sha256, record: rel });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface OriginResult {
|
|
82
|
+
origin: OracleOrigin;
|
|
83
|
+
/** True when `verified` came from the verifier trailer path (tier high requires it). */
|
|
84
|
+
viaTrailer: boolean;
|
|
85
|
+
detail: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Find the RFC file for `RFC-NNNN` in rfcsDir or its archive subtree at `head`. */
|
|
89
|
+
async function rfcPath(
|
|
90
|
+
repo: GateRepo,
|
|
91
|
+
head: string,
|
|
92
|
+
rfcsDir: string,
|
|
93
|
+
rfcId: string,
|
|
94
|
+
): Promise<string | null> {
|
|
95
|
+
const listing = await repo.git.run([
|
|
96
|
+
"ls-tree",
|
|
97
|
+
"-r",
|
|
98
|
+
"-z",
|
|
99
|
+
"--name-only",
|
|
100
|
+
head,
|
|
101
|
+
"--",
|
|
102
|
+
normalizeRelPath(rfcsDir),
|
|
103
|
+
]);
|
|
104
|
+
const prefix = `${rfcId.toLowerCase()}-`;
|
|
105
|
+
return (
|
|
106
|
+
(listing ?? "")
|
|
107
|
+
.split("\0")
|
|
108
|
+
.find((l) => l.endsWith(".md") && l.split("/").pop()!.startsWith(prefix)) ?? null
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export async function deriveOrigin(opts: {
|
|
113
|
+
repo: GateRepo;
|
|
114
|
+
head: string;
|
|
115
|
+
check: string;
|
|
116
|
+
source: string;
|
|
117
|
+
ref: string | null;
|
|
118
|
+
rfcsDir: string;
|
|
119
|
+
reviews: ReviewedOracle[];
|
|
120
|
+
checkFile: string | null;
|
|
121
|
+
/** The develop tip the session integrates into (requirement origin needs acceptance before it). */
|
|
122
|
+
integrationBase?: string;
|
|
123
|
+
}): Promise<OriginResult> {
|
|
124
|
+
const { repo, head, checkFile } = opts;
|
|
125
|
+
if (!checkFile) return { origin: "self", viaTrailer: false, detail: "check has no file target" };
|
|
126
|
+
const content = await repo.show(head, checkFile);
|
|
127
|
+
if (content === null)
|
|
128
|
+
return { origin: "self", viaTrailer: false, detail: `${checkFile} is not committed at HEAD` };
|
|
129
|
+
if (await repo.lastTouchIsVerifier(head, checkFile)) {
|
|
130
|
+
return {
|
|
131
|
+
origin: "verified",
|
|
132
|
+
viaTrailer: true,
|
|
133
|
+
detail: "last commit carries the verifier trailer pair",
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const digest = sha256(content);
|
|
137
|
+
const review = opts.reviews.find(
|
|
138
|
+
(r) => r.check === normalizeCheckRef(opts.check) && r.sha256 === digest,
|
|
139
|
+
);
|
|
140
|
+
if (review)
|
|
141
|
+
return { origin: "verified", viaTrailer: false, detail: `oracle review ${review.record}` };
|
|
142
|
+
if ((opts.source === "rfc-ac" || opts.source === "fixed-input") && opts.ref) {
|
|
143
|
+
const rfcId = /^(RFC-\d{4})\//.exec(opts.ref)?.[1];
|
|
144
|
+
// Resolve the RFC at the integration base: a session-added duplicate file must not win.
|
|
145
|
+
const rel = rfcId
|
|
146
|
+
? await rfcPath(repo, opts.integrationBase ?? head, opts.rfcsDir, rfcId)
|
|
147
|
+
: null;
|
|
148
|
+
if (rel) {
|
|
149
|
+
const range = await resolveImplementationRange(repo.git, rel);
|
|
150
|
+
// The acceptance must predate the integration base — a session cannot
|
|
151
|
+
// accept (or create) the governing RFC together with its own test.
|
|
152
|
+
const acceptedBeforeBase =
|
|
153
|
+
range.base !== null &&
|
|
154
|
+
opts.integrationBase !== undefined &&
|
|
155
|
+
(await repo.git.run(["merge-base", "--is-ancestor", range.base, opts.integrationBase])) !==
|
|
156
|
+
null;
|
|
157
|
+
if (range.base && acceptedBeforeBase) {
|
|
158
|
+
const atAccept = await repo.blob(range.base, checkFile);
|
|
159
|
+
const now = await repo.blob(head, checkFile);
|
|
160
|
+
if (atAccept !== null && atAccept === now) {
|
|
161
|
+
return {
|
|
162
|
+
origin: "requirement",
|
|
163
|
+
viaTrailer: false,
|
|
164
|
+
detail: `identical to ${rfcId} accepted commit ${range.base.slice(0, 9)}`,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
origin: "self",
|
|
172
|
+
viaTrailer: false,
|
|
173
|
+
detail: "written or changed by the implementing session with no review record",
|
|
174
|
+
};
|
|
175
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1580: git reads the gate needs — files and blob ids at a
|
|
4
|
+
revision, last commit touching a path, changed paths in a range — through
|
|
5
|
+
the RFC-1330 origin git port (argv exec, DNA-89).</purpose>
|
|
6
|
+
<non-goals>
|
|
7
|
+
<item>No writes, no checkout.</item>
|
|
8
|
+
</non-goals>
|
|
9
|
+
</MODULE_CONTRACT>
|
|
10
|
+
<CHANGE_SUMMARY>
|
|
11
|
+
<item>RFC-1580: initial git reads.</item>
|
|
12
|
+
<item>RFC-1580: correctness.gate and the flow.integrate step
|
|
13
|
+
|
|
14
|
+
Add os/correctness/gate (frozen set at --base, weakening diff incl. byte changes without verifier trailers and frozen exempt mode, git-derived oracle origin with forge/oracle-review@1 records, argv oracle runner with timeout, schema-hash substrate attestation, anchor events, tier high/formal, forge/correctness-bundle@1), the correctness.gate command, test-side helpers @warpgogol/forge/correctness, bindings.paths.oracleReviewsDir, and flow.integrate spawning the primary install's gate after hooks/integration-gate.sh (FLOW-INT-18, --accept-weakening with an X-Correctness-Weakening trailer commit). Flow and system test primaries get a stand-in forge binary; integration warnings now survive the cleanup report.</item>
|
|
15
|
+
</CHANGE_SUMMARY>
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { createHash } from "node:crypto";
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
createOriginGit,
|
|
22
|
+
hasVerifierTrailers,
|
|
23
|
+
type OriginGit,
|
|
24
|
+
} from "../../rfc/verification-origin.ts";
|
|
25
|
+
|
|
26
|
+
export class GateRepo {
|
|
27
|
+
readonly git: OriginGit;
|
|
28
|
+
private readonly blobCache = new Map<string, string | null>();
|
|
29
|
+
|
|
30
|
+
readonly root: string;
|
|
31
|
+
|
|
32
|
+
// No parameter properties: the forge CLI runs under node's strip-only TypeScript mode.
|
|
33
|
+
constructor(root: string) {
|
|
34
|
+
this.root = root;
|
|
35
|
+
this.git = createOriginGit(root);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async show(rev: string, rel: string): Promise<string | null> {
|
|
39
|
+
return this.git.run(["show", `${rev}:${rel}`]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Blob id of `rel` at `rev`, null when absent. */
|
|
43
|
+
async blob(rev: string, rel: string): Promise<string | null> {
|
|
44
|
+
const key = `${rev}:${rel}`;
|
|
45
|
+
if (this.blobCache.has(key)) return this.blobCache.get(key)!;
|
|
46
|
+
const out = await this.git.run(["rev-parse", "--verify", "--quiet", `${rev}:${rel}`]);
|
|
47
|
+
const sha = out?.trim() || null;
|
|
48
|
+
this.blobCache.set(key, sha);
|
|
49
|
+
return sha;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async files(rev: string): Promise<string[]> {
|
|
53
|
+
const out = await this.git.run(["ls-tree", "-r", "-z", "--name-only", rev]);
|
|
54
|
+
return (out ?? "").split("\0").filter((l) => l.length > 0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async changedPaths(base: string, head: string): Promise<string[]> {
|
|
58
|
+
const out = await this.git.run(["diff", "--name-only", "-z", `${base}..${head}`]);
|
|
59
|
+
return (out ?? "").split("\0").filter((l) => l.length > 0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Body of the last commit (≤ head) touching `rel`, or null. */
|
|
63
|
+
async lastCommitBody(head: string, rel: string): Promise<{ sha: string; body: string } | null> {
|
|
64
|
+
const out = await this.git.run(["log", "-1", "--format=%H%x1f%B", head, "--", rel]);
|
|
65
|
+
if (!out || !out.includes("\x1f")) return null;
|
|
66
|
+
const [sha, body] = out.split("\x1f");
|
|
67
|
+
return { sha: sha!.trim(), body: body ?? "" };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** True when the last commit touching `rel` carries the RFC-1333 verifier trailer pair. */
|
|
71
|
+
async lastTouchIsVerifier(head: string, rel: string): Promise<boolean> {
|
|
72
|
+
const last = await this.lastCommitBody(head, rel);
|
|
73
|
+
return last !== null && hasVerifierTrailers(last.body);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async revParse(ref: string): Promise<string | null> {
|
|
77
|
+
const out = await this.git.run(["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]);
|
|
78
|
+
const sha = out?.trim() ?? "";
|
|
79
|
+
return /^[0-9a-f]{40,64}$/.test(sha) ? sha : null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async commonDir(): Promise<string | null> {
|
|
83
|
+
const out = await this.git.run(["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
84
|
+
return out?.trim() || null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function sha256(text: string): string {
|
|
89
|
+
return createHash("sha256").update(text).digest("hex");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Path part of an RFC-1390 binding reference (`test:a/b.ts` → `a/b.ts`); null for `lint:`. */
|
|
93
|
+
export function checkTarget(check: string): string | null {
|
|
94
|
+
const idx = check.indexOf(":");
|
|
95
|
+
if (idx === -1) return null;
|
|
96
|
+
const kind = check.slice(0, idx).trim();
|
|
97
|
+
if (kind !== "test" && kind !== "type" && kind !== "proof") return null;
|
|
98
|
+
return check
|
|
99
|
+
.slice(idx + 1)
|
|
100
|
+
.trim()
|
|
101
|
+
.replace(/^\.\//, "");
|
|
102
|
+
}
|