@warpgogol/forge 9.3.1 → 9.4.1
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/AGENTS.md +32 -0
- package/CHANGELOG.md +40 -0
- package/README.md +6 -4
- package/README.uk.md +10 -8
- package/bin/cli.ts +4 -4
- package/dist/bin/cli.js +4 -4
- package/dist/bin/cli.js.map +1 -1
- package/dist/os/adr/handlers/list-create.d.ts.map +1 -1
- package/dist/os/adr/handlers/list-create.js +23 -2
- package/dist/os/adr/handlers/list-create.js.map +1 -1
- package/dist/os/adr/types.d.ts +2 -0
- package/dist/os/adr/types.d.ts.map +1 -1
- package/dist/os/adr/types.js +2 -2
- package/dist/os/adr/types.js.map +1 -1
- package/dist/os/compass/handlers/compass-audit-handler.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-audit-handler.js +3 -1
- package/dist/os/compass/handlers/compass-audit-handler.js.map +1 -1
- package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-header-scaffold-handler.js +6 -12
- package/dist/os/compass/handlers/compass-header-scaffold-handler.js.map +1 -1
- package/dist/os/compass/handlers/git-revision.d.ts +2 -0
- package/dist/os/compass/handlers/git-revision.d.ts.map +1 -1
- package/dist/os/compass/handlers/git-revision.js +7 -2
- package/dist/os/compass/handlers/git-revision.js.map +1 -1
- package/dist/os/compass/handlers/summary-record.d.ts.map +1 -1
- package/dist/os/compass/handlers/summary-record.js +24 -14
- package/dist/os/compass/handlers/summary-record.js.map +1 -1
- package/dist/os/conformance/conformance.module.d.ts.map +1 -1
- package/dist/os/conformance/conformance.module.js +21 -4
- package/dist/os/conformance/conformance.module.js.map +1 -1
- package/dist/os/conformance/handlers/conformance-validate.d.ts.map +1 -1
- package/dist/os/conformance/handlers/conformance-validate.js +64 -8
- package/dist/os/conformance/handlers/conformance-validate.js.map +1 -1
- package/dist/os/core/archive-regen.d.ts +99 -0
- package/dist/os/core/archive-regen.d.ts.map +1 -0
- package/dist/os/core/archive-regen.js +220 -0
- package/dist/os/core/archive-regen.js.map +1 -0
- package/dist/os/core/core.module.d.ts.map +1 -1
- package/dist/os/core/core.module.js +159 -18
- package/dist/os/core/core.module.js.map +1 -1
- package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
- package/dist/os/core/handlers/assets-helpers.js +8 -3
- package/dist/os/core/handlers/assets-helpers.js.map +1 -1
- package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +1 -1
- package/dist/os/core/handlers/forge-autonomy-validate.js +3 -1
- package/dist/os/core/handlers/forge-autonomy-validate.js.map +1 -1
- package/dist/os/core/handlers/package-health.d.ts +130 -0
- package/dist/os/core/handlers/package-health.d.ts.map +1 -1
- package/dist/os/core/handlers/package-health.js +548 -7
- package/dist/os/core/handlers/package-health.js.map +1 -1
- package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
- package/dist/os/core/handlers/release-prepare.js +5 -2
- package/dist/os/core/handlers/release-prepare.js.map +1 -1
- package/dist/os/flow/digest.d.ts.map +1 -1
- package/dist/os/flow/digest.js +3 -1
- package/dist/os/flow/digest.js.map +1 -1
- package/dist/os/flow/dirty-classify.d.ts +51 -0
- package/dist/os/flow/dirty-classify.d.ts.map +1 -0
- package/dist/os/flow/dirty-classify.js +83 -0
- package/dist/os/flow/dirty-classify.js.map +1 -0
- package/dist/os/flow/flow.module.d.ts.map +1 -1
- package/dist/os/flow/flow.module.js +110 -19
- package/dist/os/flow/flow.module.js.map +1 -1
- package/dist/os/flow/gate-engine.d.ts +13 -0
- package/dist/os/flow/gate-engine.d.ts.map +1 -0
- package/dist/os/flow/gate-engine.js +32 -0
- package/dist/os/flow/gate-engine.js.map +1 -0
- package/dist/os/flow/git.d.ts +45 -4
- package/dist/os/flow/git.d.ts.map +1 -1
- package/dist/os/flow/git.js +95 -27
- package/dist/os/flow/git.js.map +1 -1
- package/dist/os/flow/handlers/flow-backmerge.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-backmerge.js +12 -5
- package/dist/os/flow/handlers/flow-backmerge.js.map +1 -1
- package/dist/os/flow/handlers/flow-check.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-check.js +25 -3
- package/dist/os/flow/handlers/flow-check.js.map +1 -1
- package/dist/os/flow/handlers/flow-cut.d.ts +4 -1
- package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-cut.js +75 -38
- package/dist/os/flow/handlers/flow-cut.js.map +1 -1
- package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-discard.js +33 -5
- package/dist/os/flow/handlers/flow-discard.js.map +1 -1
- package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-fix.js +13 -10
- package/dist/os/flow/handlers/flow-fix.js.map +1 -1
- package/dist/os/flow/handlers/flow-hold.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-hold.js +13 -7
- package/dist/os/flow/handlers/flow-hold.js.map +1 -1
- package/dist/os/flow/handlers/flow-install.d.ts +2 -1
- package/dist/os/flow/handlers/flow-install.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-install.js +56 -13
- package/dist/os/flow/handlers/flow-install.js.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.d.ts +54 -2
- package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.js +614 -65
- package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
- package/dist/os/flow/handlers/flow-open.d.ts +14 -0
- package/dist/os/flow/handlers/flow-open.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-open.js +117 -12
- package/dist/os/flow/handlers/flow-open.js.map +1 -1
- package/dist/os/flow/handlers/flow-peers.d.ts +24 -0
- package/dist/os/flow/handlers/flow-peers.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-peers.js +99 -0
- package/dist/os/flow/handlers/flow-peers.js.map +1 -0
- package/dist/os/flow/handlers/flow-status.d.ts +13 -0
- package/dist/os/flow/handlers/flow-status.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-status.js +35 -14
- package/dist/os/flow/handlers/flow-status.js.map +1 -1
- package/dist/os/flow/index.d.ts +3 -0
- package/dist/os/flow/index.d.ts.map +1 -1
- package/dist/os/flow/index.js +7 -2
- package/dist/os/flow/index.js.map +1 -1
- package/dist/os/flow/line-version.d.ts.map +1 -1
- package/dist/os/flow/line-version.js +2 -1
- package/dist/os/flow/line-version.js.map +1 -1
- package/dist/os/flow/locks.d.ts +37 -1
- package/dist/os/flow/locks.d.ts.map +1 -1
- package/dist/os/flow/locks.js +34 -14
- package/dist/os/flow/locks.js.map +1 -1
- package/dist/os/flow/ops-registry.d.ts +33 -0
- package/dist/os/flow/ops-registry.d.ts.map +1 -0
- package/dist/os/flow/ops-registry.js +177 -0
- package/dist/os/flow/ops-registry.js.map +1 -0
- package/dist/os/flow/preflight.d.ts +157 -0
- package/dist/os/flow/preflight.d.ts.map +1 -0
- package/dist/os/flow/preflight.js +772 -0
- package/dist/os/flow/preflight.js.map +1 -0
- package/dist/os/flow/publish.d.ts +7 -0
- package/dist/os/flow/publish.d.ts.map +1 -1
- package/dist/os/flow/publish.js +165 -3
- package/dist/os/flow/publish.js.map +1 -1
- package/dist/os/flow/registry.d.ts +26 -1
- package/dist/os/flow/registry.d.ts.map +1 -1
- package/dist/os/flow/registry.js +27 -6
- package/dist/os/flow/registry.js.map +1 -1
- package/dist/os/flow/scripts.d.ts +4 -0
- package/dist/os/flow/scripts.d.ts.map +1 -1
- package/dist/os/flow/scripts.js +8 -2
- package/dist/os/flow/scripts.js.map +1 -1
- package/dist/os/flow/session-checkout.d.ts +33 -0
- package/dist/os/flow/session-checkout.d.ts.map +1 -0
- package/dist/os/flow/session-checkout.js +151 -0
- package/dist/os/flow/session-checkout.js.map +1 -0
- package/dist/os/flow/standalone-invoke.d.ts +11 -0
- package/dist/os/flow/standalone-invoke.d.ts.map +1 -0
- package/dist/os/flow/standalone-invoke.js +75 -0
- package/dist/os/flow/standalone-invoke.js.map +1 -0
- package/dist/os/flow/worktree-path.d.ts.map +1 -1
- package/dist/os/flow/worktree-path.js +9 -3
- package/dist/os/flow/worktree-path.js.map +1 -1
- package/dist/os/instructions/handlers/budget-validate.d.ts +1 -0
- package/dist/os/instructions/handlers/budget-validate.d.ts.map +1 -1
- package/dist/os/instructions/handlers/budget-validate.js +12 -4
- package/dist/os/instructions/handlers/budget-validate.js.map +1 -1
- package/dist/os/instructions/instructions.module.d.ts.map +1 -1
- package/dist/os/instructions/instructions.module.js +4 -1
- package/dist/os/instructions/instructions.module.js.map +1 -1
- package/dist/os/mission/handlers/archive.d.ts.map +1 -1
- package/dist/os/mission/handlers/archive.js +12 -8
- package/dist/os/mission/handlers/archive.js.map +1 -1
- package/dist/os/mission/importer-block.d.ts +19 -0
- package/dist/os/mission/importer-block.d.ts.map +1 -0
- package/dist/os/mission/importer-block.js +124 -0
- package/dist/os/mission/importer-block.js.map +1 -0
- package/dist/os/mission/lockfile.d.ts +17 -0
- package/dist/os/mission/lockfile.d.ts.map +1 -1
- package/dist/os/mission/lockfile.js +38 -0
- package/dist/os/mission/lockfile.js.map +1 -1
- package/dist/os/mission/open-missions.d.ts +8 -0
- package/dist/os/mission/open-missions.d.ts.map +1 -0
- package/dist/os/mission/open-missions.js +42 -0
- package/dist/os/mission/open-missions.js.map +1 -0
- package/dist/os/queue/manifest.d.ts.map +1 -1
- package/dist/os/queue/manifest.js +11 -1
- package/dist/os/queue/manifest.js.map +1 -1
- package/dist/os/rfc/acceptance.d.ts +14 -0
- package/dist/os/rfc/acceptance.d.ts.map +1 -1
- package/dist/os/rfc/acceptance.js +18 -10
- package/dist/os/rfc/acceptance.js.map +1 -1
- package/dist/os/rfc/decision-log.d.ts.map +1 -1
- package/dist/os/rfc/decision-log.js +11 -2
- package/dist/os/rfc/decision-log.js.map +1 -1
- package/dist/os/rfc/frontmatter-io.d.ts +23 -0
- package/dist/os/rfc/frontmatter-io.d.ts.map +1 -1
- package/dist/os/rfc/frontmatter-io.js +82 -1
- package/dist/os/rfc/frontmatter-io.js.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp-deviations.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp-deviations.js +24 -2
- package/dist/os/rfc/handlers/implement-stamp-deviations.js.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.js +16 -3
- package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
- package/dist/os/rfc/handlers/index-graph.d.ts.map +1 -1
- package/dist/os/rfc/handlers/index-graph.js +5 -4
- package/dist/os/rfc/handlers/index-graph.js.map +1 -1
- package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
- package/dist/os/rfc/handlers/list-create.js +107 -10
- package/dist/os/rfc/handlers/list-create.js.map +1 -1
- package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts +48 -0
- package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts.map +1 -1
- package/dist/os/rfc/handlers/rfc-evidence-sync.js +131 -2
- package/dist/os/rfc/handlers/rfc-evidence-sync.js.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts +21 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.js +77 -5
- package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
- package/dist/os/rfc/handlers/validate.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate.js +64 -6
- package/dist/os/rfc/handlers/validate.js.map +1 -1
- package/dist/os/rfc/next-id.d.ts +38 -0
- package/dist/os/rfc/next-id.d.ts.map +1 -0
- package/dist/os/rfc/next-id.js +165 -0
- package/dist/os/rfc/next-id.js.map +1 -0
- package/dist/os/rfc/probe-batch.d.ts.map +1 -1
- package/dist/os/rfc/probe-batch.js +6 -1
- package/dist/os/rfc/probe-batch.js.map +1 -1
- package/dist/os/rfc/rfc.module.d.ts.map +1 -1
- package/dist/os/rfc/rfc.module.js +36 -8
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/os/rfc/types.d.ts +42 -6
- package/dist/os/rfc/types.d.ts.map +1 -1
- package/dist/os/rfc/types.js +6 -6
- package/dist/os/rfc/types.js.map +1 -1
- package/dist/os/rfc/verification-evidence.d.ts +1 -1
- package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
- package/dist/os/rfc/verification-evidence.js +81 -28
- package/dist/os/rfc/verification-evidence.js.map +1 -1
- package/dist/os/rfc/verification-origin.d.ts +8 -0
- package/dist/os/rfc/verification-origin.d.ts.map +1 -1
- package/dist/os/rfc/verification-origin.js +47 -0
- package/dist/os/rfc/verification-origin.js.map +1 -1
- package/dist/os/session/handlers/save.d.ts.map +1 -1
- package/dist/os/session/handlers/save.js +31 -7
- package/dist/os/session/handlers/save.js.map +1 -1
- package/dist/os/spec/spec-schema.d.ts +8 -0
- package/dist/os/spec/spec-schema.d.ts.map +1 -1
- package/dist/os/spec/spec-schema.js +1 -0
- package/dist/os/spec/spec-schema.js.map +1 -1
- package/dist/os/spec/spec-status.d.ts +8 -0
- package/dist/os/spec/spec-status.d.ts.map +1 -1
- package/dist/os/spec/spec-status.js +18 -6
- package/dist/os/spec/spec-status.js.map +1 -1
- package/dist/os/spec/spec-validate.d.ts.map +1 -1
- package/dist/os/spec/spec-validate.js +62 -15
- package/dist/os/spec/spec-validate.js.map +1 -1
- package/dist/os/spec/spec.module.d.ts.map +1 -1
- package/dist/os/spec/spec.module.js +13 -5
- package/dist/os/spec/spec.module.js.map +1 -1
- package/dist/os/system/handlers/system-map-validate.d.ts.map +1 -1
- package/dist/os/system/handlers/system-map-validate.js +2 -1
- package/dist/os/system/handlers/system-map-validate.js.map +1 -1
- package/dist/os/system/handlers/system-outbox-scan.d.ts +11 -0
- package/dist/os/system/handlers/system-outbox-scan.d.ts.map +1 -1
- package/dist/os/system/handlers/system-outbox-scan.js +54 -6
- package/dist/os/system/handlers/system-outbox-scan.js.map +1 -1
- package/dist/os/system/handlers/system-task-collect.d.ts.map +1 -1
- package/dist/os/system/handlers/system-task-collect.js +11 -5
- package/dist/os/system/handlers/system-task-collect.js.map +1 -1
- package/dist/os/system/handlers/system-task-create.d.ts.map +1 -1
- package/dist/os/system/handlers/system-task-create.js +6 -1
- package/dist/os/system/handlers/system-task-create.js.map +1 -1
- package/dist/os/system/handlers/system-versionset-record.d.ts +14 -0
- package/dist/os/system/handlers/system-versionset-record.d.ts.map +1 -1
- package/dist/os/system/handlers/system-versionset-record.js +246 -6
- package/dist/os/system/handlers/system-versionset-record.js.map +1 -1
- package/dist/os/system/repo.d.ts +1 -1
- package/dist/os/system/repo.d.ts.map +1 -1
- package/dist/os/system/repo.js +53 -3
- package/dist/os/system/repo.js.map +1 -1
- package/dist/os/system/scenario-schemas.d.ts +109 -3
- package/dist/os/system/scenario-schemas.d.ts.map +1 -1
- package/dist/os/system/scenario-schemas.js +66 -10
- package/dist/os/system/scenario-schemas.js.map +1 -1
- package/dist/os/system/system.module.d.ts.map +1 -1
- package/dist/os/system/system.module.js +69 -17
- package/dist/os/system/system.module.js.map +1 -1
- package/dist/os/system/tests/contract-fixtures.d.ts +17 -0
- package/dist/os/system/tests/contract-fixtures.d.ts.map +1 -0
- package/dist/os/system/tests/contract-fixtures.js +109 -0
- package/dist/os/system/tests/contract-fixtures.js.map +1 -0
- package/dist/src/config/forge-config.d.ts +54 -18
- package/dist/src/config/forge-config.d.ts.map +1 -1
- package/dist/src/config/forge-config.js +41 -9
- package/dist/src/config/forge-config.js.map +1 -1
- package/dist/src/conformance/index.d.ts +6 -0
- package/dist/src/conformance/index.d.ts.map +1 -1
- package/dist/src/conformance/index.js +36 -1
- package/dist/src/conformance/index.js.map +1 -1
- package/dist/src/formal/proof-runner.d.ts.map +1 -1
- package/dist/src/formal/proof-runner.js +10 -2
- package/dist/src/formal/proof-runner.js.map +1 -1
- package/dist/src/migration-adapters/node-typescript-pnpm/index.js +3 -1
- package/dist/src/migration-adapters/node-typescript-pnpm/index.js.map +1 -1
- package/dist/src/migration-adapters/phaser-pnpm/index.js +3 -1
- package/dist/src/migration-adapters/phaser-pnpm/index.js.map +1 -1
- package/dist/src/onboarding/agents-generate.js +4 -4
- package/dist/src/onboarding/agents-generate.js.map +1 -1
- package/dist/src/onboarding/nested-agents-generate.d.ts.map +1 -1
- package/dist/src/onboarding/nested-agents-generate.js +3 -1
- package/dist/src/onboarding/nested-agents-generate.js.map +1 -1
- package/dist/src/onboarding/prettierignore.d.ts.map +1 -1
- package/dist/src/onboarding/prettierignore.js +2 -0
- package/dist/src/onboarding/prettierignore.js.map +1 -1
- package/dist/src/onboarding/scaffold-project.js +2 -2
- package/dist/src/onboarding/scaffold-project.js.map +1 -1
- package/dist/src/onboarding/upgrade.d.ts.map +1 -1
- package/dist/src/onboarding/upgrade.js +14 -2
- package/dist/src/onboarding/upgrade.js.map +1 -1
- package/dist/src/onboarding/workspace-discovery.d.ts.map +1 -1
- package/dist/src/onboarding/workspace-discovery.js +3 -1
- package/dist/src/onboarding/workspace-discovery.js.map +1 -1
- package/dist/src/skill-schema.d.ts +3 -0
- package/dist/src/skill-schema.d.ts.map +1 -1
- package/dist/src/skill-schema.js +9 -2
- package/dist/src/skill-schema.js.map +1 -1
- package/dist/src/spec/resolve-spec-source.d.ts +45 -0
- package/dist/src/spec/resolve-spec-source.d.ts.map +1 -0
- package/dist/src/spec/resolve-spec-source.js +153 -0
- package/dist/src/spec/resolve-spec-source.js.map +1 -0
- package/dist/src/utils/command-inventory.d.ts +28 -0
- package/dist/src/utils/command-inventory.d.ts.map +1 -0
- package/dist/src/utils/command-inventory.js +84 -0
- package/dist/src/utils/command-inventory.js.map +1 -0
- package/dist/src/utils/io.d.ts.map +1 -1
- package/dist/src/utils/io.js +6 -1
- package/dist/src/utils/io.js.map +1 -1
- package/dist/src/utils/repo-path.d.ts +10 -0
- package/dist/src/utils/repo-path.d.ts.map +1 -0
- package/dist/src/utils/repo-path.js +52 -0
- package/dist/src/utils/repo-path.js.map +1 -0
- package/dist/src/utils/spawn.d.ts +23 -0
- package/dist/src/utils/spawn.d.ts.map +1 -0
- package/dist/src/utils/spawn.js +83 -0
- package/dist/src/utils/spawn.js.map +1 -0
- package/docs/branch-model.md +1 -1
- package/docs/guides/existing-project.md +1 -1
- package/docs/maintainers/publishing.md +1 -1
- package/docs/reference/cli.md +8 -2
- package/docs/reference/profiles.md +1 -1
- package/os/adr/handlers/list-create.ts +26 -2
- package/os/adr/types.ts +4 -2
- package/os/compass/handlers/compass-audit-handler.ts +6 -1
- package/os/compass/handlers/compass-header-scaffold-handler.ts +12 -11
- package/os/compass/handlers/git-revision.ts +8 -2
- package/os/compass/handlers/summary-record.ts +25 -14
- package/os/compass/handlers/tests/compass-invariant-binding.test.ts +3 -2
- package/os/conformance/conformance.module.ts +21 -4
- package/os/conformance/handlers/conformance-validate.ts +108 -16
- package/os/conformance/handlers/tests/conformance-package-consumer.test.ts +200 -0
- package/os/core/archive-regen.ts +279 -0
- package/os/core/core.module.ts +176 -29
- package/os/core/docs-archive.test.ts +413 -3
- package/os/core/handlers/assets-helpers.ts +8 -3
- package/os/core/handlers/forge-autonomy-validate.ts +3 -1
- package/os/core/handlers/package-health.test.ts +418 -4
- package/os/core/handlers/package-health.ts +629 -7
- package/os/core/handlers/release-prepare.ts +5 -2
- package/os/flow/digest.ts +3 -1
- package/os/flow/dirty-classify.ts +120 -0
- package/os/flow/flow.module.ts +119 -24
- package/os/flow/gate-engine.ts +45 -0
- package/os/flow/git.ts +117 -29
- package/os/flow/handlers/flow-backmerge.ts +14 -4
- package/os/flow/handlers/flow-check.ts +27 -2
- package/os/flow/handlers/flow-cut.ts +124 -56
- package/os/flow/handlers/flow-discard.ts +33 -5
- package/os/flow/handlers/flow-fix.ts +22 -10
- package/os/flow/handlers/flow-hold.ts +20 -7
- package/os/flow/handlers/flow-install.ts +59 -12
- package/os/flow/handlers/flow-integrate.ts +933 -180
- package/os/flow/handlers/flow-open.ts +135 -11
- package/os/flow/handlers/flow-peers.ts +142 -0
- package/os/flow/handlers/flow-status.ts +45 -13
- package/os/flow/index.ts +8 -2
- package/os/flow/line-version.ts +2 -1
- package/os/flow/locks.ts +56 -14
- package/os/flow/ops-registry.ts +194 -0
- package/os/flow/preflight.ts +974 -0
- package/os/flow/publish.ts +200 -5
- package/os/flow/registry.ts +43 -7
- package/os/flow/scripts.ts +13 -2
- package/os/flow/session-checkout.ts +186 -0
- package/os/flow/standalone-invoke.ts +85 -0
- package/os/flow/tests/dirty-classify.test.ts +251 -0
- package/os/flow/tests/fixtures/branch-names.yaml +40 -40
- package/os/flow/tests/flow-cut.test.ts +21 -0
- package/os/flow/tests/flow-discard.test.ts +32 -0
- package/os/flow/tests/flow-guard-parity.test.ts +10 -2
- package/os/flow/tests/flow-install.test.ts +7 -3
- package/os/flow/tests/flow-integrate.gate-report.test.ts +144 -0
- package/os/flow/tests/flow-integrate.preflight.test.ts +565 -0
- package/os/flow/tests/flow-integrate.reattach.test.ts +197 -0
- package/os/flow/tests/flow-integrate.remediation.test.ts +254 -0
- package/os/flow/tests/flow-integrate.test.ts +698 -17
- package/os/flow/tests/flow-open.pending.test.ts +277 -0
- package/os/flow/tests/flow-open.test.ts +52 -9
- package/os/flow/tests/flow-push-publish.test.ts +124 -0
- package/os/flow/tests/flow-status.test.ts +31 -1
- package/os/flow/tests/locks.test.ts +39 -3
- package/os/flow/tests/ops-registry.test.ts +136 -0
- package/os/flow/tests/scripts.test.ts +5 -2
- package/os/flow/tests/state-roots.test.ts +8 -5
- package/os/flow/worktree-path.ts +9 -3
- package/os/formal/handlers/proof-check.test.ts +6 -3
- package/os/instructions/budget.test.ts +31 -0
- package/os/instructions/handlers/budget-validate.ts +13 -4
- package/os/instructions/instructions.module.ts +4 -1
- package/os/mission/handlers/archive.ts +22 -14
- package/os/mission/importer-block.ts +119 -0
- package/os/mission/lockfile.ts +41 -0
- package/os/mission/open-missions.ts +50 -0
- package/os/queue/decision-ledger.test.ts +18 -0
- package/os/queue/manifest.ts +17 -1
- package/os/rfc/acceptance.ts +30 -10
- package/os/rfc/decision-log.ts +13 -2
- package/os/rfc/frontmatter-io.ts +89 -1
- package/os/rfc/handlers/implement-stamp-deviations.test.ts +83 -0
- package/os/rfc/handlers/implement-stamp-deviations.ts +22 -2
- package/os/rfc/handlers/implement-stamp-stale.test.ts +5 -1
- package/os/rfc/handlers/implement-stamp.ts +16 -3
- package/os/rfc/handlers/index-graph.ts +5 -4
- package/os/rfc/handlers/lifecycle.test.ts +136 -0
- package/os/rfc/handlers/list-create.test.ts +126 -0
- package/os/rfc/handlers/list-create.ts +130 -10
- package/os/rfc/handlers/rfc-evidence-sync.test.ts +504 -0
- package/os/rfc/handlers/rfc-evidence-sync.ts +192 -2
- package/os/rfc/handlers/tests/index-graph.test.ts +2 -1
- package/os/rfc/handlers/validate-rules-rfc1454.test.ts +73 -0
- package/os/rfc/handlers/validate-rules.ts +103 -7
- package/os/rfc/handlers/validate.ts +68 -4
- package/os/rfc/next-id.ts +232 -0
- package/os/rfc/probe-batch.ts +6 -1
- package/os/rfc/rfc.module.ts +41 -8
- package/os/rfc/types.ts +31 -6
- package/os/rfc/verification-emit-freshness.test.ts +5 -1
- package/os/rfc/verification-emit.test.ts +5 -1
- package/os/rfc/verification-evidence.ts +99 -33
- package/os/rfc/verification-origin.ts +59 -0
- package/os/rfc/verification-refresh.test.ts +5 -1
- package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +5 -1
- package/os/session/handlers/save.ts +35 -7
- package/os/session/tests/session-save.test.ts +154 -0
- package/os/spec/spec-schema.ts +3 -0
- package/os/spec/spec-status.ts +22 -6
- package/os/spec/spec-validate.package-source.test.ts +187 -0
- package/os/spec/spec-validate.ts +65 -14
- package/os/spec/spec.module.ts +13 -5
- package/os/system/handlers/system-map-validate.ts +4 -2
- package/os/system/handlers/system-outbox-scan.ts +65 -21
- package/os/system/handlers/system-task-collect.ts +11 -5
- package/os/system/handlers/system-task-create.ts +6 -1
- package/os/system/handlers/system-versionset-record.ts +301 -16
- package/os/system/repo.ts +59 -18
- package/os/system/scenario-schemas.ts +91 -12
- package/os/system/system.module.ts +70 -17
- package/os/system/tests/contract-fixtures.ts +139 -0
- package/os/system/tests/scenario-pin-drift-check.test.ts +114 -0
- package/os/system/tests/scenario-validator-check.test.ts +96 -0
- package/os/system/tests/system-task-collect.test.ts +16 -0
- package/os/system/tests/system-task-dispatch.test.ts +4 -1
- package/os/system/tests/system-versionset.test.ts +7 -3
- package/os/system/tests/version-set-v2.test.ts +78 -0
- package/package.json +9 -1
- package/skills/fo/fo-doctor/SKILL.md +151 -0
- package/skills/fo/fo-handoff/SKILL.md +22 -0
- package/skills/fo/fo-idea-create-rfc/acceptance-criteria-standard.md +2 -1
- package/skills/fo/fo-idea-implement/SKILL.md +5 -2
- package/skills/fo/fo-idea-plan/SKILL.md +5 -5
- package/skills/fo/fo-session-retro/SKILL.md +45 -13
- package/skills/fo/fo-spec-ingest/SKILL.md +8 -0
- package/skills/fo/fo-system-dispatch/SKILL.md +1 -0
- package/skills/meta/skill-create/SKILL.md +2 -1
- package/src/bin-entry.test.ts +3 -1
- package/src/config/forge-config.ts +57 -13
- package/src/conformance/index.ts +46 -1
- package/src/formal/proof-runner.ts +10 -2
- package/src/migration-adapters/node-typescript-pnpm/index.ts +3 -1
- package/src/migration-adapters/phaser-pnpm/index.ts +3 -1
- package/src/onboarding/agents-generate.ts +4 -4
- package/src/onboarding/nested-agents-generate.ts +3 -1
- package/src/onboarding/prettierignore.ts +2 -0
- package/src/onboarding/scaffold-project.ts +2 -2
- package/src/onboarding/upgrade.ts +13 -2
- package/src/onboarding/workspace-discovery.ts +3 -1
- package/src/pipeline-status.test.ts +1 -1
- package/src/skill-schema.ts +9 -2
- package/src/spec/resolve-spec-source.ts +184 -0
- package/src/tests/acceptance-probe-kinds.test.ts +3 -1
- package/src/tests/agents-generate-domain.test.ts +3 -2
- package/src/tests/agents-generate.test.ts +2 -1
- package/src/tests/create-flow.test.ts +3 -1
- package/src/tests/create.test.ts +12 -2
- package/src/tests/editable-generated-region.test.ts +2 -2
- package/src/tests/fixtures/agents-generate-business-before.txt +2 -0
- package/src/tests/implement-stamp.test.ts +5 -2
- package/src/tests/prettierignore-manage.test.ts +11 -0
- package/src/tests/rfc-implement-stamp-governance.test.ts +6 -2
- package/src/tests/rfc-verification-verdict-ingest.test.ts +5 -1
- package/src/tests/scaffold-project.test.ts +3 -1
- package/src/tests/upgrade.test.ts +79 -3
- package/src/tests/workspace-discovery.test.ts +4 -3
- package/src/utils/command-inventory.ts +105 -0
- package/src/utils/io.ts +6 -1
- package/src/utils/repo-path.ts +49 -0
- package/src/utils/spawn.ts +88 -0
- package/src/tests/rfc-evidence-sync.test.ts +0 -369
- package/src/tests/skill-agents-sync.test.ts +0 -192
package/os/flow/locks.ts
CHANGED
|
@@ -12,22 +12,15 @@ locks broken, always released in finally. Used for the short registry lock
|
|
|
12
12
|
<KEY_DECISIONS>
|
|
13
13
|
<item>Staleness reads the lock file's `at` timestamp, not mtime — a crashed holder leaves a frozen file whose content is authoritative (DNA-105).</item>
|
|
14
14
|
<item>Timeout throws LockTimeoutError naming the file — each command maps it to its own diagnostic (FLOW-07 for the registry, FLOW-INT-08 for integrate).</item>
|
|
15
|
+
<item>Refused attempts render the last observed holder via describeHeldLock — the `stale` disposition is near-unreachable from withFlowLock (age-stale locks are broken before the deadline check) and exists for callers classifying a lock they never waited on (RFC-1515).</item>
|
|
15
16
|
</KEY_DECISIONS>
|
|
16
17
|
<CHANGE_SUMMARY>
|
|
17
|
-
<item>RFC-1487: step 1 — exclusive file locks</item>
|
|
18
|
-
<item>RFC-1487: step 1 — worktree path contracts, O_EXCL locks, branch registry and journal</item>
|
|
19
|
-
<item>RFC-1487: close rfc-1487 review findings — dirty-check parity with git worktree remove, ownership-verified lock release, FLOW-07 registry-error mapping, residual RFC-1462 docs removed
|
|
20
|
-
|
|
21
|
-
The dirty gate for session worktrees now uses full porcelain status
|
|
22
|
-
(untracked files included) because it predicts 'git worktree remove';
|
|
23
|
-
the primary-clean gate keeps tracked-only semantics because it predicts
|
|
24
|
-
'merge --ff-only'. Lock release verifies the held payload before
|
|
25
|
-
unlinking. Registry/journal failures map to FLOW-07 in every handler.
|
|
26
|
-
The final branch-name collision reports FLOW-OPEN-04, flow.discard
|
|
27
|
-
propagates its teardown result and predicts FLOW-DIS-03 on --dry-run,
|
|
28
|
-
and integrate exposes teardown as its own field.</item>
|
|
29
18
|
<item>RFC-1504: steps 2-3 — holderIsDead, boot-id payload, dead-holder break in withFlowLock</item>
|
|
30
19
|
<item>RFC-1504: review fixes — single io.readFile parse per iteration, real ageMs on dead-holder onStale, atomic break claim</item>
|
|
20
|
+
<item>RFC-1515: harden forge flow worktree lifecycle against vanished paths, forge-local state, dead-holder locks and generated drift</item>
|
|
21
|
+
<item>RFC-1515: close rfc-1515 review findings — delete tolerated paths before worktree remove, prune vanished registrations, verified branch -D, shared held-lock render, gated e2e throw, journal toleratedState, edge tests</item>
|
|
22
|
+
<item>RFC-1515: record rfc-1515 review r1 fixes, key decisions and corrected probe path</item>
|
|
23
|
+
<history>RFC-1487</history>
|
|
31
24
|
</CHANGE_SUMMARY>
|
|
32
25
|
*/
|
|
33
26
|
|
|
@@ -64,10 +57,18 @@ export interface FlowLockOptions {
|
|
|
64
57
|
/** Thrown when the wait budget elapses while a live lock is held. */
|
|
65
58
|
export class LockTimeoutError extends Error {
|
|
66
59
|
readonly lockPath: string;
|
|
67
|
-
|
|
60
|
+
/** RFC-1515: last observed holder payload — absent when the lock file was
|
|
61
|
+
* unreadable or vanished between polls ("holder unknown"). */
|
|
62
|
+
readonly holder?: { pid: number; host?: string; at: string; bootId?: string };
|
|
63
|
+
constructor(
|
|
64
|
+
lockPath: string,
|
|
65
|
+
waitedMs: number,
|
|
66
|
+
holder?: { pid: number; host?: string; at: string; bootId?: string },
|
|
67
|
+
) {
|
|
68
68
|
super(`lock ${lockPath} still held after ${waitedMs} ms`);
|
|
69
69
|
this.name = "LockTimeoutError";
|
|
70
70
|
this.lockPath = lockPath;
|
|
71
|
+
this.holder = holder;
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
|
@@ -79,6 +80,43 @@ interface LockFileContent {
|
|
|
79
80
|
bootId?: string;
|
|
80
81
|
}
|
|
81
82
|
|
|
83
|
+
/** RFC-1515 AC-4: the holder payload a refused lock attempt renders. */
|
|
84
|
+
export interface HeldLockDiagnostic {
|
|
85
|
+
pid: number;
|
|
86
|
+
host?: string;
|
|
87
|
+
at: string;
|
|
88
|
+
/** ms since the holder's `at` — null when the timestamp never parsed. */
|
|
89
|
+
heldMs: number | null;
|
|
90
|
+
disposition: "live" | "dead-holder" | "stale";
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Classify a refused attempt's last observed holder — `dead-holder` via the
|
|
95
|
+
* RFC-1504 classifier (dead pid on this host, or a foreign boot id), `stale`
|
|
96
|
+
* when the observed age exceeds the command's stale budget. The `stale` arm
|
|
97
|
+
* is near-unreachable from `withFlowLock` (age-stale locks are broken before
|
|
98
|
+
* the deadline check each poll) — it exists for callers classifying a lock
|
|
99
|
+
* they never waited on.
|
|
100
|
+
*/
|
|
101
|
+
export function describeHeldLock(
|
|
102
|
+
holder: { pid: number; host?: string; at: string; bootId?: string },
|
|
103
|
+
staleMs: number,
|
|
104
|
+
): HeldLockDiagnostic {
|
|
105
|
+
const heldAtMs = Date.parse(holder.at);
|
|
106
|
+
const heldMs = Number.isNaN(heldAtMs) ? null : Math.max(0, Date.now() - heldAtMs);
|
|
107
|
+
return {
|
|
108
|
+
pid: holder.pid,
|
|
109
|
+
host: holder.host,
|
|
110
|
+
at: holder.at,
|
|
111
|
+
heldMs,
|
|
112
|
+
disposition: holderIsDead(holder, currentBootId())
|
|
113
|
+
? "dead-holder"
|
|
114
|
+
: heldMs !== null && heldMs > staleMs
|
|
115
|
+
? "stale"
|
|
116
|
+
: "live",
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
82
120
|
const defaultSleep = (ms: number): Promise<void> =>
|
|
83
121
|
new Promise((resolve) => setTimeout(resolve, ms));
|
|
84
122
|
|
|
@@ -195,7 +233,11 @@ export async function withFlowLock<T>(
|
|
|
195
233
|
continue;
|
|
196
234
|
}
|
|
197
235
|
if (now() >= deadline) {
|
|
198
|
-
throw new LockTimeoutError(
|
|
236
|
+
throw new LockTimeoutError(
|
|
237
|
+
lockPath,
|
|
238
|
+
now() - (deadline - opts.waitMs),
|
|
239
|
+
holder ?? undefined,
|
|
240
|
+
);
|
|
199
241
|
}
|
|
200
242
|
if (opts.progressEveryMs && now() >= nextProgress) {
|
|
201
243
|
opts.onProgress?.(`waiting for ${lockPath}`);
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>Shared operation-claims registry (RFC-1543) — long-running ops that
|
|
4
|
+
write git-visible state in a checkout they do not own journal a
|
|
5
|
+
`forge/op-claim@1` record under the shared git dir before mutating, so
|
|
6
|
+
`classifyDirt` can attribute otherwise-foreign dirt to a live holder instead
|
|
7
|
+
of refusing blind. Liveness (pid alive on this host+bootId, heartbeat
|
|
8
|
+
≤5×cadence), not deletion, is authoritative — a crashed op's record is
|
|
9
|
+
reclaimed by the next reader, never trusted.</purpose>
|
|
10
|
+
<non-goals>
|
|
11
|
+
<item>No cross-host coordination — claims are machine-local, same trust model as integrate.lock.</item>
|
|
12
|
+
<item>No mutation authority — readers may sweep dead records; they never edit claims or block on them directly.</item>
|
|
13
|
+
</non-goals>
|
|
14
|
+
</MODULE_CONTRACT>
|
|
15
|
+
<KEY_DECISIONS>
|
|
16
|
+
<item>Claims live at <git-common-dir>/forge/ops/<opId>.yaml — worktrees share one git dir, so a claim written from a session worktree is visible to the primary by construction.</item>
|
|
17
|
+
<item>Claim-write failure degrades to unclaimed behavior (fail-safe): the op proceeds and classification keeps the old refusal semantics — a registry outage must never become a write blocker.</item>
|
|
18
|
+
</KEY_DECISIONS>
|
|
19
|
+
<CHANGE_SUMMARY>
|
|
20
|
+
<item>RFC-1543: op-claim registry — claim/release/liveClaims, pid+bootId+heartbeat liveness, lazy dead-record sweep</item>
|
|
21
|
+
<item>RFC-1543: attribute shared-checkout dirt to live ops and expose peers (RFC-1543)</item>
|
|
22
|
+
</CHANGE_SUMMARY>
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { hostname } from "node:os";
|
|
26
|
+
import { join } from "node:path";
|
|
27
|
+
import { parse as yamlParse, stringify as yamlStringify } from "yaml";
|
|
28
|
+
import type { WorkspaceIO } from "../../src/types.ts";
|
|
29
|
+
import { currentBootId, holderIsDead } from "../core/lock-holder.ts";
|
|
30
|
+
import { git } from "./git.ts";
|
|
31
|
+
|
|
32
|
+
export const OP_CLAIM_SCHEMA = "forge/op-claim@1";
|
|
33
|
+
/** Expected heartbeat write cadence — a claim goes stale at 5× this age. */
|
|
34
|
+
export const HEARTBEAT_CADENCE_MS = 30_000;
|
|
35
|
+
|
|
36
|
+
export interface OpClaim {
|
|
37
|
+
schema: typeof OP_CLAIM_SCHEMA;
|
|
38
|
+
opId: string;
|
|
39
|
+
command: string;
|
|
40
|
+
pid: number;
|
|
41
|
+
host: string;
|
|
42
|
+
bootId?: string;
|
|
43
|
+
startedAt: string;
|
|
44
|
+
heartbeatAt: string;
|
|
45
|
+
workspaceRoot: string;
|
|
46
|
+
/** Exact paths or directory prefixes the op legitimately dirties. */
|
|
47
|
+
paths: string[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** `<git-common-dir>/forge/ops` — shared across linked worktrees. */
|
|
51
|
+
async function opsDir(repo: string, io: WorkspaceIO): Promise<string | null> {
|
|
52
|
+
let r;
|
|
53
|
+
try {
|
|
54
|
+
r = await git(repo, io, ["rev-parse", "--git-common-dir"]);
|
|
55
|
+
} catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
if (r.exitCode !== 0) return null;
|
|
59
|
+
const dir = r.stdout.trim();
|
|
60
|
+
return join(dir.startsWith("/") ? dir : join(repo, dir), "forge", "ops");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Liveness (AC-2): pid alive on this host+bootId AND heartbeat ≤5×cadence. */
|
|
64
|
+
export function isClaimLive(claim: OpClaim, now: number = Date.now()): boolean {
|
|
65
|
+
if (holderIsDead(claim, currentBootId())) return false;
|
|
66
|
+
const beat = Date.parse(claim.heartbeatAt);
|
|
67
|
+
if (!Number.isFinite(beat) || now - beat > 5 * HEARTBEAT_CADENCE_MS) return false;
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** True when `path` equals or sits under a declared claim path/prefix. */
|
|
72
|
+
export function claimCoversPath(claim: OpClaim, path: string): boolean {
|
|
73
|
+
return claim.paths.some((p) => {
|
|
74
|
+
const prefix = p.endsWith("/") ? p : `${p}/`;
|
|
75
|
+
return path === p || path.startsWith(prefix);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Write a claim before the op's first shared-checkout mutation — best-effort. */
|
|
80
|
+
export async function claimOp(
|
|
81
|
+
repo: string,
|
|
82
|
+
io: WorkspaceIO,
|
|
83
|
+
claim: Omit<OpClaim, "schema" | "pid" | "host" | "bootId" | "startedAt" | "heartbeatAt"> & {
|
|
84
|
+
startedAt?: string;
|
|
85
|
+
},
|
|
86
|
+
): Promise<boolean> {
|
|
87
|
+
const dir = await opsDir(repo, io);
|
|
88
|
+
if (dir === null) return false;
|
|
89
|
+
const now = new Date().toISOString();
|
|
90
|
+
const record: OpClaim = {
|
|
91
|
+
schema: OP_CLAIM_SCHEMA,
|
|
92
|
+
pid: process.pid,
|
|
93
|
+
host: hostname(),
|
|
94
|
+
bootId: currentBootId(),
|
|
95
|
+
heartbeatAt: now,
|
|
96
|
+
startedAt: claim.startedAt ?? now,
|
|
97
|
+
...claim,
|
|
98
|
+
};
|
|
99
|
+
try {
|
|
100
|
+
await io.mkdir(dir);
|
|
101
|
+
await io.writeFile(join(dir, `${record.opId}.yaml`), yamlStringify(record));
|
|
102
|
+
return true;
|
|
103
|
+
} catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Refresh a live claim's heartbeat — best-effort, same path. */
|
|
109
|
+
export async function heartbeatOp(repo: string, io: WorkspaceIO, opId: string): Promise<void> {
|
|
110
|
+
const dir = await opsDir(repo, io);
|
|
111
|
+
if (dir === null) return;
|
|
112
|
+
const file = join(dir, `${opId}.yaml`);
|
|
113
|
+
try {
|
|
114
|
+
const parsed = yamlParse(await io.readFile(file)) as Partial<OpClaim> | null;
|
|
115
|
+
if (!parsed || parsed.schema !== OP_CLAIM_SCHEMA) return;
|
|
116
|
+
parsed.heartbeatAt = new Date().toISOString();
|
|
117
|
+
await io.writeFile(file, yamlStringify(parsed));
|
|
118
|
+
} catch {
|
|
119
|
+
/* best-effort */
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Best-effort removal — liveness, not deletion, is authoritative. */
|
|
124
|
+
export async function releaseOp(repo: string, io: WorkspaceIO, opId: string): Promise<void> {
|
|
125
|
+
const dir = await opsDir(repo, io);
|
|
126
|
+
if (dir === null) return;
|
|
127
|
+
try {
|
|
128
|
+
await io.rm(join(dir, `${opId}.yaml`));
|
|
129
|
+
} catch {
|
|
130
|
+
/* already gone */
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function parseClaim(raw: string): OpClaim | null {
|
|
135
|
+
let parsed: unknown;
|
|
136
|
+
try {
|
|
137
|
+
parsed = yamlParse(raw);
|
|
138
|
+
} catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
142
|
+
const c = parsed as Partial<OpClaim>;
|
|
143
|
+
if (
|
|
144
|
+
c.schema !== OP_CLAIM_SCHEMA ||
|
|
145
|
+
typeof c.opId !== "string" ||
|
|
146
|
+
typeof c.command !== "string" ||
|
|
147
|
+
typeof c.pid !== "number" ||
|
|
148
|
+
typeof c.host !== "string" ||
|
|
149
|
+
typeof c.startedAt !== "string" ||
|
|
150
|
+
typeof c.heartbeatAt !== "string" ||
|
|
151
|
+
typeof c.workspaceRoot !== "string" ||
|
|
152
|
+
!Array.isArray(c.paths)
|
|
153
|
+
) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
return c as OpClaim;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Live claims for `repo`, sweeping dead/stale records lazily as a side
|
|
161
|
+
* effect. Malformed files sweep too — a record we cannot read cannot be
|
|
162
|
+
* liveness-checked and must never grant tolerance.
|
|
163
|
+
*/
|
|
164
|
+
async function readClaims(repo: string, io: WorkspaceIO): Promise<{ live: OpClaim[]; dead: string[] }> {
|
|
165
|
+
const dir = await opsDir(repo, io);
|
|
166
|
+
if (dir === null || !(await io.exists(dir))) return { live: [], dead: [] };
|
|
167
|
+
const files = (await io.glob("*.yaml", { cwd: dir })).filter((f) => !f.endsWith("/"));
|
|
168
|
+
const live: OpClaim[] = [];
|
|
169
|
+
const dead: string[] = [];
|
|
170
|
+
for (const f of files) {
|
|
171
|
+
const abs = join(dir, f);
|
|
172
|
+
const claim = parseClaim(await io.readFile(abs));
|
|
173
|
+
if (claim !== null && isClaimLive(claim)) live.push(claim);
|
|
174
|
+
else dead.push(abs);
|
|
175
|
+
}
|
|
176
|
+
return { live, dead };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Read-only variant for surfaces that must not mutate (flow.peers). */
|
|
180
|
+
export async function liveClaimsReadOnly(repo: string, io: WorkspaceIO): Promise<OpClaim[]> {
|
|
181
|
+
return (await readClaims(repo, io)).live;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export async function liveClaims(repo: string, io: WorkspaceIO): Promise<OpClaim[]> {
|
|
185
|
+
const { live, dead } = await readClaims(repo, io);
|
|
186
|
+
for (const abs of dead) {
|
|
187
|
+
try {
|
|
188
|
+
await io.rm(abs);
|
|
189
|
+
} catch {
|
|
190
|
+
/* sweep is best-effort */
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return live;
|
|
194
|
+
}
|