@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,105 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1579 differential attribution — findings are keyed by
|
|
4
|
+
`sha256(check + "\0" + subject)` with an occurrence count; a code finding is
|
|
5
|
+
`introduced` when its key is new or its count grew since the base revision,
|
|
6
|
+
`legacy` when present at base with an equal or higher count, `resolved` when
|
|
7
|
+
present at base only. Configuration findings (CORR-AUDIT-04) are always
|
|
8
|
+
`introduced`. Allow-listed findings (`correctness.audit.allow[]`) are
|
|
9
|
+
`accepted`.</purpose>
|
|
10
|
+
<non-goals>
|
|
11
|
+
<item>No line-based attribution — subject keys are immune to line shifts.</item>
|
|
12
|
+
<item>No exit-code decisions — run.ts derives status from introduced errors only.</item>
|
|
13
|
+
</non-goals>
|
|
14
|
+
</MODULE_CONTRACT>
|
|
15
|
+
<CHANGE_SUMMARY>
|
|
16
|
+
<item>RFC-1579: initial attribution.</item>
|
|
17
|
+
<item>RFC-1579: correctness.audit auditors and differential attribution
|
|
18
|
+
|
|
19
|
+
Add os/correctness/audit: tree snapshots (working tree, index, base via one cat-file batch with git-grep prefilter), literal scanner + SQL classifier, wrangler D1 schema builder on node:sqlite, the four auditors (sql.schema.conform, ledger.orphans, state.transitions.coverage, bindings.verify.substance), subject-keyed differential attribution with allow-list, survival ledger, the correctness.audit handler and registration, and bindings.paths.correctnessLedger.</item>
|
|
20
|
+
<item>RFC-1579: close review REVIEW-CODE-2026-11-13-01 findings
|
|
21
|
+
|
|
22
|
+
F1 INSERT 'has no column named' is a finding; F2 severity/kind escalation since base is introduced; F3 unparseable machine tables are errors; F4 comma joins, string literals and comments in table extraction; F5 only migration INSERT/REPLACE seed writes; F6 SET-clause-only coverage; F7 method-call writers; F8 regex literals in the scanner; F9 alias resolution; F10 EC-34 judges the payload only; F11 EC-34 before the scoped gates with a dry-run line; F12/F13 config and YAML errors named; F14 config-only check skips snapshots; F15 git grep failures fail closed; F16 portable prefilter; F17 shell no-ops; F18 shared D1 schemas; in-code DDL scoped per package; ledger tests. DEV-1..DEV-4 recorded in the RFC Deviations section.</item>
|
|
23
|
+
</CHANGE_SUMMARY>
|
|
24
|
+
*/
|
|
25
|
+
import { createHash } from "node:crypto";
|
|
26
|
+
import { AUDIT_RULE_OF, CODE_CHECKS, } from "./types.js";
|
|
27
|
+
const SEVERITY_RANK = { info: 0, warning: 1, error: 2 };
|
|
28
|
+
export function findingKey(check, subject) {
|
|
29
|
+
return createHash("sha256").update(`${check}\0${subject}`).digest("hex");
|
|
30
|
+
}
|
|
31
|
+
function group(findings) {
|
|
32
|
+
const out = new Map();
|
|
33
|
+
for (const f of findings) {
|
|
34
|
+
const key = findingKey(f.check, f.subject);
|
|
35
|
+
const g = out.get(key);
|
|
36
|
+
if (g)
|
|
37
|
+
g.count += 1;
|
|
38
|
+
else
|
|
39
|
+
out.set(key, { first: f, count: 1 });
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
function toFinding(key, g, attribution) {
|
|
44
|
+
return {
|
|
45
|
+
rule: AUDIT_RULE_OF[g.first.check],
|
|
46
|
+
check: g.first.check,
|
|
47
|
+
key,
|
|
48
|
+
subject: g.first.subject,
|
|
49
|
+
occurrences: g.count,
|
|
50
|
+
severity: g.first.severity,
|
|
51
|
+
attribution,
|
|
52
|
+
...(g.first.location ? { location: g.first.location } : {}),
|
|
53
|
+
message: g.first.message,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Attribute `now` findings against `base` findings (code checks) and apply the allow-list. */
|
|
57
|
+
export function attribute(base, now, allow) {
|
|
58
|
+
const allowed = new Set(allow.map((a) => findingKey(a.check, a.subject)));
|
|
59
|
+
const baseCode = group(base.filter((f) => CODE_CHECKS.has(f.check)));
|
|
60
|
+
const nowGroups = group(now);
|
|
61
|
+
const out = [];
|
|
62
|
+
for (const [key, g] of nowGroups) {
|
|
63
|
+
let attribution;
|
|
64
|
+
if (!CODE_CHECKS.has(g.first.check))
|
|
65
|
+
attribution = "introduced";
|
|
66
|
+
else {
|
|
67
|
+
const prior = baseCode.get(key);
|
|
68
|
+
// A finding is legacy only when the base already had it at the same or a
|
|
69
|
+
// higher count AND the same or a higher severity with the same message
|
|
70
|
+
// kind (untouched warning → written-never-read error is introduced).
|
|
71
|
+
const kindOf = (f) => f.message.split(":")[0];
|
|
72
|
+
attribution =
|
|
73
|
+
prior &&
|
|
74
|
+
prior.count >= g.count &&
|
|
75
|
+
SEVERITY_RANK[prior.first.severity] >= SEVERITY_RANK[g.first.severity] &&
|
|
76
|
+
kindOf(prior.first) === kindOf(g.first)
|
|
77
|
+
? "legacy"
|
|
78
|
+
: "introduced";
|
|
79
|
+
}
|
|
80
|
+
if (allowed.has(key))
|
|
81
|
+
attribution = "accepted";
|
|
82
|
+
out.push(toFinding(key, g, attribution));
|
|
83
|
+
}
|
|
84
|
+
for (const [key, g] of baseCode) {
|
|
85
|
+
if (!nowGroups.has(key))
|
|
86
|
+
out.push(toFinding(key, g, "resolved"));
|
|
87
|
+
}
|
|
88
|
+
const order = { introduced: 0, accepted: 1, legacy: 2, resolved: 3 };
|
|
89
|
+
return out.sort((a, b) => order[a.attribution] - order[b.attribution] ||
|
|
90
|
+
a.check.localeCompare(b.check) ||
|
|
91
|
+
a.subject.localeCompare(b.subject));
|
|
92
|
+
}
|
|
93
|
+
/** Parse `correctness.audit.allow[]` from a forge.yaml document object; malformed rows are dropped. */
|
|
94
|
+
export function readAllowList(config) {
|
|
95
|
+
const allow = config?.correctness?.audit
|
|
96
|
+
?.allow;
|
|
97
|
+
if (!Array.isArray(allow))
|
|
98
|
+
return [];
|
|
99
|
+
return allow.filter((a) => !!a &&
|
|
100
|
+
typeof a.check === "string" &&
|
|
101
|
+
typeof a.subject === "string" &&
|
|
102
|
+
typeof a.reason === "string" &&
|
|
103
|
+
a.reason.trim().length > 0);
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=differential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"differential.js","sourceRoot":"","sources":["../../../../os/correctness/audit/differential.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AAEF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,aAAa,EACb,WAAW,GAIZ,MAAM,YAAY,CAAC;AAEpB,MAAM,aAAa,GAA2C,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAEhG,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,OAAe;IACvD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,KAAK,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3E,CAAC;AAOD,SAAS,KAAK,CAAC,QAAsB;IACnC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAmB,CAAC;IACvC,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;QAC3C,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC;YAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;;YACf,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,SAAS,CAChB,GAAW,EACX,CAAU,EACV,WAAwC;IAExC,OAAO;QACL,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;QAClC,KAAK,EAAE,CAAC,CAAC,KA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AAC;QAC9B,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CACrC,CAAC;AACJ,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,aAAa,CAAC,MAAe;IAC3C,MAAM,KAAK,GAAI,MAA4D,EAAE,WAAW,EAAE,KAAK;QAC7F,EAAE,KAAK,CAAC;IACV,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,OAAO,KAAK,CAAC,MAAM,CACjB,CAAC,CAAC,EAAmB,EAAE,CACrB,CAAC,CAAC,CAAC;QACH,OAAQ,CAAgB,CAAC,KAAK,KAAK,QAAQ;QAC3C,OAAQ,CAAgB,CAAC,OAAO,KAAK,QAAQ;QAC7C,OAAQ,CAAgB,CAAC,MAAM,KAAK,QAAQ;QAC3C,CAAgB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SchemaDiscovery } from "./schema-db.ts";
|
|
2
|
+
import { type SqlStatement } from "./sql-scanner.ts";
|
|
3
|
+
import type { TreeSnapshot } from "./snapshot.ts";
|
|
4
|
+
import type { AuditorOutput } from "./types.ts";
|
|
5
|
+
export declare function auditLedgerOrphans(discovery: SchemaDiscovery, statements: SqlStatement[], snapshot: TreeSnapshot): AuditorOutput;
|
|
6
|
+
//# sourceMappingURL=ledger-orphans.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-orphans.d.ts","sourceRoot":"","sources":["../../../../os/correctness/audit/ledger-orphans.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,YAAY,CAAC;AAE5D,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,eAAe,EAC1B,UAAU,EAAE,YAAY,EAAE,EAC1B,QAAQ,EAAE,YAAY,GACrB,aAAa,CAoDf"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1579 CORR-AUDIT-02 `ledger.orphans` — every table a D1 schema
|
|
4
|
+
declares needs both a writer and a reader among the code statements
|
|
5
|
+
(migration INSERTs count as writes): `read-never-written` and
|
|
6
|
+
`written-never-read` are errors, `untouched` (declared, never read or
|
|
7
|
+
written) is a warning so a migration-first change does not block.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>No allow-list decisions — differential.ts applies `correctness.audit.allow[]`.</item>
|
|
10
|
+
</non-goals>
|
|
11
|
+
</MODULE_CONTRACT>
|
|
12
|
+
<CHANGE_SUMMARY>
|
|
13
|
+
<item>RFC-1579: initial auditor.</item>
|
|
14
|
+
<item>RFC-1579: correctness.audit auditors and differential attribution
|
|
15
|
+
|
|
16
|
+
Add os/correctness/audit: tree snapshots (working tree, index, base via one cat-file batch with git-grep prefilter), literal scanner + SQL classifier, wrangler D1 schema builder on node:sqlite, the four auditors (sql.schema.conform, ledger.orphans, state.transitions.coverage, bindings.verify.substance), subject-keyed differential attribution with allow-list, survival ledger, the correctness.audit handler and registration, and bindings.paths.correctnessLedger.</item>
|
|
17
|
+
<item>RFC-1579: close review REVIEW-CODE-2026-11-13-01 findings
|
|
18
|
+
|
|
19
|
+
F1 INSERT 'has no column named' is a finding; F2 severity/kind escalation since base is introduced; F3 unparseable machine tables are errors; F4 comma joins, string literals and comments in table extraction; F5 only migration INSERT/REPLACE seed writes; F6 SET-clause-only coverage; F7 method-call writers; F8 regex literals in the scanner; F9 alias resolution; F10 EC-34 judges the payload only; F11 EC-34 before the scoped gates with a dry-run line; F12/F13 config and YAML errors named; F14 config-only check skips snapshots; F15 git grep failures fail closed; F16 portable prefilter; F17 shell no-ops; F18 shared D1 schemas; in-code DDL scoped per package; ledger tests. DEV-1..DEV-4 recorded in the RFC Deviations section.</item>
|
|
20
|
+
</CHANGE_SUMMARY>
|
|
21
|
+
*/
|
|
22
|
+
import { tableAccess } from "./sql-scanner.js";
|
|
23
|
+
export function auditLedgerOrphans(discovery, statements, snapshot) {
|
|
24
|
+
const findings = [];
|
|
25
|
+
const declared = new Map(); // table → first migration declaring it
|
|
26
|
+
for (const schema of discovery.schemas) {
|
|
27
|
+
for (const t of schema.tables) {
|
|
28
|
+
if (declared.has(t))
|
|
29
|
+
continue;
|
|
30
|
+
const decl = schema.migrations.find((m) => new RegExp(`CREATE\\s+TABLE\\s+(?:IF\\s+NOT\\s+EXISTS\\s+)?["\`[]?${t}\\b`, "i").test(snapshot.files.get(m) ?? ""));
|
|
31
|
+
declared.set(t, decl ?? schema.configFile);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const reads = new Set();
|
|
35
|
+
const writes = new Set();
|
|
36
|
+
for (const st of statements) {
|
|
37
|
+
const access = tableAccess(st.sql);
|
|
38
|
+
access.reads.forEach((t) => reads.add(t));
|
|
39
|
+
access.writes.forEach((t) => writes.add(t));
|
|
40
|
+
}
|
|
41
|
+
for (const schema of discovery.schemas) {
|
|
42
|
+
for (const m of schema.migrations) {
|
|
43
|
+
// Only seeding INSERT/REPLACE targets count from migrations; DDL-time
|
|
44
|
+
// UPDATE/DELETE/SELECT are neither writers nor readers of the ledger.
|
|
45
|
+
const sql = snapshot.files.get(m) ?? "";
|
|
46
|
+
for (const seed of sql.matchAll(/\b(?:INSERT\s+(?:OR\s+[A-Za-z]+\s+)?INTO|REPLACE\s+INTO)\s+["`[]?([A-Za-z_][A-Za-z0-9_]*)/gi)) {
|
|
47
|
+
writes.add(seed[1].toLowerCase());
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
for (const [table, source] of [...declared.entries()].sort()) {
|
|
52
|
+
const r = reads.has(table);
|
|
53
|
+
const w = writes.has(table);
|
|
54
|
+
if (r && w)
|
|
55
|
+
continue;
|
|
56
|
+
const kind = r ? "read-never-written" : w ? "written-never-read" : "untouched";
|
|
57
|
+
findings.push({
|
|
58
|
+
check: "ledger.orphans",
|
|
59
|
+
subject: table,
|
|
60
|
+
severity: kind === "untouched" ? "warning" : "error",
|
|
61
|
+
message: kind === "untouched"
|
|
62
|
+
? `untouched: declared in ${source}, no statement reads or writes it`
|
|
63
|
+
: kind === "read-never-written"
|
|
64
|
+
? `read-never-written: statements read ${table} but nothing writes it (declared in ${source})`
|
|
65
|
+
: `written-never-read: statements write ${table} but nothing reads it (declared in ${source})`,
|
|
66
|
+
location: { file: source, line: 1 },
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return { findings, unverifiable: 0, skipped: [] };
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=ledger-orphans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-orphans.js","sourceRoot":"","sources":["../../../../os/correctness/audit/ledger-orphans.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;EAoBE;AAGF,OAAO,EAAE,WAAW,EAAqB,MAAM,kBAAkB,CAAC;AAIlE,MAAM,UAAU,kBAAkB,CAChC,SAA0B,EAC1B,UAA0B,EAC1B,QAAsB;IAEtB,MAAM,QAAQ,GAAiB,EAAE,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC,CAAC,uCAAuC;IACnF,KAAK,MAAM,MAAM,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;QACvC,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAC9B,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;gBAAE,SAAS;YAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAA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AAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7D,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC;YAAE,SAAS;QACrB,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC;QAC/E,QAAQ,CAAC,IAAI,CAAC;YACZ,KAAK,EAAE,gBAAgB;YACvB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;YACpD,OAAO,EACL,IAAI,KAAK,WAAW;gBAClB,CAAC,CAAC,0BAA0B,MAAM,mCAAmC;gBACrE,CAAC,CAAC,IAAI,KAAK,oBAAoB;oBAC7B,CAAC,CAAC,uCAAuC,KAAK,uCAAuC,MAAM,GAAG;oBAC9F,CAAC,CAAC,wCAAwC,KAAK,sCAAsC,MAAM,GAAG;YACpG,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AuditFinding } from "./types.ts";
|
|
2
|
+
export declare const LEDGER_SCHEMA: "forge/correctness-ledger@1";
|
|
3
|
+
export declare const DEFAULT_LEDGER_PATH = "docs/maintenance-debt/correctness.ledger.yaml";
|
|
4
|
+
export interface LedgerStamp {
|
|
5
|
+
sha: string;
|
|
6
|
+
date: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LedgerRow {
|
|
9
|
+
key: string;
|
|
10
|
+
check: string;
|
|
11
|
+
subject: string;
|
|
12
|
+
firstSeen: LedgerStamp;
|
|
13
|
+
lastSeen: LedgerStamp;
|
|
14
|
+
status: "surviving" | "resolved";
|
|
15
|
+
}
|
|
16
|
+
export interface Ledger {
|
|
17
|
+
schema: typeof LEDGER_SCHEMA;
|
|
18
|
+
rows: LedgerRow[];
|
|
19
|
+
}
|
|
20
|
+
export declare function parseLedger(text: string | null): Ledger;
|
|
21
|
+
/**
|
|
22
|
+
* Merge the current findings into the ledger: every current legacy/accepted
|
|
23
|
+
* code finding is `surviving` with `lastSeen` = now (its `firstSeen` kept or
|
|
24
|
+
* set to now); rows no longer present become `resolved` (their `lastSeen`
|
|
25
|
+
* keeps the last revision that still had them).
|
|
26
|
+
*/
|
|
27
|
+
export declare function mergeLedger(previous: Ledger, findings: AuditFinding[], stamp: LedgerStamp): Ledger;
|
|
28
|
+
export declare function serializeLedger(ledger: Ledger): string;
|
|
29
|
+
//# sourceMappingURL=ledger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../../../os/correctness/audit/ledger.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,eAAO,MAAM,aAAa,EAAG,4BAAqC,CAAC;AACnE,eAAO,MAAM,mBAAmB,kDAAkD,CAAC;AAEnF,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,WAAW,CAAC;IACvB,QAAQ,EAAE,WAAW,CAAC;IACtB,MAAM,EAAE,WAAW,GAAG,UAAU,CAAC;CAClC;AAED,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,OAAO,aAAa,CAAC;IAC7B,IAAI,EAAE,SAAS,EAAE,CAAC;CACnB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAWvD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,YAAY,EAAE,EACxB,KAAK,EAAE,WAAW,GACjB,MAAM,CA2BR;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKtD"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1579 survival ledger — one row per legacy or accepted code
|
|
4
|
+
finding (`key`, `check`, `subject`, `firstSeen`/`lastSeen` as `{sha, date}`,
|
|
5
|
+
`status: surviving | resolved`) at `bindings.paths.correctnessLedger`.
|
|
6
|
+
It measures how long accepted debt survives; nothing gates on it.</purpose>
|
|
7
|
+
<non-goals>
|
|
8
|
+
<item>Never written by a gate — only `correctness.audit --write-ledger`.</item>
|
|
9
|
+
<item>No werkstatt-site maintenance-debt baseline reuse — consumers do not ship werkstatt-site.</item>
|
|
10
|
+
</non-goals>
|
|
11
|
+
</MODULE_CONTRACT>
|
|
12
|
+
<CHANGE_SUMMARY>
|
|
13
|
+
<item>RFC-1579: initial ledger merge and serialization.</item>
|
|
14
|
+
<item>RFC-1579: correctness.audit auditors and differential attribution
|
|
15
|
+
|
|
16
|
+
Add os/correctness/audit: tree snapshots (working tree, index, base via one cat-file batch with git-grep prefilter), literal scanner + SQL classifier, wrangler D1 schema builder on node:sqlite, the four auditors (sql.schema.conform, ledger.orphans, state.transitions.coverage, bindings.verify.substance), subject-keyed differential attribution with allow-list, survival ledger, the correctness.audit handler and registration, and bindings.paths.correctnessLedger.</item>
|
|
17
|
+
</CHANGE_SUMMARY>
|
|
18
|
+
*/
|
|
19
|
+
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
20
|
+
export const LEDGER_SCHEMA = "forge/correctness-ledger@1";
|
|
21
|
+
export const DEFAULT_LEDGER_PATH = "docs/maintenance-debt/correctness.ledger.yaml";
|
|
22
|
+
export function parseLedger(text) {
|
|
23
|
+
if (!text)
|
|
24
|
+
return { schema: LEDGER_SCHEMA, rows: [] };
|
|
25
|
+
try {
|
|
26
|
+
const doc = parseYaml(text);
|
|
27
|
+
const rows = Array.isArray(doc?.rows)
|
|
28
|
+
? doc.rows.filter((r) => r && typeof r.key === "string")
|
|
29
|
+
: [];
|
|
30
|
+
return { schema: LEDGER_SCHEMA, rows };
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return { schema: LEDGER_SCHEMA, rows: [] };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Merge the current findings into the ledger: every current legacy/accepted
|
|
38
|
+
* code finding is `surviving` with `lastSeen` = now (its `firstSeen` kept or
|
|
39
|
+
* set to now); rows no longer present become `resolved` (their `lastSeen`
|
|
40
|
+
* keeps the last revision that still had them).
|
|
41
|
+
*/
|
|
42
|
+
export function mergeLedger(previous, findings, stamp) {
|
|
43
|
+
const current = findings.filter((f) => f.check !== "bindings.verify.substance" &&
|
|
44
|
+
(f.attribution === "legacy" || f.attribution === "accepted"));
|
|
45
|
+
const byKey = new Map(previous.rows.map((r) => [r.key, r]));
|
|
46
|
+
const rows = [];
|
|
47
|
+
const seen = new Set();
|
|
48
|
+
for (const f of current) {
|
|
49
|
+
const prior = byKey.get(f.key);
|
|
50
|
+
rows.push({
|
|
51
|
+
key: f.key,
|
|
52
|
+
check: f.check,
|
|
53
|
+
subject: f.subject,
|
|
54
|
+
firstSeen: prior?.firstSeen ?? stamp,
|
|
55
|
+
lastSeen: stamp,
|
|
56
|
+
status: "surviving",
|
|
57
|
+
});
|
|
58
|
+
seen.add(f.key);
|
|
59
|
+
}
|
|
60
|
+
for (const r of previous.rows) {
|
|
61
|
+
if (seen.has(r.key))
|
|
62
|
+
continue;
|
|
63
|
+
rows.push({ ...r, status: "resolved" });
|
|
64
|
+
}
|
|
65
|
+
rows.sort((a, b) => a.check.localeCompare(b.check) || a.subject.localeCompare(b.subject));
|
|
66
|
+
return { schema: LEDGER_SCHEMA, rows };
|
|
67
|
+
}
|
|
68
|
+
export function serializeLedger(ledger) {
|
|
69
|
+
return ("# GENERATED by `forge correctness.audit --write-ledger` (RFC-1579) — survival of accepted correctness debt.\n" +
|
|
70
|
+
stringifyYaml(ledger));
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../../os/correctness/audit/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;EAiBE;AAEF,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,MAAM,CAAC;AAItE,MAAM,CAAC,MAAM,aAAa,GAAG,4BAAqC,CAAC;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,+CAA+C,CAAC;AAqBnF,MAAM,UAAU,WAAW,CAAC,IAAmB;IAC7C,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IACtD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAuB,CAAC;QAClD,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC;YACnC,CAAC,CAAE,GAAG,CAAC,IAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,KAAK,QAAQ,CAAC;YACzE,CAAC,CAAC,EAAE,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,EAAE,CAAC;QAC9B,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YAAE,SAAS;QAC9B,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1F,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,CACL,+GAA+G;QAC/G,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type TreeSnapshot } from "./snapshot.ts";
|
|
2
|
+
import { type AuditCheckId, type AuditResult, type RawFinding } from "./types.ts";
|
|
3
|
+
export interface AuditOptions {
|
|
4
|
+
/** Revision to compare against; default: HEAD with --staged, else merge-base with develop. */
|
|
5
|
+
base?: string;
|
|
6
|
+
/** Judge the staged index instead of the working tree. */
|
|
7
|
+
staged?: boolean;
|
|
8
|
+
/** Run one auditor only. */
|
|
9
|
+
check?: AuditCheckId;
|
|
10
|
+
}
|
|
11
|
+
export type AuditOutcome = {
|
|
12
|
+
ok: true;
|
|
13
|
+
result: AuditResult;
|
|
14
|
+
} | {
|
|
15
|
+
ok: false;
|
|
16
|
+
usageError: string;
|
|
17
|
+
};
|
|
18
|
+
interface CodePass {
|
|
19
|
+
findings: RawFinding[];
|
|
20
|
+
unverifiable: number;
|
|
21
|
+
skipped: string[];
|
|
22
|
+
}
|
|
23
|
+
/** Run the code auditors (1–3) over one snapshot. */
|
|
24
|
+
export declare function runCodeAuditors(snapshot: TreeSnapshot, only?: AuditCheckId): CodePass;
|
|
25
|
+
export declare function runCorrectnessAudit(workspaceRoot: string, options?: AuditOptions): Promise<AuditOutcome>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../../os/correctness/audit/run.ts"],"names":[],"mappings":"AAwCA,OAAO,EAML,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAmB,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAEnG,MAAM,WAAW,YAAY;IAC3B,8FAA8F;IAC9F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,4BAA4B;IAC5B,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjG,UAAU,QAAQ;IAChB,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAwBD,qDAAqD;AACrD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAoCrF;AAUD,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,YAAY,CAAC,CA+EvB"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1579 orchestration of `correctness.audit` — resolve the base
|
|
4
|
+
revision, load the base and judged snapshots (working tree or staged index),
|
|
5
|
+
run the code auditors on both and the configuration auditor on the judged
|
|
6
|
+
tree, attribute findings differentially, apply the allow-list, and derive
|
|
7
|
+
the status (fail only on introduced errors).</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>No writes — the ledger writer lives in the handler behind --write-ledger.</item>
|
|
10
|
+
<item>No manifest validation or oracle freeze — RFC-1578 / RFC-1580.</item>
|
|
11
|
+
</non-goals>
|
|
12
|
+
</MODULE_CONTRACT>
|
|
13
|
+
<CHANGE_SUMMARY>
|
|
14
|
+
<item>RFC-1579: initial orchestration.</item>
|
|
15
|
+
<item>RFC-1579: correctness.audit auditors and differential attribution
|
|
16
|
+
|
|
17
|
+
Add os/correctness/audit: tree snapshots (working tree, index, base via one cat-file batch with git-grep prefilter), literal scanner + SQL classifier, wrangler D1 schema builder on node:sqlite, the four auditors (sql.schema.conform, ledger.orphans, state.transitions.coverage, bindings.verify.substance), subject-keyed differential attribution with allow-list, survival ledger, the correctness.audit handler and registration, and bindings.paths.correctnessLedger.</item>
|
|
18
|
+
<item>RFC-1579: gate line, ecosystem.commit early run, reference page
|
|
19
|
+
|
|
20
|
+
typescript profile integration-gate.sh runs the primary install's correctness.audit against FLOW_BASE_SHA; werkstatt ecosystem.commit gains EC-34 (correctness.audit --staged, refuses introduced CORR-AUDIT-01..03, warns on CORR-AUDIT-04); in-code CREATE TABLE tables (Durable Object storage) are unverifiable instead of D1 findings; correctness.audit declares generates: []; reference page and agent guides.
|
|
21
|
+
|
|
22
|
+
Measured on werkstatt (rollout step 3): 7 wrangler D1 configs, ~10 s per run, 3 legacy sql.schema.conform findings (packages/warpgogol-billing-cloudflare against schemas outside the repo), 127 unverifiable statements, no state machines; CORR-AUDIT-04 present (verify equals test) — fixed by the werkstatt gate-wiring queue task.</item>
|
|
23
|
+
<item>RFC-1579: close review REVIEW-CODE-2026-11-13-01 findings
|
|
24
|
+
|
|
25
|
+
F1 INSERT 'has no column named' is a finding; F2 severity/kind escalation since base is introduced; F3 unparseable machine tables are errors; F4 comma joins, string literals and comments in table extraction; F5 only migration INSERT/REPLACE seed writes; F6 SET-clause-only coverage; F7 method-call writers; F8 regex literals in the scanner; F9 alias resolution; F10 EC-34 judges the payload only; F11 EC-34 before the scoped gates with a dry-run line; F12/F13 config and YAML errors named; F14 config-only check skips snapshots; F15 git grep failures fail closed; F16 portable prefilter; F17 shell no-ops; F18 shared D1 schemas; in-code DDL scoped per package; ledger tests. DEV-1..DEV-4 recorded in the RFC Deviations section.</item>
|
|
26
|
+
</CHANGE_SUMMARY>
|
|
27
|
+
*/
|
|
28
|
+
import { readFileSync } from "node:fs";
|
|
29
|
+
import path from "node:path";
|
|
30
|
+
import { parse as parseYaml } from "yaml";
|
|
31
|
+
import { createOriginGit } from "../../rfc/verification-origin.js";
|
|
32
|
+
import { auditVerifySubstance } from "./bindings-verify-substance.js";
|
|
33
|
+
import { attribute, readAllowList } from "./differential.js";
|
|
34
|
+
import { auditLedgerOrphans } from "./ledger-orphans.js";
|
|
35
|
+
import { closeSchemas, discoverSchemas } from "./schema-db.js";
|
|
36
|
+
import { auditSqlSchemaConform, inCodeTables } from "./sql-schema-conform.js";
|
|
37
|
+
import { scanLiterals, scanStatements } from "./sql-scanner.js";
|
|
38
|
+
import { defaultBase, isTestFile, loadSnapshot, resolveRevision, } from "./snapshot.js";
|
|
39
|
+
import { auditStateTransitions, declaredWriters } from "./state-transitions-coverage.js";
|
|
40
|
+
import { AUDIT_CHECK_IDS } from "./types.js";
|
|
41
|
+
function statementsOf(snapshot) {
|
|
42
|
+
const out = [];
|
|
43
|
+
for (const [file, text] of snapshot.files) {
|
|
44
|
+
if (!/\.(?:ts|mts|tsx)$/.test(file) || isTestFile(file))
|
|
45
|
+
continue;
|
|
46
|
+
out.push(...scanStatements(file, text));
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
const DDL_RE = /CREATE\s+(?:VIRTUAL\s+)?TABLE/i;
|
|
51
|
+
/** Literal texts carrying in-code DDL (non-test TypeScript only), with their file. */
|
|
52
|
+
function literalTextsOf(snapshot) {
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const [file, text] of snapshot.files) {
|
|
55
|
+
if (!/\.(?:ts|mts|tsx)$/.test(file) || isTestFile(file) || !DDL_RE.test(text))
|
|
56
|
+
continue;
|
|
57
|
+
for (const lit of scanLiterals(text))
|
|
58
|
+
if (DDL_RE.test(lit.text))
|
|
59
|
+
out.push({ file, text: lit.text });
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
/** Run the code auditors (1–3) over one snapshot. */
|
|
64
|
+
export function runCodeAuditors(snapshot, only) {
|
|
65
|
+
const wants = (id) => !only || only === id;
|
|
66
|
+
const pass = { findings: [], unverifiable: 0, skipped: [] };
|
|
67
|
+
if (wants("sql.schema.conform") || wants("ledger.orphans")) {
|
|
68
|
+
const discovery = discoverSchemas(snapshot);
|
|
69
|
+
try {
|
|
70
|
+
for (const u of discovery.unsupported)
|
|
71
|
+
pass.skipped.push(`sql.schema.conform: unsupported-config (${u})`);
|
|
72
|
+
const noD1 = discovery.schemas.length === 0 && discovery.failures.length === 0;
|
|
73
|
+
if (noD1) {
|
|
74
|
+
if (wants("sql.schema.conform"))
|
|
75
|
+
pass.skipped.push("sql.schema.conform: no-d1");
|
|
76
|
+
if (wants("ledger.orphans"))
|
|
77
|
+
pass.skipped.push("ledger.orphans: no-d1");
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const statements = statementsOf(snapshot);
|
|
81
|
+
if (wants("sql.schema.conform")) {
|
|
82
|
+
const r = auditSqlSchemaConform(discovery, statements, inCodeTables(literalTextsOf(snapshot)));
|
|
83
|
+
pass.findings.push(...r.findings);
|
|
84
|
+
pass.unverifiable += r.unverifiable;
|
|
85
|
+
}
|
|
86
|
+
if (wants("ledger.orphans"))
|
|
87
|
+
pass.findings.push(...auditLedgerOrphans(discovery, statements, snapshot).findings);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
closeSchemas(discovery);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (wants("state.transitions.coverage")) {
|
|
95
|
+
const r = auditStateTransitions(snapshot);
|
|
96
|
+
pass.findings.push(...r.findings);
|
|
97
|
+
pass.skipped.push(...r.skipped);
|
|
98
|
+
}
|
|
99
|
+
return pass;
|
|
100
|
+
}
|
|
101
|
+
function forgeDoc(snapshot) {
|
|
102
|
+
try {
|
|
103
|
+
return parseYaml(snapshot.files.get("forge.yaml") ?? "") ?? {};
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return {};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export async function runCorrectnessAudit(workspaceRoot, options = {}) {
|
|
110
|
+
if (options.check && !AUDIT_CHECK_IDS.includes(options.check)) {
|
|
111
|
+
return {
|
|
112
|
+
ok: false,
|
|
113
|
+
usageError: `--check ${options.check} is not an auditor (${AUDIT_CHECK_IDS.join(", ")})`,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const baseRef = options.base ?? (options.staged ? "HEAD" : null);
|
|
117
|
+
const base = baseRef
|
|
118
|
+
? await resolveRevision(workspaceRoot, baseRef)
|
|
119
|
+
: await defaultBase(workspaceRoot);
|
|
120
|
+
if (!base) {
|
|
121
|
+
return {
|
|
122
|
+
ok: false,
|
|
123
|
+
usageError: baseRef
|
|
124
|
+
? `--base ${baseRef} does not resolve to a commit`
|
|
125
|
+
: "no merge-base with develop — pass --base <ref>",
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const judgedKind = options.staged ? { kind: "index" } : { kind: "worktree" };
|
|
129
|
+
const configOnly = options.check === "bindings.verify.substance";
|
|
130
|
+
const empty = { findings: [], unverifiable: 0, skipped: [] };
|
|
131
|
+
let now;
|
|
132
|
+
let then;
|
|
133
|
+
try {
|
|
134
|
+
if (configOnly) {
|
|
135
|
+
// The configuration auditor needs only forge.yaml — no base or code reads.
|
|
136
|
+
const forgeYaml = options.staged
|
|
137
|
+
? await createOriginGit(workspaceRoot).run(["show", ":forge.yaml"])
|
|
138
|
+
: (() => {
|
|
139
|
+
try {
|
|
140
|
+
return readFileSync(path.join(workspaceRoot, "forge.yaml"), "utf8");
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
})();
|
|
146
|
+
now = {
|
|
147
|
+
label: judgedKind.kind,
|
|
148
|
+
files: new Map(forgeYaml ? [["forge.yaml", forgeYaml]] : []),
|
|
149
|
+
};
|
|
150
|
+
then = { label: base, files: new Map() };
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
now = await loadSnapshot(workspaceRoot, judgedKind, declaredWriters);
|
|
154
|
+
then = await loadSnapshot(workspaceRoot, { kind: "rev", sha: base }, declaredWriters);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
return { ok: false, usageError: `cannot read the trees: ${err.message}` };
|
|
159
|
+
}
|
|
160
|
+
if (!now || !then)
|
|
161
|
+
return { ok: false, usageError: `cannot read the ${!now ? "judged tree" : `base ${base}`}` };
|
|
162
|
+
const codeOnly = options.check && !configOnly ? options.check : undefined;
|
|
163
|
+
const nowPass = configOnly ? empty : runCodeAuditors(now, codeOnly);
|
|
164
|
+
const basePass = configOnly ? empty : runCodeAuditors(then, codeOnly);
|
|
165
|
+
const doc = forgeDoc(now);
|
|
166
|
+
const exempt = doc?.correctness?.mode === "exempt";
|
|
167
|
+
const config = !options.check || options.check === "bindings.verify.substance"
|
|
168
|
+
? auditVerifySubstance(now.files.get("forge.yaml"), exempt)
|
|
169
|
+
: { findings: [], unverifiable: 0, skipped: [] };
|
|
170
|
+
const findings = attribute(basePass.findings, [...nowPass.findings, ...config.findings], readAllowList(doc));
|
|
171
|
+
const blocking = findings.some((f) => f.attribution === "introduced" && f.severity === "error");
|
|
172
|
+
return {
|
|
173
|
+
ok: true,
|
|
174
|
+
result: {
|
|
175
|
+
command: "correctness.audit",
|
|
176
|
+
base,
|
|
177
|
+
status: blocking ? "fail" : "pass",
|
|
178
|
+
findings,
|
|
179
|
+
unverifiable: nowPass.unverifiable,
|
|
180
|
+
skipped: [...nowPass.skipped, ...config.skipped],
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../../os/correctness/audit/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BE;AAEF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,cAAc,EAAqB,MAAM,kBAAkB,CAAC;AACnF,OAAO,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,eAAe,GAGhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,eAAe,EAAwD,MAAM,YAAY,CAAC;AAmBnG,SAAS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AC,KAAK,KAAK,2BAA2B;QAC7D,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAC3D,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAErD,MAAM,QAAQ,GAAG,SAAS,CACxB,QAAQ,CAAC,QAAQ,EACjB,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,EACzC,aAAa,CAAC,GAAG,CAAC,CACnB,CAAC;IACF,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,YAAY,IAAI,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;IAChG,OAAO;QACL,EAAE,EAAE,IAAI;QACR,MAAM,EAAE;YACN,OAAO,EAAE,mBAAmB;YAC5B,IAAI;YACJ,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;YAClC,QAAQ;YACR,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;SACjD;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DatabaseSync as DatabaseSyncType } from "node:sqlite";
|
|
2
|
+
import { type TreeSnapshot } from "./snapshot.ts";
|
|
3
|
+
export interface D1Schema {
|
|
4
|
+
/** `database_name` of the binding. */
|
|
5
|
+
name: string;
|
|
6
|
+
/** Workspace-relative POSIX directory of the wrangler config ("" = repo root). */
|
|
7
|
+
packageDir: string;
|
|
8
|
+
configFile: string;
|
|
9
|
+
migrations: string[];
|
|
10
|
+
db: DatabaseSyncType;
|
|
11
|
+
/** Base tables (no sqlite_/_cf_/d1_migrations engine tables, no FTS shadows), lower-cased. */
|
|
12
|
+
tables: Set<string>;
|
|
13
|
+
}
|
|
14
|
+
export interface MigrationFailure {
|
|
15
|
+
migration: string;
|
|
16
|
+
message: string;
|
|
17
|
+
/** "config" — the wrangler file itself is unreadable; "migration" — a migration does not apply. */
|
|
18
|
+
kind: "config" | "migration";
|
|
19
|
+
}
|
|
20
|
+
export interface SchemaDiscovery {
|
|
21
|
+
schemas: D1Schema[];
|
|
22
|
+
failures: MigrationFailure[];
|
|
23
|
+
unsupported: string[];
|
|
24
|
+
/** Package dirs whose config or migrations failed — their statements are unverifiable. */
|
|
25
|
+
failedPackages: Set<string>;
|
|
26
|
+
}
|
|
27
|
+
/** Discover and build every D1 schema of a snapshot. */
|
|
28
|
+
export declare function discoverSchemas(snapshot: TreeSnapshot): SchemaDiscovery;
|
|
29
|
+
/** Candidate schemas of a statement in `file`: its package's schemas, or every schema outside any. */
|
|
30
|
+
export declare function candidateSchemas(schemas: D1Schema[], file: string): D1Schema[];
|
|
31
|
+
export declare function closeSchemas(discovery: SchemaDiscovery): void;
|
|
32
|
+
//# sourceMappingURL=schema-db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-db.d.ts","sourceRoot":"","sources":["../../../../os/correctness/audit/schema-db.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpE,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAmBpE,MAAM,WAAW,QAAQ;IACvB,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,EAAE,EAAE,gBAAgB,CAAC;IACrB,8FAA8F;IAC9F,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,mGAAmG;IACnG,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,0FAA0F;IAC1F,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B;AAqCD,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,eAAe,CA2EvE;AAED,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,CAQ9E;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI,CAQ7D"}
|