@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,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1568 — forge module registration for `gate.run.status`. A forge
|
|
4
|
+
module so both hosts (standalone `forge` CLI + `werkstatt run` kernel) see
|
|
5
|
+
the command through their existing forge-module loading.</purpose>
|
|
6
|
+
</MODULE_CONTRACT>
|
|
7
|
+
<CHANGE_SUMMARY>
|
|
8
|
+
<item>RFC-1568: step 4 — gate-run module</item>
|
|
9
|
+
<item>RFC-1568: durable gate-run records, --detach mechanics, and forge CLI wiring</item>
|
|
10
|
+
</CHANGE_SUMMARY>
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { ForgeModule } from "../../src/forge-module.ts";
|
|
14
|
+
|
|
15
|
+
export async function createForgeGateRunModule(): Promise<ForgeModule> {
|
|
16
|
+
const { gateRunStatusCommand } = await import("./status.ts");
|
|
17
|
+
return {
|
|
18
|
+
name: "forge-gate-run",
|
|
19
|
+
version: "0.1.0",
|
|
20
|
+
runtime: "autonomous",
|
|
21
|
+
declarations: [],
|
|
22
|
+
commands: [gateRunStatusCommand],
|
|
23
|
+
pipelines: [],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { createForgeGateRunModule } from "./gate-run.module.ts";
|
|
2
|
+
export {
|
|
3
|
+
GATE_RUN_RETENTION,
|
|
4
|
+
GATE_RUNS_DIR,
|
|
5
|
+
classifyGateRun,
|
|
6
|
+
finishGateRun,
|
|
7
|
+
gateRunsDir,
|
|
8
|
+
listGateRuns,
|
|
9
|
+
repoRelativeCwd,
|
|
10
|
+
saveGateRun,
|
|
11
|
+
startGateRun,
|
|
12
|
+
} from "./record.ts";
|
|
13
|
+
export { GATE_RUN_ID_ENV, HEARTBEAT_WAIT_MS, detachPointerLines, detachSelf } from "./detach.ts";
|
|
14
|
+
export type { DetachResult } from "./detach.ts";
|
|
15
|
+
export { GATE_RUN_RULES, GATE_RUN_SCHEMA } from "./types.ts";
|
|
16
|
+
export type { GateRunRecord, GateRunStatus, SpawnLike, SpawnLikeChild } from "./types.ts";
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1568 — gate-run record lifecycle: start/finish writes (atomic
|
|
4
|
+
via fs-atomic), list, and liveness classification. Records live at
|
|
5
|
+
`<git common dir>/forge/gate-runs/` — shared across worktrees, never
|
|
6
|
+
committed. `lost` is derived at read time through `holderIsDead`, never
|
|
7
|
+
persisted.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>No command dispatch — hosts wrap execute() with these helpers.</item>
|
|
10
|
+
<item>No process management — a running record whose holder dies stays on
|
|
11
|
+
disk; classify reports it `lost`.</item>
|
|
12
|
+
</non-goals>
|
|
13
|
+
</MODULE_CONTRACT>
|
|
14
|
+
<CHANGE_SUMMARY>
|
|
15
|
+
<item>RFC-1568: step 2 — record lifecycle, classifyGateRun, retention</item>
|
|
16
|
+
<item>RFC-1568: durable gate-run records, --detach mechanics, and forge CLI wiring</item>
|
|
17
|
+
</CHANGE_SUMMARY>
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { hostname } from "node:os";
|
|
21
|
+
import { join, relative } from "node:path";
|
|
22
|
+
import { randomBytes } from "node:crypto";
|
|
23
|
+
|
|
24
|
+
import type { WorkspaceIO } from "../../src/types.ts";
|
|
25
|
+
import { writeFileAtomic } from "../../src/utils/fs-atomic.ts";
|
|
26
|
+
import { currentBootId, holderIsDead } from "../core/lock-holder.ts";
|
|
27
|
+
import type { GateRunRecord, GateRunStatus } from "./types.ts";
|
|
28
|
+
import { GATE_RUN_SCHEMA } from "./types.ts";
|
|
29
|
+
|
|
30
|
+
export const GATE_RUNS_DIR = "forge/gate-runs";
|
|
31
|
+
/** Newest records kept per command — running records are never deleted. */
|
|
32
|
+
export const GATE_RUN_RETENTION = 50;
|
|
33
|
+
|
|
34
|
+
export function gateRunsDir(commonGitDir: string): string {
|
|
35
|
+
return join(commonGitDir, GATE_RUNS_DIR);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function makeRunId(command: string): string {
|
|
39
|
+
const stamp = new Date()
|
|
40
|
+
.toISOString()
|
|
41
|
+
.replace(/[-:]/g, "")
|
|
42
|
+
.replace(/\.\d+Z$/, "Z");
|
|
43
|
+
return `gr-${stamp}-${command}-${randomBytes(2).toString("hex")}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function recordPath(commonGitDir: string, runId: string): string {
|
|
47
|
+
return join(gateRunsDir(commonGitDir), `${runId}.json`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Atomic record persist — the only write path for gate-run files. */
|
|
51
|
+
export async function saveGateRun(
|
|
52
|
+
commonGitDir: string,
|
|
53
|
+
record: GateRunRecord,
|
|
54
|
+
io: WorkspaceIO,
|
|
55
|
+
): Promise<void> {
|
|
56
|
+
const dir = gateRunsDir(commonGitDir);
|
|
57
|
+
await io.mkdir(dir);
|
|
58
|
+
await writeFileAtomic(recordPath(commonGitDir, record.runId), JSON.stringify(record, null, 2));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Retention — delete records+logs beyond the newest GATE_RUN_RETENTION per
|
|
63
|
+
* command. `status: running` records are exempt: the 51st queued run must
|
|
64
|
+
* not erase visibility of a still-running gate.
|
|
65
|
+
*/
|
|
66
|
+
async function applyRetention(
|
|
67
|
+
commonGitDir: string,
|
|
68
|
+
command: string,
|
|
69
|
+
io: WorkspaceIO,
|
|
70
|
+
): Promise<void> {
|
|
71
|
+
const runs = await listGateRuns(commonGitDir, io, { command });
|
|
72
|
+
const deletable = runs.filter((r) => r.status !== "running").slice(GATE_RUN_RETENTION);
|
|
73
|
+
for (const stale of deletable) {
|
|
74
|
+
try {
|
|
75
|
+
await io.rm(recordPath(commonGitDir, stale.runId));
|
|
76
|
+
if (stale.logPath) {
|
|
77
|
+
await io.rm(join(gateRunsDir(commonGitDir), `${stale.runId}.log`));
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
// retention is best-effort — a busy file system never blocks the gate
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Start a gate run. The detached child re-invokes with `input.runId` set
|
|
87
|
+
* (WERKSTATT_GATE_RUN_ID) and adopts the parent's record instead of creating
|
|
88
|
+
* a second one — its own pid overwrites the parent's.
|
|
89
|
+
*/
|
|
90
|
+
export async function startGateRun(input: {
|
|
91
|
+
commonGitDir: string;
|
|
92
|
+
command: string;
|
|
93
|
+
argv: string[];
|
|
94
|
+
cwd: string;
|
|
95
|
+
detached: boolean;
|
|
96
|
+
io: WorkspaceIO;
|
|
97
|
+
/** child of a detached parent passes the parent's run id. */
|
|
98
|
+
runId?: string;
|
|
99
|
+
missionId?: string;
|
|
100
|
+
}): Promise<GateRunRecord> {
|
|
101
|
+
const runId = input.runId ?? makeRunId(input.command);
|
|
102
|
+
const record: GateRunRecord = {
|
|
103
|
+
schema: GATE_RUN_SCHEMA,
|
|
104
|
+
runId,
|
|
105
|
+
command: input.command,
|
|
106
|
+
argv: input.argv,
|
|
107
|
+
cwd: input.cwd,
|
|
108
|
+
detached: input.detached,
|
|
109
|
+
pid: process.pid,
|
|
110
|
+
host: hostname(),
|
|
111
|
+
bootId: currentBootId(),
|
|
112
|
+
startedAt: new Date().toISOString(),
|
|
113
|
+
status: "running",
|
|
114
|
+
...(input.missionId ? { missionId: input.missionId } : {}),
|
|
115
|
+
};
|
|
116
|
+
await saveGateRun(input.commonGitDir, record, input.io);
|
|
117
|
+
if (input.runId === undefined) {
|
|
118
|
+
// retention is a start-side concern — never on the adopting child write.
|
|
119
|
+
await applyRetention(input.commonGitDir, input.command, input.io);
|
|
120
|
+
}
|
|
121
|
+
return record;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Final write — endedAt, exit code, summary, optional gate-report pointer. */
|
|
125
|
+
export async function finishGateRun(
|
|
126
|
+
commonGitDir: string,
|
|
127
|
+
record: GateRunRecord,
|
|
128
|
+
result: { exitCode: number; summary?: string; reportPath?: string },
|
|
129
|
+
io: WorkspaceIO,
|
|
130
|
+
): Promise<void> {
|
|
131
|
+
const finished: GateRunRecord = {
|
|
132
|
+
...record,
|
|
133
|
+
endedAt: new Date().toISOString(),
|
|
134
|
+
exitCode: result.exitCode,
|
|
135
|
+
status: result.exitCode === 0 ? "succeeded" : "failed",
|
|
136
|
+
...(result.summary ? { summary: result.summary } : {}),
|
|
137
|
+
...(result.reportPath ? { reportPath: result.reportPath } : {}),
|
|
138
|
+
};
|
|
139
|
+
await saveGateRun(commonGitDir, finished, io);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Newest-first listing. Corrupt records are skipped with a warn through
|
|
144
|
+
* `io` — a torn write must never break the status command.
|
|
145
|
+
*/
|
|
146
|
+
export async function listGateRuns(
|
|
147
|
+
commonGitDir: string,
|
|
148
|
+
io: WorkspaceIO,
|
|
149
|
+
filter?: { command?: string; limit?: number },
|
|
150
|
+
): Promise<GateRunRecord[]> {
|
|
151
|
+
const dir = gateRunsDir(commonGitDir);
|
|
152
|
+
let names: Awaited<ReturnType<WorkspaceIO["readdir"]>>;
|
|
153
|
+
try {
|
|
154
|
+
names = await io.readdir(dir);
|
|
155
|
+
} catch {
|
|
156
|
+
return [];
|
|
157
|
+
}
|
|
158
|
+
const out: GateRunRecord[] = [];
|
|
159
|
+
for (const entry of names) {
|
|
160
|
+
if (!entry.name.endsWith(".json")) continue;
|
|
161
|
+
try {
|
|
162
|
+
const parsed = JSON.parse(await io.readFile(join(dir, entry.name))) as GateRunRecord;
|
|
163
|
+
if (parsed.schema !== GATE_RUN_SCHEMA || typeof parsed.runId !== "string") continue;
|
|
164
|
+
if (filter?.command !== undefined && parsed.command !== filter.command) continue;
|
|
165
|
+
out.push(parsed);
|
|
166
|
+
} catch {
|
|
167
|
+
// corrupt record — skip, never throw (RFC-1568 tolerance rule)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
out.sort((a, b) => b.startedAt.localeCompare(a.startedAt));
|
|
171
|
+
return filter?.limit !== undefined ? out.slice(0, filter.limit) : out;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* running → lost when the holder is dead under the same liveness rule the
|
|
176
|
+
* flow locks use (same-host pid probe + boot id). Never writes — the record
|
|
177
|
+
* on disk keeps `status: running`.
|
|
178
|
+
*/
|
|
179
|
+
export function classifyGateRun(
|
|
180
|
+
record: GateRunRecord,
|
|
181
|
+
ownBootId: string | undefined = currentBootId(),
|
|
182
|
+
): GateRunStatus {
|
|
183
|
+
if (record.status !== "running") return record.status;
|
|
184
|
+
if (holderIsDead({ pid: record.pid, host: record.host, bootId: record.bootId }, ownBootId)) {
|
|
185
|
+
return "lost";
|
|
186
|
+
}
|
|
187
|
+
return "running";
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** The `cwd` field — relative to the common dir's parent (repo root) when possible. */
|
|
191
|
+
export function repoRelativeCwd(commonGitDir: string, cwd: string): string {
|
|
192
|
+
const rel = relative(join(commonGitDir, ".."), cwd);
|
|
193
|
+
return rel === "" || rel.startsWith("..") ? cwd : rel;
|
|
194
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1568 — `gate.run.status` handler: reports gate-run records from
|
|
4
|
+
`<git common dir>/forge/gate-runs/`. Selection: --id (one), --last
|
|
5
|
+
(newest, optional --command filter), default (10 newest). --wait polls up
|
|
6
|
+
to N seconds (max 600) until the run is no longer running. The command
|
|
7
|
+
exits 0 whenever records are readable — a gate's own outcome lives in
|
|
8
|
+
`data.runs[].status`, never in this command's exit code (DNA-106).</purpose>
|
|
9
|
+
<non-goals>
|
|
10
|
+
<item>No run lifecycle mutation — records are written by the runner.</item>
|
|
11
|
+
</non-goals>
|
|
12
|
+
</MODULE_CONTRACT>
|
|
13
|
+
<CHANGE_SUMMARY>
|
|
14
|
+
<item>RFC-1568: step 4 — gate.run.status handler</item>
|
|
15
|
+
<item>RFC-1568: durable gate-run records, --detach mechanics, and forge CLI wiring</item>
|
|
16
|
+
<item>RFC-1562: rfc-1562 acceptance evidence, regenerated manifests, gate contract tag</item>
|
|
17
|
+
<item>RFC-1575: gate.run.status uncacheable, --wait ends with a verdict
|
|
18
|
+
|
|
19
|
+
cacheable: false keeps live gate-run state out of the kernel result cache; --id --wait returns data.wait {requestedSeconds, waitedMs, outcome: completed|budget-expired} and a summary suffix. CMD-MAN-06 dropped after its live census (~100 warnings, no true positive): falsified route in the plan, ledger Q-8.</item>
|
|
20
|
+
</CHANGE_SUMMARY>
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import type {
|
|
24
|
+
ForgeCommandInput,
|
|
25
|
+
ForgeCommandResult,
|
|
26
|
+
ForgeRuntimeContext,
|
|
27
|
+
} from "../../src/types.ts";
|
|
28
|
+
import { resolveIo } from "../../src/utils/io.ts";
|
|
29
|
+
import { commonGitDir } from "../flow/registry.ts";
|
|
30
|
+
import { classifyGateRun, listGateRuns } from "./record.ts";
|
|
31
|
+
import type { GateRunRecord, GateRunStatus } from "./types.ts";
|
|
32
|
+
|
|
33
|
+
const WAIT_MAX_SECONDS = 600;
|
|
34
|
+
const WAIT_POLL_MS = 2_000;
|
|
35
|
+
|
|
36
|
+
/** RFC-1575: terminal verdict of a `--wait` — whether the run left `running` or the budget ran out. */
|
|
37
|
+
export interface GateRunWaitVerdict {
|
|
38
|
+
requestedSeconds: number;
|
|
39
|
+
waitedMs: number;
|
|
40
|
+
/** completed: the run left `running` during or before the wait; budget-expired: still running at the deadline */
|
|
41
|
+
outcome: "completed" | "budget-expired";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface GateRunStatusData {
|
|
45
|
+
runs: Array<GateRunRecord & { status: GateRunStatus }>;
|
|
46
|
+
/** RFC-1575: present only for `--id` with `--wait` > 0. */
|
|
47
|
+
wait?: GateRunWaitVerdict;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** RFC-1575 FI-1 — summary suffix when the wait budget expires. */
|
|
51
|
+
export const WAIT_EXPIRED_SUFFIX = "wait budget expired, still running";
|
|
52
|
+
|
|
53
|
+
function flag(input: ForgeCommandInput, name: string): string | undefined {
|
|
54
|
+
const v = input.flags[name];
|
|
55
|
+
return typeof v === "string" ? v : undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function boolFlag(input: ForgeCommandInput, name: string): boolean {
|
|
59
|
+
return input.flags[name] === true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function withClassified(record: GateRunRecord): GateRunRecord & { status: GateRunStatus } {
|
|
63
|
+
return { ...record, status: classifyGateRun(record) };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function formatRunLine(record: GateRunRecord & { status: GateRunStatus }): string {
|
|
67
|
+
const bits: string[] = [record.status];
|
|
68
|
+
if (record.exitCode !== undefined) bits.push(`exit ${record.exitCode}`);
|
|
69
|
+
bits.push(record.startedAt);
|
|
70
|
+
if (record.endedAt) bits.push(`→ ${record.endedAt}`);
|
|
71
|
+
return `[gate-run] ${record.runId} ${record.command} ${bits.join(" ")}`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function runGateRunStatus(
|
|
75
|
+
input: ForgeCommandInput,
|
|
76
|
+
context: ForgeRuntimeContext,
|
|
77
|
+
): Promise<ForgeCommandResult<GateRunStatusData>> {
|
|
78
|
+
const io = resolveIo(context.io);
|
|
79
|
+
const root = context.forgeRoot ?? context.workspaceRoot;
|
|
80
|
+
let common: string;
|
|
81
|
+
try {
|
|
82
|
+
common = await commonGitDir(io, root);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
return {
|
|
85
|
+
exitCode: 1,
|
|
86
|
+
summary: `[gate.run.status] cannot resolve the git common dir: ${(error as Error).message}`,
|
|
87
|
+
data: { runs: [] },
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const id = flag(input, "id");
|
|
92
|
+
const command = flag(input, "command");
|
|
93
|
+
const last = boolFlag(input, "last");
|
|
94
|
+
const waitRaw = flag(input, "wait");
|
|
95
|
+
const waitSeconds = waitRaw === undefined ? 0 : Math.min(Number(waitRaw) || 0, WAIT_MAX_SECONDS);
|
|
96
|
+
|
|
97
|
+
if (id !== undefined) {
|
|
98
|
+
const waitStarted = Date.now();
|
|
99
|
+
const deadline = waitStarted + waitSeconds * 1_000;
|
|
100
|
+
for (;;) {
|
|
101
|
+
const all = await listGateRuns(common, io);
|
|
102
|
+
const found = all.find((r) => r.runId === id);
|
|
103
|
+
if (found === undefined) {
|
|
104
|
+
return {
|
|
105
|
+
exitCode: 1,
|
|
106
|
+
summary: `[gate.run.status] GATE-RUN-03 unknown run id ${id}`,
|
|
107
|
+
data: { runs: [] },
|
|
108
|
+
nextSteps: [
|
|
109
|
+
{ action: "gate.run.status --last — inspect the most recent run", kind: "optional" },
|
|
110
|
+
],
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const classified = withClassified(found);
|
|
114
|
+
if (classified.status !== "running" || Date.now() >= deadline) {
|
|
115
|
+
if (waitSeconds <= 0) {
|
|
116
|
+
return { exitCode: 0, summary: formatRunLine(classified), data: { runs: [classified] } };
|
|
117
|
+
}
|
|
118
|
+
const waitedMs = Date.now() - waitStarted;
|
|
119
|
+
const wait: GateRunWaitVerdict = {
|
|
120
|
+
requestedSeconds: waitSeconds,
|
|
121
|
+
waitedMs,
|
|
122
|
+
outcome: classified.status === "running" ? "budget-expired" : "completed",
|
|
123
|
+
};
|
|
124
|
+
const suffix =
|
|
125
|
+
wait.outcome === "budget-expired"
|
|
126
|
+
? ` — ${WAIT_EXPIRED_SUFFIX} (${waitSeconds} s)`
|
|
127
|
+
: ` — left running after ${Math.round(waitedMs / 1000)} s`;
|
|
128
|
+
return {
|
|
129
|
+
exitCode: 0,
|
|
130
|
+
summary: formatRunLine(classified) + suffix,
|
|
131
|
+
data: { runs: [classified], wait },
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
await new Promise((r) =>
|
|
135
|
+
setTimeout(r, Math.min(WAIT_POLL_MS, Math.max(50, deadline - Date.now()))),
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (last) {
|
|
141
|
+
const all = await listGateRuns(common, io, { command, limit: 1 });
|
|
142
|
+
const runs = all.map(withClassified);
|
|
143
|
+
return {
|
|
144
|
+
exitCode: 0,
|
|
145
|
+
summary:
|
|
146
|
+
runs.length === 0
|
|
147
|
+
? `[gate.run.status] no gate runs recorded${command ? ` for ${command}` : ""}`
|
|
148
|
+
: formatRunLine(runs[0]!),
|
|
149
|
+
data: { runs },
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const all = await listGateRuns(common, io, { command, limit: 10 });
|
|
154
|
+
const runs = all.map(withClassified);
|
|
155
|
+
return {
|
|
156
|
+
exitCode: 0,
|
|
157
|
+
summary:
|
|
158
|
+
runs.length === 0
|
|
159
|
+
? `[gate.run.status] no gate runs recorded${command ? ` for ${command}` : ""}`
|
|
160
|
+
: `[gate.run.status] ${runs.length} recent run(s):\n${runs.map(formatRunLine).join("\n")}`,
|
|
161
|
+
data: { runs },
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export const gateRunStatusCommand = {
|
|
166
|
+
name: "gate.run.status",
|
|
167
|
+
description:
|
|
168
|
+
"Report durable gate-run records written by detachable commands " +
|
|
169
|
+
"(RFC-1568). `--id` one run, `--last` the most recent (optionally " +
|
|
170
|
+
"filtered by `--command`), default the 10 newest; `--wait <s>` blocks " +
|
|
171
|
+
"up to 600 s until the run leaves `running`. Classifies unfinished runs " +
|
|
172
|
+
"as `lost` via the same dead-holder liveness rule as flow locks. Exits " +
|
|
173
|
+
"0 whenever records are readable — the gate's outcome lives in " +
|
|
174
|
+
"`data.runs[].status`, never in this command's exit code (DNA-106).",
|
|
175
|
+
scope: "workspace" as const,
|
|
176
|
+
contract: "gate",
|
|
177
|
+
rules: [
|
|
178
|
+
{ id: "GATE-RUN-01", severity: "error" as const },
|
|
179
|
+
{ id: "GATE-RUN-02", severity: "error" as const },
|
|
180
|
+
{ id: "GATE-RUN-03", severity: "error" as const },
|
|
181
|
+
],
|
|
182
|
+
mutatesState: false,
|
|
183
|
+
execOnReadOnly: true,
|
|
184
|
+
// RFC-1575: live process state — never served from the kernel result cache
|
|
185
|
+
// (the records live under the git common dir, outside any cache digest).
|
|
186
|
+
cacheable: false,
|
|
187
|
+
reads: ["forge/gate-runs/**"],
|
|
188
|
+
flags: {
|
|
189
|
+
id: { kind: "string" as const, description: "One run id." },
|
|
190
|
+
last: {
|
|
191
|
+
kind: "boolean" as const,
|
|
192
|
+
description: "Most recent run (optionally filtered by --command).",
|
|
193
|
+
},
|
|
194
|
+
command: { kind: "string" as const, description: "Filter by command name." },
|
|
195
|
+
wait: {
|
|
196
|
+
kind: "string" as const,
|
|
197
|
+
description: "Block up to N seconds (max 600) until the run is no longer running.",
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
execute: runGateRunStatus,
|
|
201
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1568 detach mechanics tests (AC-4, AC-5): detachSelf passes the
|
|
4
|
+
entry/argv/env contract to an injected spawner and returns the child's pid
|
|
5
|
+
+ log path; the detached child adopts the parent's record via
|
|
6
|
+
WERKSTATT_GATE_RUN_ID (startGateRun with runId) so a detached run leaves
|
|
7
|
+
exactly one record carrying the child's pid.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>No real spawned gates — SpawnLike is faked; one integration case may
|
|
10
|
+
spawn `node -e`.</item>
|
|
11
|
+
</non-goals>
|
|
12
|
+
</MODULE_CONTRACT>
|
|
13
|
+
<CHANGE_SUMMARY>
|
|
14
|
+
<item>RFC-1568: step 3 — detach tests</item>
|
|
15
|
+
<item>RFC-1568: durable gate-run records, --detach mechanics, and forge CLI wiring</item>
|
|
16
|
+
</CHANGE_SUMMARY>
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { existsSync } from "node:fs";
|
|
20
|
+
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
21
|
+
import { tmpdir } from "node:os";
|
|
22
|
+
import { join } from "node:path";
|
|
23
|
+
|
|
24
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
25
|
+
|
|
26
|
+
import { resolveIo } from "../../../src/utils/io.ts";
|
|
27
|
+
import { GATE_RUN_ID_ENV, detachPointerLines, detachSelf } from "../detach.ts";
|
|
28
|
+
import { gateRunsDir, listGateRuns, saveGateRun, startGateRun } from "../record.ts";
|
|
29
|
+
import type { GateRunRecord, SpawnLike } from "../types.ts";
|
|
30
|
+
import { GATE_RUN_SCHEMA } from "../types.ts";
|
|
31
|
+
|
|
32
|
+
const dirs: string[] = [];
|
|
33
|
+
afterEach(async () => {
|
|
34
|
+
for (const dir of dirs.splice(0)) await rm(dir, { recursive: true, force: true });
|
|
35
|
+
}, 20_000);
|
|
36
|
+
|
|
37
|
+
async function tempCommon(): Promise<string> {
|
|
38
|
+
const dir = await mkdtemp(join(tmpdir(), "gate-run-detach-"));
|
|
39
|
+
dirs.push(dir);
|
|
40
|
+
return dir;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const io = resolveIo(undefined);
|
|
44
|
+
|
|
45
|
+
function recordFixture(common: string): Promise<GateRunRecord> {
|
|
46
|
+
return startGateRun({
|
|
47
|
+
commonGitDir: common,
|
|
48
|
+
command: "flow.integrate",
|
|
49
|
+
argv: ["--files", "a.md"],
|
|
50
|
+
cwd: ".",
|
|
51
|
+
detached: true,
|
|
52
|
+
io,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
describe("detachSelf", () => {
|
|
57
|
+
it("AC-4: spawns the CLI detached with the run id env and returns the child pid", async () => {
|
|
58
|
+
const common = await tempCommon();
|
|
59
|
+
const record = await recordFixture(common);
|
|
60
|
+
const seen: {
|
|
61
|
+
file?: string;
|
|
62
|
+
args?: string[];
|
|
63
|
+
opts?: { env?: Record<string, string | undefined>; stdio?: unknown[]; detached?: boolean };
|
|
64
|
+
} = {};
|
|
65
|
+
const fakeSpawn: SpawnLike = (file, args, opts) => {
|
|
66
|
+
seen.file = file;
|
|
67
|
+
seen.args = args;
|
|
68
|
+
seen.opts = opts;
|
|
69
|
+
return { pid: 424_242, unref() {} };
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const result = await detachSelf({
|
|
73
|
+
entry: "/repo/packages/forge/bin/cli.ts",
|
|
74
|
+
argv: ["flow.integrate", "--files", "a.md"],
|
|
75
|
+
record,
|
|
76
|
+
commonGitDir: common,
|
|
77
|
+
spawn: fakeSpawn,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
expect(result.pid).toBe(424_242);
|
|
81
|
+
expect(result.runId).toBe(record.runId);
|
|
82
|
+
expect(seen.file).toBe(process.execPath);
|
|
83
|
+
// execArgv forwards the host's loader flags (tsx) so the child re-enters
|
|
84
|
+
// through the same module pipeline as the parent.
|
|
85
|
+
expect(seen.args).toEqual([
|
|
86
|
+
...process.execArgv,
|
|
87
|
+
"/repo/packages/forge/bin/cli.ts",
|
|
88
|
+
"flow.integrate",
|
|
89
|
+
"--files",
|
|
90
|
+
"a.md",
|
|
91
|
+
]);
|
|
92
|
+
expect(seen.opts?.detached).toBe(true);
|
|
93
|
+
expect(seen.opts?.env?.[GATE_RUN_ID_ENV]).toBe(record.runId);
|
|
94
|
+
// stdio: stdin ignored, stdout+stderr routed into the log fd.
|
|
95
|
+
expect(seen.opts?.stdio?.[0]).toBe("ignore");
|
|
96
|
+
expect(existsSync(result.logPath)).toBe(true);
|
|
97
|
+
expect(result.logPath).toBe(join(gateRunsDir(common), `${record.runId}.log`));
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("pointer lines name the run, the log, and the status command", async () => {
|
|
101
|
+
const common = await tempCommon();
|
|
102
|
+
const lines = detachPointerLines(
|
|
103
|
+
{ pid: 1, runId: "gr-x", logPath: join(gateRunsDir(common), "gr-x.log") },
|
|
104
|
+
common,
|
|
105
|
+
"pnpm exec werkstatt run gate.run.status",
|
|
106
|
+
);
|
|
107
|
+
expect(lines[0]).toContain("gr-x");
|
|
108
|
+
expect(lines[1]).toContain(".git/forge/gate-runs/gr-x.log");
|
|
109
|
+
expect(lines[2]).toContain("gate.run.status --id gr-x");
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe("detached child adoption", () => {
|
|
114
|
+
it("AC-5: the child rewrites the parent's record — one record, child pid", async () => {
|
|
115
|
+
const common = await tempCommon();
|
|
116
|
+
// Parent writes the record before spawning.
|
|
117
|
+
const parent = await recordFixture(common);
|
|
118
|
+
const childPid = 515_151;
|
|
119
|
+
|
|
120
|
+
// Child side: WERKSTATT_GATE_RUN_ID set → startGateRun adopts the id.
|
|
121
|
+
const adopted = await startGateRun({
|
|
122
|
+
commonGitDir: common,
|
|
123
|
+
command: parent.command,
|
|
124
|
+
argv: parent.argv,
|
|
125
|
+
cwd: parent.cwd,
|
|
126
|
+
detached: true,
|
|
127
|
+
io,
|
|
128
|
+
runId: parent.runId,
|
|
129
|
+
});
|
|
130
|
+
adopted.pid = childPid;
|
|
131
|
+
await saveGateRun(common, adopted, io);
|
|
132
|
+
|
|
133
|
+
const runs = await listGateRuns(common, io);
|
|
134
|
+
expect(runs).toHaveLength(1);
|
|
135
|
+
expect(runs[0]?.runId).toBe(parent.runId);
|
|
136
|
+
|
|
137
|
+
const raw = JSON.parse(
|
|
138
|
+
await readFile(join(gateRunsDir(common), `${parent.runId}.json`), "utf8"),
|
|
139
|
+
) as GateRunRecord;
|
|
140
|
+
expect(raw.pid).toBe(childPid);
|
|
141
|
+
expect(raw.schema).toBe(GATE_RUN_SCHEMA);
|
|
142
|
+
expect(raw.status).toBe("running");
|
|
143
|
+
});
|
|
144
|
+
});
|