@warpgogol/forge 9.4.1 → 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 +33 -0
- package/README.md +30 -0
- package/README.uk.md +30 -0
- package/bin/cli.ts +163 -53
- package/dist/bin/cli.js +137 -42
- 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/dirty-classify.d.ts +7 -0
- package/dist/os/flow/dirty-classify.d.ts.map +1 -1
- package/dist/os/flow/dirty-classify.js +11 -0
- package/dist/os/flow/dirty-classify.js.map +1 -1
- package/dist/os/flow/flow.module.d.ts.map +1 -1
- package/dist/os/flow/flow.module.js +19 -4
- package/dist/os/flow/flow.module.js.map +1 -1
- package/dist/os/flow/handlers/flow-check.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-check.js +9 -9
- package/dist/os/flow/handlers/flow-check.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 +148 -30
- package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
- package/dist/os/flow/handlers/flow-open.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-open.js +14 -19
- package/dist/os/flow/handlers/flow-open.js.map +1 -1
- package/dist/os/flow/index.d.ts +1 -0
- package/dist/os/flow/index.d.ts.map +1 -1
- package/dist/os/flow/index.js +5 -3
- package/dist/os/flow/index.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 +24 -0
- package/dist/os/flow/preflight.d.ts.map +1 -1
- package/dist/os/flow/preflight.js +364 -24
- 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 +6 -6
- 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/detach.d.ts +27 -0
- package/dist/os/gate-run/detach.d.ts.map +1 -0
- package/dist/os/gate-run/detach.js +85 -0
- package/dist/os/gate-run/detach.js.map +1 -0
- package/dist/os/gate-run/gate-run.module.d.ts +3 -0
- package/dist/os/gate-run/gate-run.module.d.ts.map +1 -0
- package/dist/os/gate-run/gate-run.module.js +23 -0
- package/dist/os/gate-run/gate-run.module.js.map +1 -0
- package/dist/os/gate-run/index.d.ts +7 -0
- package/dist/os/gate-run/index.d.ts.map +1 -0
- package/dist/os/gate-run/index.js +5 -0
- package/dist/os/gate-run/index.js.map +1 -0
- package/dist/os/gate-run/record.d.ts +47 -0
- package/dist/os/gate-run/record.d.ts.map +1 -0
- package/dist/os/gate-run/record.js +157 -0
- package/dist/os/gate-run/record.js.map +1 -0
- package/dist/os/gate-run/status.d.ts +53 -0
- package/dist/os/gate-run/status.d.ts.map +1 -0
- package/dist/os/gate-run/status.js +163 -0
- package/dist/os/gate-run/status.js.map +1 -0
- package/dist/os/gate-run/types.d.ts +47 -0
- package/dist/os/gate-run/types.d.ts.map +1 -0
- package/dist/os/gate-run/types.js +24 -0
- package/dist/os/gate-run/types.js.map +1 -0
- package/dist/os/program/schemas.d.ts +3 -3
- package/dist/os/queue/types.d.ts +2 -2
- package/dist/os/rfc/evidence-annotation.d.ts +26 -0
- package/dist/os/rfc/evidence-annotation.d.ts.map +1 -0
- package/dist/os/rfc/evidence-annotation.js +52 -0
- package/dist/os/rfc/evidence-annotation.js.map +1 -0
- package/dist/os/rfc/handlers/fixed-inputs.d.ts.map +1 -1
- package/dist/os/rfc/handlers/fixed-inputs.js +7 -1
- package/dist/os/rfc/handlers/fixed-inputs.js.map +1 -1
- 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 +35 -29
- 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 +152 -11
- 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 +20 -7
- 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/cli-flags.d.ts.map +1 -1
- package/dist/src/cli-flags.js +6 -0
- package/dist/src/cli-flags.js.map +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/dist/src/types.d.ts +7 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +2 -8
- package/dist/src/types.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/dirty-classify.ts +13 -0
- package/os/flow/flow.module.ts +20 -4
- package/os/flow/handlers/flow-check.ts +17 -18
- package/os/flow/handlers/flow-digest.ts +11 -1
- package/os/flow/handlers/flow-integrate.ts +191 -39
- package/os/flow/handlers/flow-open.ts +24 -31
- package/os/flow/index.ts +5 -7
- package/os/flow/post-rebase-regen.ts +170 -0
- package/os/flow/preflight.ts +361 -27
- 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.preflight.test.ts +26 -5
- package/os/flow/tests/flow-integrate.test.ts +77 -10
- package/os/flow/tests/helpers.ts +45 -24
- package/os/flow/tests/lockfile-induced.test.ts +328 -0
- package/os/gate-run/detach.ts +106 -0
- package/os/gate-run/gate-run.module.ts +25 -0
- package/os/gate-run/index.ts +16 -0
- package/os/gate-run/record.ts +194 -0
- package/os/gate-run/status.ts +201 -0
- package/os/gate-run/tests/gate-run-detach.test.ts +144 -0
- package/os/gate-run/tests/gate-run-record.test.ts +200 -0
- package/os/gate-run/tests/gate-run-status.test.ts +114 -0
- package/os/gate-run/types.ts +73 -0
- package/os/rfc/evidence-annotation.ts +61 -0
- package/os/rfc/handlers/fixed-inputs.test.ts +70 -0
- package/os/rfc/handlers/fixed-inputs.ts +11 -1
- 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 +40 -29
- package/os/rfc/handlers/list-create.test.ts +14 -5
- package/os/rfc/handlers/validate-evidence-shape.test.ts +218 -0
- package/os/rfc/handlers/validate-probe-meta.test.ts +71 -0
- package/os/rfc/handlers/validate-rules.ts +211 -21
- package/os/rfc/handlers/validate-transient-probes.test.ts +222 -0
- package/os/rfc/rfc-0000-template.md +10 -10
- package/os/rfc/rfc.module.ts +21 -7
- 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 +57 -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/skills/fo/fo-session-retro/SKILL.md +4 -2
- package/src/cli-flags.ts +7 -0
- 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
- package/src/types.ts +9 -8
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1580: `correctness.gate` command handler — flags, exit codes
|
|
4
|
+
(1 on any error, 2 on usage), pretty output. Read-only except for its
|
|
5
|
+
bundle file under the git common dir.</purpose>
|
|
6
|
+
<non-goals>
|
|
7
|
+
<item>No gate logic — gate/run.ts.</item>
|
|
8
|
+
<item>Never passes --accept-weakening on its own — the operator decides.</item>
|
|
9
|
+
</non-goals>
|
|
10
|
+
</MODULE_CONTRACT>
|
|
11
|
+
<CHANGE_SUMMARY>
|
|
12
|
+
<item>RFC-1580: initial handler.</item>
|
|
13
|
+
<item>RFC-1580: correctness.gate and the flow.integrate step
|
|
14
|
+
|
|
15
|
+
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>
|
|
16
|
+
</CHANGE_SUMMARY>
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { readFileSync } from "node:fs";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
|
|
23
|
+
import type {
|
|
24
|
+
ForgeCommandInput,
|
|
25
|
+
ForgeCommandResult,
|
|
26
|
+
ForgeRuntimeContext,
|
|
27
|
+
} from "../../../src/types.ts";
|
|
28
|
+
import { runCorrectnessGate } from "../gate/run.ts";
|
|
29
|
+
import type { CorrectnessGateResult } from "../gate/types.ts";
|
|
30
|
+
|
|
31
|
+
function forgeVersion(): string {
|
|
32
|
+
try {
|
|
33
|
+
const pkg = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../../package.json");
|
|
34
|
+
return String(
|
|
35
|
+
(JSON.parse(readFileSync(pkg, "utf8")) as { version?: string }).version ?? "unknown",
|
|
36
|
+
);
|
|
37
|
+
} catch {
|
|
38
|
+
return "unknown";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function runCorrectnessGateCommand(
|
|
43
|
+
input: ForgeCommandInput,
|
|
44
|
+
context: ForgeRuntimeContext,
|
|
45
|
+
): Promise<ForgeCommandResult<CorrectnessGateResult>> {
|
|
46
|
+
const base = typeof input.flags["base"] === "string" ? (input.flags["base"] as string) : "";
|
|
47
|
+
if (!base)
|
|
48
|
+
return { exitCode: 2, summary: "[correctness.gate] usage error: --base <sha> is required" };
|
|
49
|
+
const accept =
|
|
50
|
+
typeof input.flags["accept-weakening"] === "string"
|
|
51
|
+
? (input.flags["accept-weakening"] as string)
|
|
52
|
+
: undefined;
|
|
53
|
+
const outcome = await runCorrectnessGate(context.workspaceRoot, {
|
|
54
|
+
base,
|
|
55
|
+
acceptWeakening: accept,
|
|
56
|
+
forgeVersion: forgeVersion(),
|
|
57
|
+
forgePath: process.argv[1],
|
|
58
|
+
});
|
|
59
|
+
if (!outcome.ok)
|
|
60
|
+
return { exitCode: 2, summary: `[correctness.gate] usage error: ${outcome.usageError}` };
|
|
61
|
+
const data = outcome.result;
|
|
62
|
+
if (context.outputFormat === "pretty") {
|
|
63
|
+
for (const v of data.violations) {
|
|
64
|
+
const line = `${v.rule} ${v.message}`;
|
|
65
|
+
if (v.severity === "error") context.logger.error(line);
|
|
66
|
+
else context.logger.warn(line);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const errors = data.violations.filter((v) => v.severity === "error").length;
|
|
70
|
+
const summary =
|
|
71
|
+
data.status === "exempt"
|
|
72
|
+
? "correctness.gate: exempt (correctness.mode: exempt)"
|
|
73
|
+
: `correctness.gate: ${data.status} (mode ${data.mode}, ${errors} error(s), ${data.violations.length - errors} warning(s), ${data.weakenings.length} weakening(s)${data.acceptedWeakening ? " accepted" : ""}) — bundle ${data.bundlePath}`;
|
|
74
|
+
return { data, summary, exitCode: data.status === "fail" ? 1 : 0 };
|
|
75
|
+
}
|
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1578: `correctness.manifest.validate` — checks the product
|
|
4
|
+
correctness manifest (`forge/correctness-manifest@1`) and the `correctness`
|
|
5
|
+
section of forge.yaml: CORR-01 presence, CORR-02 schema, CORR-03 ref
|
|
6
|
+
resolution, CORR-04 code anchors, CORR-05 oracle ↔ checked-by binding,
|
|
7
|
+
CORR-06 seam substrate minimums, CORR-07 capture provenance, CORR-08
|
|
8
|
+
requirement/DNA coverage, CORR-09 exemption shape. `mode: exempt` evaluates
|
|
9
|
+
no rule.</purpose>
|
|
10
|
+
<non-goals>
|
|
11
|
+
<item>Do not run oracles, freeze them, or attest substrates — RFC-1580.</item>
|
|
12
|
+
<item>Do not write the manifest or any other file — read-only.</item>
|
|
13
|
+
<item>Do not parse `@ai-invariant` markers directly — anchors.ts delegates to the RFC-1390 parser.</item>
|
|
14
|
+
</non-goals>
|
|
15
|
+
</MODULE_CONTRACT>
|
|
16
|
+
<KEY_DECISIONS>
|
|
17
|
+
<item>Unparseable YAML is CORR-01 (the manifest is effectively absent); a parsed document that violates the schema is CORR-02.</item>
|
|
18
|
+
<item>A provider entry's L1/L2 oracle satisfies the minimum only when every capture it declares has a valid, unexpired sidecar.</item>
|
|
19
|
+
<item>The clock is injectable so CORR-07 is testable without sleeping.</item>
|
|
20
|
+
</KEY_DECISIONS>
|
|
21
|
+
<CHANGE_SUMMARY>
|
|
22
|
+
<item>RFC-1578: initial validator, rules CORR-01..09.</item>
|
|
23
|
+
<item>RFC-1578: correctness manifest, validator, promotes gate
|
|
24
|
+
|
|
25
|
+
Add os/correctness (forge/correctness-manifest@1, correctness.manifest.validate CORR-01..09), bindings.paths.correctnessManifest, bindings.commands.checkRun and the correctness section, promotes with V-55 and RFC-IMP-16, the typescript profile skeleton, reference pages, and the promotes marking in fo-idea-create-rfc/fo-idea-audit. Repoint the RFC-1391 AC-8 registry test at src/command-modules.ts (stale since RFC-1573) and close the types.ts header comment without a glob-shaped terminator (EC-33).</item>
|
|
26
|
+
<item>RFC-1578: close review REVIEW-CODE-2026-11-12-08 findings
|
|
27
|
+
|
|
28
|
+
F1 code-only anchor scan (markdown fences never declare anchors); F2 generated index as a re-verified hint, scan on any miss; F3 RFC-IMP-16 asserted through rfc.implement.stamp; F4 forge create patches only absent/null keys; F5 type: refs normalized; F6/F10/F11 capture existence via existsSync, future recordedAt and workspace-escaping paths are CORR-07; F7 V-55 reuses criteriaEval; F8 validator inventory regenerated; F9 binding-driven reads; F12 git listing, index hint, create patch tests; DEV-1 single sidecar spelling; DEV-2 output field dropped.</item>
|
|
29
|
+
</CHANGE_SUMMARY>
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
33
|
+
import path from "node:path";
|
|
34
|
+
import picomatch from "picomatch";
|
|
35
|
+
import { parse as parseYaml } from "yaml";
|
|
36
|
+
|
|
37
|
+
import { BINDING_KINDS } from "../../../src/compass/invariant-parser.ts";
|
|
38
|
+
import type {
|
|
39
|
+
ForgeCommandInput,
|
|
40
|
+
ForgeCommandResult,
|
|
41
|
+
ForgeRuntimeContext,
|
|
42
|
+
} from "../../../src/types.ts";
|
|
43
|
+
import { buildAnchorIndex } from "../anchors.ts";
|
|
44
|
+
import {
|
|
45
|
+
CAPTURE_SIDECAR_SUFFIX,
|
|
46
|
+
CORRECTNESS_ENTRY_ID_RE,
|
|
47
|
+
SEAM_MINIMUM,
|
|
48
|
+
correctnessCaptureSchema,
|
|
49
|
+
correctnessManifestSchema,
|
|
50
|
+
substrateRank,
|
|
51
|
+
type CorrectnessEntry,
|
|
52
|
+
type CorrectnessManifest,
|
|
53
|
+
type CorrectnessOracle,
|
|
54
|
+
type CorrectnessRuleId,
|
|
55
|
+
type CorrectnessValidateResult,
|
|
56
|
+
type CorrectnessViolation,
|
|
57
|
+
type CoverageCounts,
|
|
58
|
+
type Substrate,
|
|
59
|
+
} from "../manifest-schema.ts";
|
|
60
|
+
import { readDnaIds, readRequirementsDocument, resolveRfcRef } from "../references.ts";
|
|
61
|
+
import {
|
|
62
|
+
listWorkspaceFiles,
|
|
63
|
+
normalizeCheckRef,
|
|
64
|
+
normalizeRelPath,
|
|
65
|
+
readCorrectnessSettings,
|
|
66
|
+
} from "../workspace.ts";
|
|
67
|
+
|
|
68
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
69
|
+
export const CAPTURE_EXPIRY_WARNING_DAYS = 7;
|
|
70
|
+
/** Clock skew tolerated for a sidecar recordedAt ahead of the validator's clock. */
|
|
71
|
+
const FUTURE_SKEW_MS = DAY_MS;
|
|
72
|
+
|
|
73
|
+
export interface ValidateOptions {
|
|
74
|
+
/** Wall clock for CORR-07 (defaults to Date.now()). */
|
|
75
|
+
now?: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface CaptureStatus {
|
|
79
|
+
capture: string;
|
|
80
|
+
ok: boolean;
|
|
81
|
+
expiringSoon: boolean;
|
|
82
|
+
problem?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Evaluate one capture file's sidecar provenance and freshness. */
|
|
86
|
+
export function evaluateCapture(
|
|
87
|
+
workspaceRoot: string,
|
|
88
|
+
capture: string,
|
|
89
|
+
now: number,
|
|
90
|
+
): CaptureStatus {
|
|
91
|
+
const rel = normalizeRelPath(capture);
|
|
92
|
+
const fail = (problem: string): CaptureStatus => ({
|
|
93
|
+
capture: rel,
|
|
94
|
+
ok: false,
|
|
95
|
+
expiringSoon: false,
|
|
96
|
+
problem,
|
|
97
|
+
});
|
|
98
|
+
// Captures are workspace files — a path escaping the root is never evidence.
|
|
99
|
+
if (rel.startsWith("../") || rel === ".." || path.isAbsolute(rel)) {
|
|
100
|
+
return fail(`capture path ${capture} escapes the workspace`);
|
|
101
|
+
}
|
|
102
|
+
if (!existsSync(path.join(workspaceRoot, rel))) return fail(`capture file ${rel} is missing`);
|
|
103
|
+
// Sidecar: `<capture file>.capture.yaml` (one sidecar per capture file).
|
|
104
|
+
const used = `${rel}${CAPTURE_SIDECAR_SUFFIX}`;
|
|
105
|
+
let raw: string;
|
|
106
|
+
try {
|
|
107
|
+
raw = readFileSync(path.join(workspaceRoot, used), "utf8");
|
|
108
|
+
} catch {
|
|
109
|
+
return fail(`capture ${rel} has no sidecar (${used})`);
|
|
110
|
+
}
|
|
111
|
+
let doc: unknown;
|
|
112
|
+
try {
|
|
113
|
+
doc = parseYaml(raw);
|
|
114
|
+
} catch (err) {
|
|
115
|
+
return {
|
|
116
|
+
capture: rel,
|
|
117
|
+
ok: false,
|
|
118
|
+
expiringSoon: false,
|
|
119
|
+
problem: `sidecar ${used} is not YAML: ${(err as Error).message}`,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const parsed = correctnessCaptureSchema.safeParse(doc);
|
|
123
|
+
if (!parsed.success) {
|
|
124
|
+
const fields = parsed.error.issues.map((i) => i.path.join(".") || "(root)").join(", ");
|
|
125
|
+
return {
|
|
126
|
+
capture: rel,
|
|
127
|
+
ok: false,
|
|
128
|
+
expiringSoon: false,
|
|
129
|
+
problem: `sidecar ${used} lacks required provenance (${fields}); needs schema, recordedAt, provider, model, ttlDays, origin`,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const recorded = Date.parse(parsed.data.recordedAt);
|
|
133
|
+
if (Number.isNaN(recorded)) {
|
|
134
|
+
return {
|
|
135
|
+
capture: rel,
|
|
136
|
+
ok: false,
|
|
137
|
+
expiringSoon: false,
|
|
138
|
+
problem: `sidecar ${used} recordedAt "${parsed.data.recordedAt}" is not a timestamp`,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
if (recorded > now + FUTURE_SKEW_MS) {
|
|
142
|
+
return fail(
|
|
143
|
+
`sidecar ${used} recordedAt ${parsed.data.recordedAt} lies in the future — a capture cannot be fresher than now`,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
const expiresAt = recorded + parsed.data.ttlDays * DAY_MS;
|
|
147
|
+
if (now > expiresAt) {
|
|
148
|
+
const ageDays = Math.floor((now - recorded) / DAY_MS);
|
|
149
|
+
return {
|
|
150
|
+
capture: rel,
|
|
151
|
+
ok: false,
|
|
152
|
+
expiringSoon: false,
|
|
153
|
+
problem: `capture ${rel} is ${ageDays} days old, past its ttlDays ${parsed.data.ttlDays} — re-record it on the live provider`,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const expiringSoon = expiresAt - now <= CAPTURE_EXPIRY_WARNING_DAYS * DAY_MS;
|
|
157
|
+
return { capture: rel, ok: true, expiringSoon };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function emptyCoverage(): CoverageCounts {
|
|
161
|
+
return { total: 0, anchored: 0, exempt: 0, silent: 0 };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Pure-ish core: evaluate the workspace's correctness manifest. */
|
|
165
|
+
export async function validateCorrectnessManifest(
|
|
166
|
+
workspaceRoot: string,
|
|
167
|
+
options: ValidateOptions = {},
|
|
168
|
+
): Promise<CorrectnessValidateResult> {
|
|
169
|
+
const now = options.now ?? Date.now();
|
|
170
|
+
const settings = readCorrectnessSettings(workspaceRoot);
|
|
171
|
+
const violations: CorrectnessViolation[] = [];
|
|
172
|
+
const add = (
|
|
173
|
+
rule: CorrectnessRuleId,
|
|
174
|
+
severity: "error" | "warning",
|
|
175
|
+
message: string,
|
|
176
|
+
extra: { entry?: string; ref?: string } = {},
|
|
177
|
+
) => violations.push({ rule, severity, message, ...extra });
|
|
178
|
+
|
|
179
|
+
const result = (
|
|
180
|
+
status: CorrectnessValidateResult["status"],
|
|
181
|
+
coverage = { req: emptyCoverage(), dna: emptyCoverage() },
|
|
182
|
+
): CorrectnessValidateResult => ({
|
|
183
|
+
command: "correctness.manifest.validate",
|
|
184
|
+
mode: settings.mode,
|
|
185
|
+
tier: settings.tier,
|
|
186
|
+
status,
|
|
187
|
+
coverage,
|
|
188
|
+
violations,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
for (const bad of settings.invalid) {
|
|
192
|
+
const allowed = bad.key === "mode" ? "warn, enforce, exempt" : "standard, high, formal";
|
|
193
|
+
add(
|
|
194
|
+
"CORR-02",
|
|
195
|
+
"error",
|
|
196
|
+
`forge.yaml correctness.${bad.key} "${String(bad.value)}" is invalid — expected one of: ${allowed}`,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (settings.mode === "exempt") {
|
|
201
|
+
if (settings.manifestPath) {
|
|
202
|
+
add(
|
|
203
|
+
"CORR-02",
|
|
204
|
+
"error",
|
|
205
|
+
`correctness.mode is exempt but bindings.paths.correctnessManifest is set (${settings.manifestPath}) — a repository without a product runtime declares no manifest; drop one of the two`,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
return result(violations.some((v) => v.severity === "error") ? "fail" : "exempt");
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const gated = settings.mode === "enforce" ? "error" : "warning";
|
|
212
|
+
if (settings.configError) {
|
|
213
|
+
add("CORR-01", gated, `forge.yaml is not readable: ${settings.configError}`);
|
|
214
|
+
}
|
|
215
|
+
if (settings.mode === "enforce" && !settings.checkRun) {
|
|
216
|
+
add(
|
|
217
|
+
"CORR-01",
|
|
218
|
+
"error",
|
|
219
|
+
"correctness.mode is enforce but bindings.commands.checkRun is unset — bind the command that runs one oracle ({file} placeholder)",
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// ── Load the manifest (CORR-01 / CORR-02) ──────────────────────────────
|
|
224
|
+
let manifest: CorrectnessManifest | null = null;
|
|
225
|
+
if (!settings.manifestPath) {
|
|
226
|
+
add(
|
|
227
|
+
"CORR-01",
|
|
228
|
+
gated,
|
|
229
|
+
"bindings.paths.correctnessManifest is unset — the product declares no correctness manifest",
|
|
230
|
+
);
|
|
231
|
+
} else {
|
|
232
|
+
let raw: string | null = null;
|
|
233
|
+
try {
|
|
234
|
+
raw = readFileSync(path.join(workspaceRoot, settings.manifestPath), "utf8");
|
|
235
|
+
} catch {
|
|
236
|
+
add("CORR-01", gated, `correctness manifest ${settings.manifestPath} does not exist`);
|
|
237
|
+
}
|
|
238
|
+
if (raw !== null) {
|
|
239
|
+
let doc: unknown;
|
|
240
|
+
let parsedYaml = true;
|
|
241
|
+
try {
|
|
242
|
+
doc = parseYaml(raw);
|
|
243
|
+
} catch (err) {
|
|
244
|
+
parsedYaml = false;
|
|
245
|
+
add(
|
|
246
|
+
"CORR-01",
|
|
247
|
+
gated,
|
|
248
|
+
`correctness manifest ${settings.manifestPath} is not valid YAML: ${(err as Error).message}`,
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
if (parsedYaml) {
|
|
252
|
+
const parsed = correctnessManifestSchema.safeParse(doc ?? {});
|
|
253
|
+
if (parsed.success) {
|
|
254
|
+
manifest = parsed.data;
|
|
255
|
+
} else {
|
|
256
|
+
for (const issue of parsed.error.issues) {
|
|
257
|
+
add(
|
|
258
|
+
"CORR-02",
|
|
259
|
+
"error",
|
|
260
|
+
`manifest schema: ${issue.path.join(".") || "(root)"}: ${issue.message}`,
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// ── Reference roots ─────────────────────────────────────────────────────
|
|
269
|
+
const reqDoc = readRequirementsDocument(workspaceRoot, settings.compassDocs);
|
|
270
|
+
const dnaIds = readDnaIds(workspaceRoot, settings.invariantsFile);
|
|
271
|
+
const reqIds = new Set(reqDoc.ids);
|
|
272
|
+
const dnaSet = new Set(dnaIds);
|
|
273
|
+
|
|
274
|
+
const entries: CorrectnessEntry[] = manifest?.entries ?? [];
|
|
275
|
+
const exemptions = manifest?.exemptions ?? [];
|
|
276
|
+
|
|
277
|
+
if (manifest) {
|
|
278
|
+
const files = await listWorkspaceFiles(workspaceRoot);
|
|
279
|
+
const anchorIndex =
|
|
280
|
+
entries.length > 0
|
|
281
|
+
? buildAnchorIndex(
|
|
282
|
+
workspaceRoot,
|
|
283
|
+
files,
|
|
284
|
+
entries.flatMap((x) => x.anchors),
|
|
285
|
+
)
|
|
286
|
+
: null;
|
|
287
|
+
|
|
288
|
+
// CORR-02: support globs must match files.
|
|
289
|
+
for (const glob of manifest.support) {
|
|
290
|
+
const matcher = picomatch(normalizeRelPath(glob), { dot: true });
|
|
291
|
+
if (!files.some((f) => matcher(f))) {
|
|
292
|
+
add("CORR-02", "error", `support glob "${glob}" matches no file`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const seenIds = new Set<string>();
|
|
297
|
+
for (const entry of entries) {
|
|
298
|
+
const e = { entry: entry.id };
|
|
299
|
+
// CORR-02 entry shape.
|
|
300
|
+
if (!CORRECTNESS_ENTRY_ID_RE.test(entry.id)) {
|
|
301
|
+
add("CORR-02", "error", `entry id "${entry.id}" does not match CM-<scope>-<NN>`, e);
|
|
302
|
+
}
|
|
303
|
+
if (seenIds.has(entry.id)) add("CORR-02", "error", `duplicate entry id ${entry.id}`, e);
|
|
304
|
+
seenIds.add(entry.id);
|
|
305
|
+
if (entry.source === "domain" && !entry.statement) {
|
|
306
|
+
add("CORR-02", "error", `${entry.id}: a domain entry needs a statement`, e);
|
|
307
|
+
}
|
|
308
|
+
if (entry.source !== "domain" && !entry.ref) {
|
|
309
|
+
add("CORR-02", "error", `${entry.id}: a ${entry.source} entry needs a ref`, e);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// CORR-03 ref resolution.
|
|
313
|
+
if (entry.ref && entry.source !== "domain") {
|
|
314
|
+
const ref = entry.ref;
|
|
315
|
+
if (entry.source === "req" && !reqIds.has(ref)) {
|
|
316
|
+
add(
|
|
317
|
+
"CORR-03",
|
|
318
|
+
"error",
|
|
319
|
+
reqDoc.path
|
|
320
|
+
? `${entry.id}: requirement ${ref} is not declared in ${reqDoc.path}`
|
|
321
|
+
: `${entry.id}: requirement ${ref} cannot resolve — no compass doc has <document-id>requirements</document-id>`,
|
|
322
|
+
{ ...e, ref },
|
|
323
|
+
);
|
|
324
|
+
} else if (entry.source === "dna" && !dnaSet.has(ref)) {
|
|
325
|
+
add(
|
|
326
|
+
"CORR-03",
|
|
327
|
+
"error",
|
|
328
|
+
`${entry.id}: ${ref} is not declared in ${settings.invariantsFile ?? "bindings.paths.invariantsFile (unset)"}`,
|
|
329
|
+
{ ...e, ref },
|
|
330
|
+
);
|
|
331
|
+
} else if (entry.source === "rfc-ac" || entry.source === "fixed-input") {
|
|
332
|
+
const res = resolveRfcRef(
|
|
333
|
+
workspaceRoot,
|
|
334
|
+
settings.rfcsDir,
|
|
335
|
+
ref,
|
|
336
|
+
entry.source === "rfc-ac" ? "AC" : "FI",
|
|
337
|
+
);
|
|
338
|
+
if (!res.ok) add("CORR-03", "error", `${entry.id}: ${res.reason}`, { ...e, ref });
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// CORR-04 anchors.
|
|
343
|
+
const bound = new Set<string>();
|
|
344
|
+
for (const anchorId of entry.anchors) {
|
|
345
|
+
const records = anchorIndex?.anchors.get(anchorId) ?? [];
|
|
346
|
+
if (records.length === 0) {
|
|
347
|
+
add(
|
|
348
|
+
"CORR-04",
|
|
349
|
+
"error",
|
|
350
|
+
`${entry.id}: anchor ${anchorId} is declared by no @ai-invariant[${anchorId}] in the repository`,
|
|
351
|
+
e,
|
|
352
|
+
);
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
const refs = records.flatMap((r) => r.checkedBy);
|
|
356
|
+
if (refs.length === 0) {
|
|
357
|
+
add(
|
|
358
|
+
"CORR-04",
|
|
359
|
+
"error",
|
|
360
|
+
`${entry.id}: anchor ${anchorId} (${records[0]!.file}:${records[0]!.line}) has no checked-by binding`,
|
|
361
|
+
e,
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
for (const r of refs) bound.add(r);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// CORR-05 oracle ↔ checked-by.
|
|
368
|
+
for (const oracle of entry.oracles) {
|
|
369
|
+
const kind = oracle.check.includes(":")
|
|
370
|
+
? oracle.check.slice(0, oracle.check.indexOf(":")).trim()
|
|
371
|
+
: "";
|
|
372
|
+
if (!BINDING_KINDS.has(kind as never)) {
|
|
373
|
+
add(
|
|
374
|
+
"CORR-05",
|
|
375
|
+
"error",
|
|
376
|
+
`${entry.id}: oracle check "${oracle.check}" is not an RFC-1390 binding reference (test:, type:, lint:, proof:)`,
|
|
377
|
+
e,
|
|
378
|
+
);
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
if (!bound.has(normalizeCheckRef(oracle.check))) {
|
|
382
|
+
add(
|
|
383
|
+
"CORR-05",
|
|
384
|
+
"error",
|
|
385
|
+
`${entry.id}: oracle ${oracle.check} is not named in the checked-by binding of any anchor of the entry (${entry.anchors.join(", ")})`,
|
|
386
|
+
e,
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// CORR-07 captures (provider entries) and CORR-06 substrate.
|
|
392
|
+
const captureOk = new Map<CorrectnessOracle, boolean>();
|
|
393
|
+
if (entry.seam === "provider") {
|
|
394
|
+
for (const oracle of entry.oracles) {
|
|
395
|
+
let allOk = (oracle.captures ?? []).length > 0;
|
|
396
|
+
for (const capture of oracle.captures ?? []) {
|
|
397
|
+
const status = evaluateCapture(workspaceRoot, capture, now);
|
|
398
|
+
if (!status.ok) {
|
|
399
|
+
allOk = false;
|
|
400
|
+
add("CORR-07", "error", `${entry.id}: ${status.problem}`, e);
|
|
401
|
+
} else if (status.expiringSoon) {
|
|
402
|
+
add(
|
|
403
|
+
"CORR-07",
|
|
404
|
+
"warning",
|
|
405
|
+
`${entry.id}: capture ${status.capture} expires within ${CAPTURE_EXPIRY_WARNING_DAYS} days — schedule a refresh`,
|
|
406
|
+
e,
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
captureOk.set(oracle, allOk);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const minimum = SEAM_MINIMUM[entry.seam];
|
|
414
|
+
const effective = (o: CorrectnessOracle): Substrate | null => {
|
|
415
|
+
if (entry.seam !== "provider") return o.substrate;
|
|
416
|
+
if (o.substrate === "L3") return "L3";
|
|
417
|
+
if ((o.substrate === "L1" || o.substrate === "L2") && captureOk.get(o)) return "L3";
|
|
418
|
+
return null;
|
|
419
|
+
};
|
|
420
|
+
const best = entry.oracles
|
|
421
|
+
.map((o) => effective(o))
|
|
422
|
+
.filter((l): l is Substrate => l !== null)
|
|
423
|
+
.sort((a, b) => substrateRank(b) - substrateRank(a))[0];
|
|
424
|
+
const bestDeclared = [...entry.oracles].sort(
|
|
425
|
+
(a, b) => substrateRank(b.substrate) - substrateRank(a.substrate),
|
|
426
|
+
)[0]!.substrate;
|
|
427
|
+
if (
|
|
428
|
+
entry.seam !== "other" &&
|
|
429
|
+
(best === undefined || substrateRank(best) < substrateRank(minimum))
|
|
430
|
+
) {
|
|
431
|
+
add(
|
|
432
|
+
"CORR-06",
|
|
433
|
+
"error",
|
|
434
|
+
entry.seam === "provider"
|
|
435
|
+
? `${entry.id}: seam provider requires L3, or L1/L2 with a fresh capture; best oracle is ${bestDeclared}${bestDeclared === "L0" ? "" : " without a valid capture"}`
|
|
436
|
+
: `${entry.id}: seam ${entry.seam} requires ${minimum}; best oracle is ${bestDeclared}`,
|
|
437
|
+
e,
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// CORR-09 exemptions.
|
|
443
|
+
for (const ex of exemptions) {
|
|
444
|
+
if (ex.kind === "unverifiable" && !ex.reason?.trim()) {
|
|
445
|
+
add("CORR-09", "error", `exemption ${ex.ref}: unverifiable needs a reason`, {
|
|
446
|
+
ref: ex.ref,
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
if (ex.kind === "deferred" && !ex.task?.trim()) {
|
|
450
|
+
add("CORR-09", "error", `exemption ${ex.ref}: deferred needs a task`, { ref: ex.ref });
|
|
451
|
+
}
|
|
452
|
+
if (!reqIds.has(ex.ref) && !dnaSet.has(ex.ref)) {
|
|
453
|
+
add("CORR-09", "error", `exemption ${ex.ref} resolves to no requirement id or DNA id`, {
|
|
454
|
+
ref: ex.ref,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// ── CORR-08 coverage ─────────────────────────────────────────────────────
|
|
461
|
+
const anchoredReq = new Set(
|
|
462
|
+
entries.filter((x) => x.source === "req" && x.ref).map((x) => x.ref!),
|
|
463
|
+
);
|
|
464
|
+
const anchoredDna = new Set(
|
|
465
|
+
entries.filter((x) => x.source === "dna" && x.ref).map((x) => x.ref!),
|
|
466
|
+
);
|
|
467
|
+
const exempted = new Set(exemptions.map((x) => x.ref));
|
|
468
|
+
const coverageOf = (ids: string[], anchored: Set<string>, label: string): CoverageCounts => {
|
|
469
|
+
const counts = { total: ids.length, anchored: 0, exempt: 0, silent: 0 };
|
|
470
|
+
for (const id of ids) {
|
|
471
|
+
if (anchored.has(id)) counts.anchored += 1;
|
|
472
|
+
else if (exempted.has(id)) counts.exempt += 1;
|
|
473
|
+
else {
|
|
474
|
+
counts.silent += 1;
|
|
475
|
+
add("CORR-08", gated, `${label} ${id} has no manifest entry and no exemption`, { ref: id });
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return counts;
|
|
479
|
+
};
|
|
480
|
+
if (!reqDoc.path) {
|
|
481
|
+
add(
|
|
482
|
+
"CORR-08",
|
|
483
|
+
"warning",
|
|
484
|
+
"no compass requirements document — none of bindings.paths.compassDocs has <document-id>requirements</document-id> (expected docs/requirements.xml)",
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
const coverage = {
|
|
488
|
+
req: coverageOf(reqDoc.ids, anchoredReq, "requirement"),
|
|
489
|
+
dna: coverageOf(dnaIds, anchoredDna, "DNA"),
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
return result(violations.some((v) => v.severity === "error") ? "fail" : "pass", coverage);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export async function runCorrectnessManifestValidate(
|
|
496
|
+
_input: ForgeCommandInput,
|
|
497
|
+
context: ForgeRuntimeContext,
|
|
498
|
+
): Promise<ForgeCommandResult<CorrectnessValidateResult>> {
|
|
499
|
+
const data = await validateCorrectnessManifest(context.workspaceRoot);
|
|
500
|
+
const errors = data.violations.filter((v) => v.severity === "error").length;
|
|
501
|
+
const warnings = data.violations.length - errors;
|
|
502
|
+
if (context.outputFormat === "pretty") {
|
|
503
|
+
for (const v of data.violations) {
|
|
504
|
+
const line = `${v.rule} ${v.message}`;
|
|
505
|
+
if (v.severity === "error") context.logger.error(line);
|
|
506
|
+
else context.logger.warn(line);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
const summary =
|
|
510
|
+
data.status === "exempt"
|
|
511
|
+
? "correctness.manifest.validate: exempt (correctness.mode: exempt — layer A does not apply)"
|
|
512
|
+
: `correctness.manifest.validate: ${data.status} (mode ${data.mode}, ${errors} error(s), ${warnings} warning(s); req ${data.coverage.req.anchored}/${data.coverage.req.total} anchored, dna ${data.coverage.dna.anchored}/${data.coverage.dna.total} anchored)`;
|
|
513
|
+
return { data, summary, exitCode: data.status === "fail" ? 1 : 0 };
|
|
514
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>Public surface of the forge correctness contour (RFC-1578): module
|
|
4
|
+
factory, manifest contracts, and the validator core.</purpose>
|
|
5
|
+
<non-goals>
|
|
6
|
+
<item>No logic — re-exports only.</item>
|
|
7
|
+
</non-goals>
|
|
8
|
+
</MODULE_CONTRACT>
|
|
9
|
+
<CHANGE_SUMMARY>
|
|
10
|
+
<item>RFC-1578: initial exports.</item>
|
|
11
|
+
<item>RFC-1579: correctness.audit core for the werkstatt ecosystem.commit early run.</item>
|
|
12
|
+
<item>RFC-1578: correctness manifest, validator, promotes gate
|
|
13
|
+
|
|
14
|
+
Add os/correctness (forge/correctness-manifest@1, correctness.manifest.validate CORR-01..09), bindings.paths.correctnessManifest, bindings.commands.checkRun and the correctness section, promotes with V-55 and RFC-IMP-16, the typescript profile skeleton, reference pages, and the promotes marking in fo-idea-create-rfc/fo-idea-audit. Repoint the RFC-1391 AC-8 registry test at src/command-modules.ts (stale since RFC-1573) and close the types.ts header comment without a glob-shaped terminator (EC-33).</item>
|
|
15
|
+
</CHANGE_SUMMARY>
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export { createForgeCorrectnessModule } from "./correctness.module.ts";
|
|
19
|
+
export * from "./manifest-schema.ts";
|
|
20
|
+
export { validateCorrectnessManifest, evaluateCapture } from "./handlers/validate.ts";
|
|
21
|
+
export { readCorrectnessSettings, normalizeCheckRef, normalizeRelPath } from "./workspace.ts";
|
|
22
|
+
export { runCorrectnessAudit, type AuditOptions, type AuditOutcome } from "./audit/run.ts";
|
|
23
|
+
export { isAuditRelevant } from "./audit/snapshot.ts";
|
|
24
|
+
export type { AuditFinding, AuditResult, AuditCheckId } from "./audit/types.ts";
|