@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
|
@@ -0,0 +1,974 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>flow.integrate preflight (RFC-1528) — a bounded, deterministic check list that
|
|
4
|
+
runs between the dirty-tree checks and the integration-gate spawn, refusing in
|
|
5
|
+
seconds what the gate would catch minutes later. Ordered: (1) worktree dirty +
|
|
6
|
+
lockfile-diff classification, (2) primary tracked dirt + classification,
|
|
7
|
+
(3) ecosystem.manifest.validate, (4) rfc.validate --id per changed RFC file,
|
|
8
|
+
(5) friction.validate. Each check runs only when resolvable (invoke port +
|
|
9
|
+
registry entry) — absence degrades with a note, never blocks. The list is
|
|
10
|
+
closed by the RFC: adding a check requires an amendment.</purpose>
|
|
11
|
+
<non-goals>
|
|
12
|
+
<item>No auto-fix, no auto-commit — the lockfile classifier only labels the importer-prune-only shape with a remedy hint; a dirty pnpm-lock.yaml still refuses.</item>
|
|
13
|
+
<item>No builds, no test suites — sub-minute deterministic validators only.</item>
|
|
14
|
+
</non-goals>
|
|
15
|
+
</MODULE_CONTRACT>
|
|
16
|
+
<CHANGE_SUMMARY>
|
|
17
|
+
<item>RFC-1531: shared DirtyClass enum via dirty-classify.ts (Q-4), classified FLOW-INT-01/03 data.entries, classifyDirtyEntries for the remediation flags</item>
|
|
18
|
+
<item>RFC-1546: derive-and-repair recoverable state across flow surfaces (AC-1..AC-5)</item>
|
|
19
|
+
<item>RFC-1545: standalone generated-conflict regeneration in flow.integrate</item>
|
|
20
|
+
<item>RFC-1543: attribute shared-checkout dirt to live ops and expose peers (RFC-1543)</item>
|
|
21
|
+
<item>RFC-1544: attribute mission lockfile churn to owning checkout and auto-resolve foreign importer diffs (RFC-1544)</item>
|
|
22
|
+
<history>RFC-1528, RFC-1537, RFC-1538</history>
|
|
23
|
+
</CHANGE_SUMMARY>
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { basename, dirname, join } from "node:path";
|
|
27
|
+
|
|
28
|
+
import type {
|
|
29
|
+
CommandRegistry,
|
|
30
|
+
ForgeFlagValue,
|
|
31
|
+
ForgeInvokeCommand,
|
|
32
|
+
ForgeRegisteredCommandInfo,
|
|
33
|
+
WorkspaceIO,
|
|
34
|
+
} from "../../src/types.ts";
|
|
35
|
+
import { loadLiveCommandInventory } from "../../src/utils/command-inventory.ts";
|
|
36
|
+
import { isGeneratedContent, isGeneratedPathName, REGEN_FLAGS } from "../core/archive-regen.ts";
|
|
37
|
+
import { openMissionsIn } from "../mission/open-missions.ts";
|
|
38
|
+
import {
|
|
39
|
+
classifyDirtyPath,
|
|
40
|
+
summarizeClasses,
|
|
41
|
+
type ClassifiedDirtyEntry,
|
|
42
|
+
type DirtyClass,
|
|
43
|
+
} from "./dirty-classify.ts";
|
|
44
|
+
import { currentBranch, git, statusTracked, worktreeList } from "./git.ts";
|
|
45
|
+
import { canonicalRepoDir } from "../../src/utils/repo-path.ts";
|
|
46
|
+
import { claimCoversPath, liveClaims, type OpClaim } from "./ops-registry.ts";
|
|
47
|
+
|
|
48
|
+
export type LockfileClassification = "importer-prune-only" | "other";
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Strict match for the pnpm-prune shape: ONLY removed lines, every one either
|
|
52
|
+
* a `missions/<id>/workpiece:` importer key or a deeper-indented member of
|
|
53
|
+
* such a key's block. Returns the sorted pruned mission ids on match, null
|
|
54
|
+
* otherwise — any added line, any other removed line, or a diff with no
|
|
55
|
+
* removals is ambiguous and stays an ordinary refusal.
|
|
56
|
+
*/
|
|
57
|
+
export function classifyLockfilePruneIds(diffText: string): string[] | null {
|
|
58
|
+
const ids = new Set<string>();
|
|
59
|
+
let sawImporterKey = false;
|
|
60
|
+
let openBlockIndent: number | null = null;
|
|
61
|
+
for (const raw of diffText.split("\n")) {
|
|
62
|
+
if (
|
|
63
|
+
raw === "" ||
|
|
64
|
+
raw.startsWith("diff ") ||
|
|
65
|
+
raw.startsWith("index ") ||
|
|
66
|
+
raw.startsWith("---") ||
|
|
67
|
+
raw.startsWith("+++") ||
|
|
68
|
+
raw.startsWith("@@")
|
|
69
|
+
) {
|
|
70
|
+
if (raw.startsWith("@@")) openBlockIndent = null;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (raw.startsWith("+")) return null;
|
|
74
|
+
const line = raw.slice(1);
|
|
75
|
+
if (raw[0] === " ") {
|
|
76
|
+
const indent = line.length - line.trimStart().length;
|
|
77
|
+
if (openBlockIndent !== null && line.trim().length > 0 && indent <= openBlockIndent) {
|
|
78
|
+
openBlockIndent = null;
|
|
79
|
+
}
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (raw[0] !== "-") continue;
|
|
83
|
+
if (line.trim().length === 0) {
|
|
84
|
+
// A blank removed line only tolerates inside an open importer block.
|
|
85
|
+
if (openBlockIndent === null) return null;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const indent = line.length - line.trimStart().length;
|
|
89
|
+
const key = /^\s*missions\/([^\s/]+)\/workpiece:\s*$/.exec(line);
|
|
90
|
+
if (key) {
|
|
91
|
+
sawImporterKey = true;
|
|
92
|
+
ids.add(key[1]);
|
|
93
|
+
openBlockIndent = indent;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (openBlockIndent !== null && indent > openBlockIndent) continue;
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return sawImporterKey ? [...ids].sort() : null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function classifyLockfileDiff(diffText: string): LockfileClassification {
|
|
103
|
+
return classifyLockfilePruneIds(diffText) !== null ? "importer-prune-only" : "other";
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Mirror of the prune shape for materialization (RFC-1537): ONLY added lines,
|
|
108
|
+
* every one either a `missions/<id>/workpiece:` importer key or a deeper-
|
|
109
|
+
* indented member of such a block. Returns the sorted mission ids on match,
|
|
110
|
+
* null otherwise — any removal or foreign addition is ambiguous.
|
|
111
|
+
*/
|
|
112
|
+
export function classifyLockfileMaterialize(diffText: string): string[] | null {
|
|
113
|
+
const ids = new Set<string>();
|
|
114
|
+
let sawImporterKey = false;
|
|
115
|
+
let openBlockIndent: number | null = null;
|
|
116
|
+
for (const raw of diffText.split("\n")) {
|
|
117
|
+
if (
|
|
118
|
+
raw === "" ||
|
|
119
|
+
raw.startsWith("diff ") ||
|
|
120
|
+
raw.startsWith("index ") ||
|
|
121
|
+
raw.startsWith("---") ||
|
|
122
|
+
raw.startsWith("+++") ||
|
|
123
|
+
raw.startsWith("@@")
|
|
124
|
+
) {
|
|
125
|
+
if (raw.startsWith("@@")) openBlockIndent = null;
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (raw.startsWith("-")) return null;
|
|
129
|
+
const line = raw.slice(1);
|
|
130
|
+
if (raw[0] === " ") {
|
|
131
|
+
const indent = line.length - line.trimStart().length;
|
|
132
|
+
if (openBlockIndent !== null && line.trim().length > 0 && indent <= openBlockIndent) {
|
|
133
|
+
openBlockIndent = null;
|
|
134
|
+
}
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (raw[0] !== "+") continue;
|
|
138
|
+
if (line.trim().length === 0) {
|
|
139
|
+
// A blank added line only tolerates inside an open importer block.
|
|
140
|
+
if (openBlockIndent === null) return null;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const indent = line.length - line.trimStart().length;
|
|
144
|
+
const key = /^\s*missions\/([^\s/]+)\/workpiece:\s*$/.exec(line);
|
|
145
|
+
if (key) {
|
|
146
|
+
sawImporterKey = true;
|
|
147
|
+
ids.add(key[1]);
|
|
148
|
+
openBlockIndent = indent;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (openBlockIndent !== null && indent > openBlockIndent) continue;
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
return sawImporterKey ? [...ids].sort() : null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Classify the pnpm-lock.yaml diff of `repo` when the lockfile is dirty. */
|
|
158
|
+
async function classifyDirtyLockfile(
|
|
159
|
+
repo: string,
|
|
160
|
+
io: WorkspaceIO,
|
|
161
|
+
dirtyEntries: string[],
|
|
162
|
+
runGit: typeof git,
|
|
163
|
+
): Promise<LockfileClassification | null> {
|
|
164
|
+
const lockfileDirty = dirtyEntries.some((entry) => entry.slice(3).trim() === "pnpm-lock.yaml");
|
|
165
|
+
if (!lockfileDirty) return null;
|
|
166
|
+
const diff = await runGit(repo, io, ["diff", "HEAD", "--", "pnpm-lock.yaml"]);
|
|
167
|
+
return classifyLockfileDiff(diff.stdout);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// ── RFC-1537: regenerable dirt classifier ────────────────────────────────
|
|
171
|
+
// Q-4 (RFC-1531): the class enum is shared — dirty-classify.ts owns the
|
|
172
|
+
// closed vocabulary; this module only assigns its diff-aware members.
|
|
173
|
+
|
|
174
|
+
export type { DirtyClass } from "./dirty-classify.ts";
|
|
175
|
+
|
|
176
|
+
export interface ToleratedEntry {
|
|
177
|
+
path: string;
|
|
178
|
+
class: DirtyClass;
|
|
179
|
+
/** RFC-1544: pruned mission ids for the lockfile importer classes. */
|
|
180
|
+
missionIds?: string[];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* RFC-1544: referent state for one pruned `missions/<id>/workpiece` importer
|
|
185
|
+
* — where the directory still exists and whether its mission is open. The
|
|
186
|
+
* classifier stays pure: referents are injected by the caller.
|
|
187
|
+
*/
|
|
188
|
+
export interface ImporterReferent {
|
|
189
|
+
missionId: string;
|
|
190
|
+
/** `missions/<id>/workpiece` exists in the checkout being classified. */
|
|
191
|
+
existsHere: boolean;
|
|
192
|
+
/** Other registered worktrees where the directory exists. */
|
|
193
|
+
existsInCheckout: string[];
|
|
194
|
+
/** An open `missions/<id>/mission.yaml` exists in any registered checkout. */
|
|
195
|
+
missionOpen: boolean;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Default referent resolver — `git worktree list` for the checkout set and
|
|
200
|
+
* `openMissionsIn` per checkout for mission state (the same enumeration
|
|
201
|
+
* `flow.status` performs; never cwd-relative guesses).
|
|
202
|
+
*/
|
|
203
|
+
export async function resolveImporterReferents(
|
|
204
|
+
repo: string,
|
|
205
|
+
io: WorkspaceIO,
|
|
206
|
+
missionIds: string[],
|
|
207
|
+
): Promise<ImporterReferent[]> {
|
|
208
|
+
const worktrees = await worktreeList(repo, io);
|
|
209
|
+
const here = canonicalRepoDir(repo);
|
|
210
|
+
const others = worktrees.filter((w) => w.path !== here).map((w) => w.path);
|
|
211
|
+
const openCache = new Map<string, Set<string>>();
|
|
212
|
+
const openIn = async (dir: string): Promise<Set<string>> => {
|
|
213
|
+
let set = openCache.get(dir);
|
|
214
|
+
if (set === undefined) {
|
|
215
|
+
try {
|
|
216
|
+
set = new Set(await openMissionsIn(dir, io));
|
|
217
|
+
} catch {
|
|
218
|
+
set = new Set();
|
|
219
|
+
}
|
|
220
|
+
openCache.set(dir, set);
|
|
221
|
+
}
|
|
222
|
+
return set;
|
|
223
|
+
};
|
|
224
|
+
const out: ImporterReferent[] = [];
|
|
225
|
+
for (const missionId of missionIds) {
|
|
226
|
+
const rel = join("missions", missionId, "workpiece");
|
|
227
|
+
const existsHere = await io.exists(join(repo, rel));
|
|
228
|
+
const existsInCheckout: string[] = [];
|
|
229
|
+
for (const dir of others) {
|
|
230
|
+
if (await io.exists(join(dir, rel))) existsInCheckout.push(dir);
|
|
231
|
+
}
|
|
232
|
+
let missionOpen = (await openIn(repo)).has(missionId);
|
|
233
|
+
for (const dir of others) {
|
|
234
|
+
if (!missionOpen && (await openIn(dir)).has(missionId)) missionOpen = true;
|
|
235
|
+
}
|
|
236
|
+
out.push({ missionId, existsHere, existsInCheckout: existsInCheckout.sort(), missionOpen });
|
|
237
|
+
}
|
|
238
|
+
return out;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface DirtVerdict {
|
|
242
|
+
tolerated: ToleratedEntry[];
|
|
243
|
+
/** Porcelain lines that match no declared regenerable shape — still refuse. */
|
|
244
|
+
unattributed: string[];
|
|
245
|
+
/**
|
|
246
|
+
* RFC-1543: unattributed paths covered by a LIVE op-claim — class
|
|
247
|
+
* `in-flight-foreign`. They never block silently: the caller either waits
|
|
248
|
+
* for the holder or refuses FLOW-INT-03 naming it. Resolved only for the
|
|
249
|
+
* primary checkout — worktrees are single-owner.
|
|
250
|
+
*/
|
|
251
|
+
foreignInFlight: { path: string; holder: OpClaim }[];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const TWIN_ROOT = ".agents/skills/";
|
|
255
|
+
|
|
256
|
+
/** Canonical candidates for a `.agents/skills/<dir>/<rel>` twin path. */
|
|
257
|
+
function twinCanonicalCandidates(dir: string, rel: string): string[] {
|
|
258
|
+
const candidates = [
|
|
259
|
+
`packages/forge/skills/${dir}/${rel}`,
|
|
260
|
+
`packages/forge/skills/fo/${dir}/${rel}`,
|
|
261
|
+
`packages/forge/skills/meta/${dir}/${rel}`,
|
|
262
|
+
`packages/werkstatt-site/src/domain/skills/${dir}/${rel}`,
|
|
263
|
+
];
|
|
264
|
+
if (dir === "shared-knowledge") {
|
|
265
|
+
candidates.push(`packages/forge/skills/shared/knowledge/${rel}`);
|
|
266
|
+
}
|
|
267
|
+
return candidates;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
async function fileBytesEqual(a: string, b: string, io: WorkspaceIO): Promise<boolean> {
|
|
271
|
+
const [ba, bb] = await Promise.all([io.readFileBytes(a), io.readFileBytes(b)]);
|
|
272
|
+
return ba.length === bb.length && ba.every((v, i) => v === bb[i]);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** `.prettierignore` diff is twin-sync only when every change adds .agents/skills/ lines. */
|
|
276
|
+
function prettierignoreTwinOnly(diffText: string): boolean {
|
|
277
|
+
let saw = false;
|
|
278
|
+
for (const raw of diffText.split("\n")) {
|
|
279
|
+
if (
|
|
280
|
+
raw === "" ||
|
|
281
|
+
raw.startsWith("diff ") ||
|
|
282
|
+
raw.startsWith("index ") ||
|
|
283
|
+
raw.startsWith("---") ||
|
|
284
|
+
raw.startsWith("+++") ||
|
|
285
|
+
raw.startsWith("@@") ||
|
|
286
|
+
raw.startsWith(" ")
|
|
287
|
+
) {
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
if (raw.startsWith("-")) return false;
|
|
291
|
+
if (raw.startsWith("+")) {
|
|
292
|
+
if (!/^\+\s*\.agents\/skills\/[^\s]+\/?\s*$/.test(raw)) return false;
|
|
293
|
+
saw = true;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return saw;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Partition porcelain lines into declared regenerable classes (tolerated —
|
|
301
|
+
* journaled, never committed) and `unattributed` lines that still refuse.
|
|
302
|
+
* The shapes are closed by RFC-1537: ambiguity always degrades to
|
|
303
|
+
* unattributed, never to tolerance.
|
|
304
|
+
*/
|
|
305
|
+
export async function classifyDirt(
|
|
306
|
+
repo: string,
|
|
307
|
+
io: WorkspaceIO,
|
|
308
|
+
entries: string[],
|
|
309
|
+
deps: { runGit: typeof git } = { runGit: git },
|
|
310
|
+
claims: OpClaim[] = [],
|
|
311
|
+
resolveReferents?: (missionIds: string[]) => Promise<ImporterReferent[]>,
|
|
312
|
+
): Promise<DirtVerdict> {
|
|
313
|
+
const tolerated: ToleratedEntry[] = [];
|
|
314
|
+
const unattributed: string[] = [];
|
|
315
|
+
const foreignInFlight: { path: string; holder: OpClaim }[] = [];
|
|
316
|
+
const byPath = new Map<string, string[]>();
|
|
317
|
+
for (const line of entries) {
|
|
318
|
+
const p = line.slice(3).trim();
|
|
319
|
+
byPath.set(p, [...(byPath.get(p) ?? []), line]);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
let openMissions: Set<string> | null = null;
|
|
323
|
+
const openMissionIds = async (): Promise<Set<string>> => {
|
|
324
|
+
if (openMissions === null) {
|
|
325
|
+
openMissions = new Set(await openMissionsIn(repo, io));
|
|
326
|
+
}
|
|
327
|
+
return openMissions;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
outer: for (const [path, lines] of byPath) {
|
|
331
|
+
if (path === "pnpm-lock.yaml") {
|
|
332
|
+
const diff = await deps.runGit(repo, io, ["diff", "HEAD", "--", "pnpm-lock.yaml"]);
|
|
333
|
+
const pruneIds = classifyLockfilePruneIds(diff.stdout);
|
|
334
|
+
if (pruneIds !== null) {
|
|
335
|
+
// RFC-1544: the pruned importer's referent decides the class — a
|
|
336
|
+
// foreign checkout's open mission (foreign-open-mission, auto-
|
|
337
|
+
// restored by flow.integrate), dead residue (importer-prune-stale,
|
|
338
|
+
// accepted cleanup), or anything else (importer-prune, unchanged).
|
|
339
|
+
// An unresolvable referent set (no exec/ io capability) degrades to
|
|
340
|
+
// the inert importer-prune — "couldn't resolve" is not "resolved to
|
|
341
|
+
// nothing".
|
|
342
|
+
let referents: ImporterReferent[] | undefined;
|
|
343
|
+
if (resolveReferents !== undefined) {
|
|
344
|
+
try {
|
|
345
|
+
referents = await resolveReferents(pruneIds);
|
|
346
|
+
} catch {
|
|
347
|
+
referents = undefined;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (
|
|
351
|
+
referents !== undefined &&
|
|
352
|
+
referents.every((r) => !r.existsHere && r.missionOpen && r.existsInCheckout.length > 0)
|
|
353
|
+
) {
|
|
354
|
+
tolerated.push({ path, class: "foreign-open-mission", missionIds: pruneIds });
|
|
355
|
+
} else if (
|
|
356
|
+
referents !== undefined &&
|
|
357
|
+
referents.every((r) => !r.existsHere && r.existsInCheckout.length === 0 && !r.missionOpen)
|
|
358
|
+
) {
|
|
359
|
+
tolerated.push({ path, class: "importer-prune-stale", missionIds: pruneIds });
|
|
360
|
+
} else {
|
|
361
|
+
tolerated.push({ path, class: "importer-prune", missionIds: pruneIds });
|
|
362
|
+
}
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
const ids = classifyLockfileMaterialize(diff.stdout);
|
|
366
|
+
if (ids !== null) {
|
|
367
|
+
const open = await openMissionIds();
|
|
368
|
+
if (ids.every((id) => open.has(id))) {
|
|
369
|
+
tolerated.push({ path, class: "importer-materialize" });
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
unattributed.push(...lines);
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
if (path === ".prettierignore") {
|
|
377
|
+
const diff = await deps.runGit(repo, io, ["diff", "HEAD", "--", ".prettierignore"]);
|
|
378
|
+
if (prettierignoreTwinOnly(diff.stdout)) {
|
|
379
|
+
tolerated.push({ path, class: "skill-twin-sync" });
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
unattributed.push(...lines);
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
if (path.startsWith(TWIN_ROOT) && path.length > TWIN_ROOT.length) {
|
|
386
|
+
const rel = path.slice(TWIN_ROOT.length).replace(/\/$/, "");
|
|
387
|
+
const dir = rel.split("/")[0];
|
|
388
|
+
const fileRel = rel.slice(dir.length + 1);
|
|
389
|
+
if (fileRel === "") {
|
|
390
|
+
// `?? .agents/skills/<dir>/` — an untracked twin DIRECTORY. Fail
|
|
391
|
+
// closed: every file inside must byte-match a canonical source or be
|
|
392
|
+
// the .forge-managed marker beside one; a single stray stays dirty.
|
|
393
|
+
const canonicalDir = async (): Promise<boolean> => {
|
|
394
|
+
for (const c of twinCanonicalCandidates(dir, "SKILL.md")) {
|
|
395
|
+
if (await io.exists(join(repo, dirname(c)))) return true;
|
|
396
|
+
}
|
|
397
|
+
return false;
|
|
398
|
+
};
|
|
399
|
+
const files = (await io.glob(`${TWIN_ROOT}${rel}/**`, { cwd: repo })).filter(
|
|
400
|
+
(f) => !f.endsWith("/"),
|
|
401
|
+
);
|
|
402
|
+
let allTwins = files.length > 0 && (await canonicalDir());
|
|
403
|
+
for (const f of allTwins ? files : []) {
|
|
404
|
+
const frel = f.slice(`${TWIN_ROOT}${rel}/`.length);
|
|
405
|
+
if (frel === ".forge-managed") continue;
|
|
406
|
+
let matched = false;
|
|
407
|
+
for (const c of twinCanonicalCandidates(dir, frel)) {
|
|
408
|
+
const abs = join(repo, c);
|
|
409
|
+
if ((await io.exists(abs)) && (await fileBytesEqual(join(repo, f), abs, io))) {
|
|
410
|
+
matched = true;
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (!matched) {
|
|
415
|
+
allTwins = false;
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
if (allTwins) tolerated.push({ path, class: "skill-twin-sync" });
|
|
420
|
+
else unattributed.push(...lines);
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
if (fileRel === ".forge-managed") {
|
|
424
|
+
// Twin bookkeeping file — tolerated when the dir has any canonical
|
|
425
|
+
// skill source; a free-floating marker is real dirt.
|
|
426
|
+
let markerOk = false;
|
|
427
|
+
for (const c of twinCanonicalCandidates(dir, "SKILL.md")) {
|
|
428
|
+
if (await io.exists(join(repo, dirname(c)))) {
|
|
429
|
+
markerOk = true;
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
if (markerOk) tolerated.push({ path, class: "skill-twin-sync" });
|
|
434
|
+
else unattributed.push(...lines);
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
let matched = false;
|
|
438
|
+
for (const c of twinCanonicalCandidates(dir, fileRel)) {
|
|
439
|
+
const abs = join(repo, c);
|
|
440
|
+
if ((await io.exists(abs)) && (await fileBytesEqual(join(repo, path), abs, io))) {
|
|
441
|
+
matched = true;
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if (matched) tolerated.push({ path, class: "skill-twin-sync" });
|
|
446
|
+
else unattributed.push(...lines);
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
unattributed.push(...lines);
|
|
450
|
+
}
|
|
451
|
+
// RFC-1543 AC-3: unattributed paths covered by a live claim reclassify as
|
|
452
|
+
// in-flight-foreign — every other unattributed path stays work-class.
|
|
453
|
+
if (claims.length > 0) {
|
|
454
|
+
const stillUnattributed: string[] = [];
|
|
455
|
+
for (const line of unattributed) {
|
|
456
|
+
const path = line.slice(3).trim();
|
|
457
|
+
const holder = claims.find((c) => claimCoversPath(c, path));
|
|
458
|
+
if (holder !== undefined) foreignInFlight.push({ path, holder });
|
|
459
|
+
else stillUnattributed.push(line);
|
|
460
|
+
}
|
|
461
|
+
unattributed.length = 0;
|
|
462
|
+
unattributed.push(...stillUnattributed);
|
|
463
|
+
}
|
|
464
|
+
return { tolerated, unattributed, foreignInFlight };
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* RFC-1531 AC-6: classify EVERY dirty entry — tolerated-family classes come
|
|
469
|
+
* from the diff-aware classifyDirt; the remaining entries get their
|
|
470
|
+
* path-only class (disposable or work — importer/twin classes can only be
|
|
471
|
+
* diff-assigned, so they never appear here). Used for FLOW-INT-01's
|
|
472
|
+
* data.entries and by the remediation flags.
|
|
473
|
+
*/
|
|
474
|
+
export async function classifyDirtyEntries(
|
|
475
|
+
repo: string,
|
|
476
|
+
io: WorkspaceIO,
|
|
477
|
+
entries: string[],
|
|
478
|
+
deps: { runGit: typeof git } = { runGit: git },
|
|
479
|
+
): Promise<ClassifiedDirtyEntry[]> {
|
|
480
|
+
const verdict = await classifyDirt(repo, io, entries, deps);
|
|
481
|
+
const out: ClassifiedDirtyEntry[] = verdict.tolerated.map((t) => ({
|
|
482
|
+
path: t.path,
|
|
483
|
+
class: t.class,
|
|
484
|
+
}));
|
|
485
|
+
for (const f of verdict.foreignInFlight) {
|
|
486
|
+
out.push({ path: f.path, class: "in-flight-foreign" });
|
|
487
|
+
}
|
|
488
|
+
for (const line of verdict.unattributed) {
|
|
489
|
+
const path = line.slice(3).trim();
|
|
490
|
+
out.push({ path, class: classifyDirtyPath(path) });
|
|
491
|
+
}
|
|
492
|
+
return out;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
const LOCKFILE_PRUNE_HINT =
|
|
496
|
+
" — its diff matches the vanished mission-importer prune shape; restore it " +
|
|
497
|
+
"(`git checkout -- pnpm-lock.yaml` is blocked for agents: copy HEAD bytes " +
|
|
498
|
+
"with `git show HEAD:pnpm-lock.yaml > pnpm-lock.yaml`) or commit the prune deliberately";
|
|
499
|
+
|
|
500
|
+
export interface PreflightRefuse {
|
|
501
|
+
ruleId: string;
|
|
502
|
+
message: string;
|
|
503
|
+
fixHint: string;
|
|
504
|
+
data?: Record<string, unknown>;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
export interface PreflightSkip {
|
|
508
|
+
check: string;
|
|
509
|
+
reason: "no-invoke" | "unresolvable";
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export interface IntegratePreflightResult {
|
|
513
|
+
ok: boolean;
|
|
514
|
+
/** Check names that ran, in order. */
|
|
515
|
+
checked: string[];
|
|
516
|
+
/** Checks skipped — invoke port absent, or command not in the inventory. */
|
|
517
|
+
skipped: PreflightSkip[];
|
|
518
|
+
/** RFC-1537: regenerable dirt tolerated on this run — journaled, never
|
|
519
|
+
* committed or silently absorbed. */
|
|
520
|
+
tolerated: ToleratedEntry[];
|
|
521
|
+
refuse?: PreflightRefuse;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* The bounded preflight — first failure wins. `deps` seams exist for tests;
|
|
526
|
+
* production passes the real git helpers.
|
|
527
|
+
*/
|
|
528
|
+
export async function runIntegratePreflight(
|
|
529
|
+
opts: {
|
|
530
|
+
primary: string;
|
|
531
|
+
branchWorktree: string;
|
|
532
|
+
branch: string;
|
|
533
|
+
io: WorkspaceIO;
|
|
534
|
+
/** Already-computed statusDirty() of the branch worktree. */
|
|
535
|
+
worktreeDirty: { entries: string[]; toleratedState: string[] };
|
|
536
|
+
invoke?: ForgeInvokeCommand;
|
|
537
|
+
/**
|
|
538
|
+
* RFC-1543 AC-4: seconds to wait for live foreign claim-holders before
|
|
539
|
+
* FLOW-INT-03 refuses — default 600, 0 restores fail-fast.
|
|
540
|
+
*/
|
|
541
|
+
waitForeignSeconds?: number;
|
|
542
|
+
onProgress?: (line: string) => void;
|
|
543
|
+
commandRegistry?: CommandRegistry;
|
|
544
|
+
/** Test seam — overrides the live inventory union (registry + command manifest). */
|
|
545
|
+
commands?: ForgeRegisteredCommandInfo[];
|
|
546
|
+
},
|
|
547
|
+
deps: {
|
|
548
|
+
runGit: typeof git;
|
|
549
|
+
runStatusTracked: typeof statusTracked;
|
|
550
|
+
runCurrentBranch: typeof currentBranch;
|
|
551
|
+
} = { runGit: git, runStatusTracked: statusTracked, runCurrentBranch: currentBranch },
|
|
552
|
+
): Promise<IntegratePreflightResult> {
|
|
553
|
+
const checked: string[] = [];
|
|
554
|
+
const skipped: PreflightSkip[] = [];
|
|
555
|
+
const tolerated: ToleratedEntry[] = [];
|
|
556
|
+
const { io } = opts;
|
|
557
|
+
// D-001 union: werkstatt run supplies invoke but no commandRegistry — the
|
|
558
|
+
// generated manifest (in the primary checkout) covers resolvability.
|
|
559
|
+
const commands = opts.commands ?? loadLiveCommandInventory(opts.primary, opts.commandRegistry);
|
|
560
|
+
const commandNames = new Set(commands.map((c) => c.name));
|
|
561
|
+
const resolvable = (name: string) => opts.invoke !== undefined && commandNames.has(name);
|
|
562
|
+
|
|
563
|
+
// (0) open mission in the integrating worktree — WT-GATE-01 semantics at
|
|
564
|
+
// preflight price (RFC-1537): ahead of every validator arm and even the
|
|
565
|
+
// dirty checks, since a live mission outranks a dirty tree. A scan failure
|
|
566
|
+
// skips with a note — the downstream gate still enforces.
|
|
567
|
+
try {
|
|
568
|
+
const openMissions = await openMissionsIn(opts.branchWorktree, io);
|
|
569
|
+
checked.push("open-mission");
|
|
570
|
+
if (openMissions.length > 0) {
|
|
571
|
+
return {
|
|
572
|
+
ok: false,
|
|
573
|
+
checked,
|
|
574
|
+
skipped,
|
|
575
|
+
tolerated,
|
|
576
|
+
refuse: {
|
|
577
|
+
ruleId: "WT-GATE-01",
|
|
578
|
+
message: `worktree has ${openMissions.length} open mission(s): ${openMissions.join(", ")}`,
|
|
579
|
+
fixHint:
|
|
580
|
+
"close or abort the mission(s) in the worktree before integrating or tearing down",
|
|
581
|
+
data: { openMissions },
|
|
582
|
+
},
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
} catch {
|
|
586
|
+
skipped.push({ check: "open-mission", reason: "unresolvable" });
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// (1) worktree dirty — FLOW-INT-01 only on unattributed entries; declared
|
|
590
|
+
// regenerable classes journal as tolerated (RFC-1537).
|
|
591
|
+
checked.push("worktree-dirty");
|
|
592
|
+
if (opts.worktreeDirty.entries.length > 0) {
|
|
593
|
+
const verdict = await classifyDirt(
|
|
594
|
+
opts.branchWorktree,
|
|
595
|
+
io,
|
|
596
|
+
opts.worktreeDirty.entries,
|
|
597
|
+
{
|
|
598
|
+
runGit: deps.runGit,
|
|
599
|
+
},
|
|
600
|
+
[],
|
|
601
|
+
(ids) => resolveImporterReferents(opts.branchWorktree, io, ids),
|
|
602
|
+
);
|
|
603
|
+
tolerated.push(...verdict.tolerated);
|
|
604
|
+
if (verdict.unattributed.length > 0) {
|
|
605
|
+
const lockfile = await classifyDirtyLockfile(
|
|
606
|
+
opts.branchWorktree,
|
|
607
|
+
io,
|
|
608
|
+
verdict.unattributed,
|
|
609
|
+
deps.runGit,
|
|
610
|
+
);
|
|
611
|
+
return {
|
|
612
|
+
ok: false,
|
|
613
|
+
checked,
|
|
614
|
+
skipped,
|
|
615
|
+
tolerated,
|
|
616
|
+
refuse: {
|
|
617
|
+
ruleId: "FLOW-INT-01",
|
|
618
|
+
message:
|
|
619
|
+
`worktree ${opts.branchWorktree} has ${verdict.unattributed.length} uncommitted change(s): ${verdict.unattributed.slice(0, 10).join(", ")}` +
|
|
620
|
+
(verdict.tolerated.length > 0
|
|
621
|
+
? ` — tolerated regenerable state: ${verdict.tolerated.map((t) => `${t.path} (${t.class})`).join(", ")}`
|
|
622
|
+
: "") +
|
|
623
|
+
(opts.worktreeDirty.toleratedState.length > 0
|
|
624
|
+
? ` — tolerated forge-local state: ${opts.worktreeDirty.toleratedState.join(", ")}`
|
|
625
|
+
: "") +
|
|
626
|
+
(lockfile === "importer-prune-only" ? ` — pnpm-lock.yaml${LOCKFILE_PRUNE_HINT}` : ""),
|
|
627
|
+
fixHint:
|
|
628
|
+
"commit or revert the uncommitted changes inside the session worktree, or remediate with --auto-clean / --autocommit, then re-run",
|
|
629
|
+
data: {
|
|
630
|
+
// RFC-1531 AC-6: per-path classes so the remedy is read from
|
|
631
|
+
// the diagnostic — disposable members may --auto-clean away,
|
|
632
|
+
// work members must be committed or reverted (or --autocommit).
|
|
633
|
+
entries: verdict.unattributed.map((line) => {
|
|
634
|
+
const path = line.slice(3).trim();
|
|
635
|
+
return { path, class: classifyDirtyPath(path) };
|
|
636
|
+
}),
|
|
637
|
+
classes: summarizeClasses(
|
|
638
|
+
verdict.unattributed.map((line) => {
|
|
639
|
+
const path = line.slice(3).trim();
|
|
640
|
+
return { path, class: classifyDirtyPath(path) };
|
|
641
|
+
}),
|
|
642
|
+
),
|
|
643
|
+
toleratedState: opts.worktreeDirty.toleratedState,
|
|
644
|
+
toleratedDirt: verdict.tolerated,
|
|
645
|
+
...(lockfile !== null ? { lockfileClassification: lockfile } : {}),
|
|
646
|
+
},
|
|
647
|
+
},
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// (2) primary must sit clean on develop — early FLOW-INT-03, same
|
|
653
|
+
// classification; the post-gate check stays (primary can dirty mid-gate).
|
|
654
|
+
checked.push("primary-dirty");
|
|
655
|
+
const primaryBranch = await deps.runCurrentBranch(opts.primary, io);
|
|
656
|
+
// RFC-1543 AC-4: primary-side foreign claims get a bounded wait — the poll
|
|
657
|
+
// re-reads both dirt and claims (≤30s cadence) until they clear or the
|
|
658
|
+
// budget expires; unattributed work refuses instantly as before.
|
|
659
|
+
const waitForeignMs = Math.max(0, (opts.waitForeignSeconds ?? 600) * 1000);
|
|
660
|
+
const foreignDeadline = Date.now() + waitForeignMs;
|
|
661
|
+
let primaryClean = false;
|
|
662
|
+
for (;;) {
|
|
663
|
+
const primaryDirty = await deps.runStatusTracked(opts.primary, io);
|
|
664
|
+
if (primaryDirty.entries.length === 0) {
|
|
665
|
+
primaryClean = true;
|
|
666
|
+
break;
|
|
667
|
+
}
|
|
668
|
+
const verdict = await classifyDirt(
|
|
669
|
+
opts.primary,
|
|
670
|
+
io,
|
|
671
|
+
primaryDirty.entries,
|
|
672
|
+
{ runGit: deps.runGit },
|
|
673
|
+
await liveClaims(opts.primary, io),
|
|
674
|
+
(ids) => resolveImporterReferents(opts.primary, io, ids),
|
|
675
|
+
);
|
|
676
|
+
tolerated.push(...verdict.tolerated);
|
|
677
|
+
const foreignOnly =
|
|
678
|
+
verdict.unattributed.length === 0 &&
|
|
679
|
+
verdict.foreignInFlight.length > 0 &&
|
|
680
|
+
primaryBranch === "develop";
|
|
681
|
+
if (foreignOnly && Date.now() < foreignDeadline) {
|
|
682
|
+
const holders = verdict.foreignInFlight.map(
|
|
683
|
+
(f) =>
|
|
684
|
+
`${f.holder.command} ${f.holder.opId} (pid ${f.holder.pid}, started ${f.holder.startedAt})`,
|
|
685
|
+
);
|
|
686
|
+
opts.onProgress?.(
|
|
687
|
+
`primary held by foreign op(s): ${holders.join("; ")} — waiting up to ${Math.ceil((foreignDeadline - Date.now()) / 1000)}s`,
|
|
688
|
+
);
|
|
689
|
+
await new Promise((r) => setTimeout(r, Math.min(30_000, foreignDeadline - Date.now())));
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
if (
|
|
693
|
+
primaryBranch !== "develop" ||
|
|
694
|
+
verdict.unattributed.length > 0 ||
|
|
695
|
+
verdict.foreignInFlight.length > 0
|
|
696
|
+
) {
|
|
697
|
+
const lockfile = await classifyDirtyLockfile(
|
|
698
|
+
opts.primary,
|
|
699
|
+
io,
|
|
700
|
+
verdict.unattributed,
|
|
701
|
+
deps.runGit,
|
|
702
|
+
);
|
|
703
|
+
const holderNote =
|
|
704
|
+
verdict.foreignInFlight.length > 0
|
|
705
|
+
? ` — in-flight holder(s): ${verdict.foreignInFlight.map((f) => `${f.holder.command} ${f.holder.opId} (pid ${f.holder.pid})`).join("; ")}`
|
|
706
|
+
: "";
|
|
707
|
+
return {
|
|
708
|
+
ok: false,
|
|
709
|
+
checked,
|
|
710
|
+
skipped,
|
|
711
|
+
tolerated,
|
|
712
|
+
refuse: {
|
|
713
|
+
ruleId: "FLOW-INT-03",
|
|
714
|
+
message:
|
|
715
|
+
(primaryBranch !== "develop"
|
|
716
|
+
? `primary worktree is on ${primaryBranch ?? "detached HEAD"}, not develop`
|
|
717
|
+
: verdict.unattributed.length > 0
|
|
718
|
+
? `primary worktree has ${verdict.unattributed.length} uncommitted change(s)`
|
|
719
|
+
: `primary worktree held by ${verdict.foreignInFlight.length} in-flight foreign op(s)`) +
|
|
720
|
+
holderNote +
|
|
721
|
+
(verdict.tolerated.length > 0
|
|
722
|
+
? ` — tolerated regenerable state: ${verdict.tolerated.map((t) => `${t.path} (${t.class})`).join(", ")}`
|
|
723
|
+
: "") +
|
|
724
|
+
(lockfile === "importer-prune-only" ? ` — pnpm-lock.yaml${LOCKFILE_PRUNE_HINT}` : ""),
|
|
725
|
+
fixHint:
|
|
726
|
+
"switch the primary to develop and commit or revert its tracked changes, then re-run — the branch stays rebased",
|
|
727
|
+
data: {
|
|
728
|
+
entries: verdict.unattributed.map((line) => {
|
|
729
|
+
const path = line.slice(3).trim();
|
|
730
|
+
return { path, class: classifyDirtyPath(path) };
|
|
731
|
+
}),
|
|
732
|
+
foreignHolders: verdict.foreignInFlight.map((f) => ({
|
|
733
|
+
path: f.path,
|
|
734
|
+
opId: f.holder.opId,
|
|
735
|
+
command: f.holder.command,
|
|
736
|
+
pid: f.holder.pid,
|
|
737
|
+
startedAt: f.holder.startedAt,
|
|
738
|
+
})),
|
|
739
|
+
toleratedDirt: verdict.tolerated,
|
|
740
|
+
...(lockfile !== null ? { lockfileClassification: lockfile } : {}),
|
|
741
|
+
},
|
|
742
|
+
},
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
primaryClean = true;
|
|
746
|
+
break;
|
|
747
|
+
}
|
|
748
|
+
if (!primaryClean && primaryBranch !== "develop") {
|
|
749
|
+
return {
|
|
750
|
+
ok: false,
|
|
751
|
+
checked,
|
|
752
|
+
skipped,
|
|
753
|
+
tolerated,
|
|
754
|
+
refuse: {
|
|
755
|
+
ruleId: "FLOW-INT-03",
|
|
756
|
+
message: `primary worktree is on ${primaryBranch ?? "detached HEAD"}, not develop`,
|
|
757
|
+
fixHint:
|
|
758
|
+
"switch the primary to develop and commit or revert its tracked changes, then re-run — the branch stays rebased",
|
|
759
|
+
},
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// (3) ecosystem.manifest.validate — stale generated manifest is a
|
|
764
|
+
// recoverable violation (RFC-1546): the failure is recorded and the
|
|
765
|
+
// remaining checks still run. Only when the drift is the SOLE violation
|
|
766
|
+
// does the owner command regenerate in place and the validator re-run —
|
|
767
|
+
// a coexisting refusal below must skip the regeneration entirely.
|
|
768
|
+
let manifestDrift: { summary?: string; exitCode?: number } | undefined;
|
|
769
|
+
if (resolvable("ecosystem.manifest.validate")) {
|
|
770
|
+
checked.push("ecosystem.manifest.validate");
|
|
771
|
+
const result = await opts.invoke!("ecosystem.manifest.validate", {});
|
|
772
|
+
if (result.ok === false || (result.exitCode !== undefined && result.exitCode !== 0)) {
|
|
773
|
+
manifestDrift = { summary: result.summary, exitCode: result.exitCode };
|
|
774
|
+
}
|
|
775
|
+
} else {
|
|
776
|
+
skipped.push({
|
|
777
|
+
check: "ecosystem.manifest.validate",
|
|
778
|
+
reason: opts.invoke === undefined ? "no-invoke" : "unresolvable",
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// (4) rfc.validate --id per changed RFC file on develop...branch.
|
|
783
|
+
// --diff-filter=d excludes deletions — an archive move's old path must not
|
|
784
|
+
// produce a validate-id on a vanished file.
|
|
785
|
+
const diff = await deps.runGit(opts.primary, io, [
|
|
786
|
+
"diff",
|
|
787
|
+
"--name-only",
|
|
788
|
+
"--diff-filter=d",
|
|
789
|
+
`develop...${opts.branch}`,
|
|
790
|
+
]);
|
|
791
|
+
const changedRfcIds = [
|
|
792
|
+
...new Set(
|
|
793
|
+
diff.stdout
|
|
794
|
+
.split("\n")
|
|
795
|
+
.map(
|
|
796
|
+
(l) =>
|
|
797
|
+
/^docs\/rfcs\/(?:archive\/(?:implemented|rejected|superseded)\/)?rfc-(\d+)-[^/]*\.md$/.exec(
|
|
798
|
+
l.trim(),
|
|
799
|
+
)?.[1],
|
|
800
|
+
)
|
|
801
|
+
.filter((m): m is string => m !== undefined)
|
|
802
|
+
.map((n) => `RFC-${n.padStart(4, "0")}`),
|
|
803
|
+
),
|
|
804
|
+
];
|
|
805
|
+
if (changedRfcIds.length > 0) {
|
|
806
|
+
if (resolvable("rfc.validate")) {
|
|
807
|
+
for (const id of changedRfcIds) {
|
|
808
|
+
checked.push(`rfc.validate:${id}`);
|
|
809
|
+
const result = await opts.invoke!("rfc.validate", { id });
|
|
810
|
+
if (result.ok === false || (result.exitCode !== undefined && result.exitCode !== 0)) {
|
|
811
|
+
return {
|
|
812
|
+
ok: false,
|
|
813
|
+
checked,
|
|
814
|
+
skipped,
|
|
815
|
+
tolerated,
|
|
816
|
+
refuse: {
|
|
817
|
+
ruleId: "FLOW-INT-13",
|
|
818
|
+
message: `preflight: rfc.validate ${id} refused — ${result.summary ?? `exit ${result.exitCode}`}`,
|
|
819
|
+
fixHint: "fix the RFC diagnostics, commit, then re-run flow.integrate",
|
|
820
|
+
data: { command: "rfc.validate", id, summary: result.summary },
|
|
821
|
+
},
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
} else {
|
|
826
|
+
skipped.push({
|
|
827
|
+
check: "rfc.validate",
|
|
828
|
+
reason: opts.invoke === undefined ? "no-invoke" : "unresolvable",
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
// (5) friction.validate — a broken registry refuses early.
|
|
834
|
+
if (resolvable("friction.validate")) {
|
|
835
|
+
checked.push("friction.validate");
|
|
836
|
+
const result = await opts.invoke!("friction.validate", {});
|
|
837
|
+
if (result.ok === false || (result.exitCode !== undefined && result.exitCode !== 0)) {
|
|
838
|
+
return {
|
|
839
|
+
ok: false,
|
|
840
|
+
checked,
|
|
841
|
+
skipped,
|
|
842
|
+
tolerated,
|
|
843
|
+
refuse: {
|
|
844
|
+
ruleId: "FLOW-INT-14",
|
|
845
|
+
message: `preflight: friction.validate refused — ${result.summary ?? `exit ${result.exitCode}`}`,
|
|
846
|
+
fixHint:
|
|
847
|
+
"repair docs/frictions.yaml (e.g. a duplicate id), commit, then re-run flow.integrate",
|
|
848
|
+
data: { command: "friction.validate", summary: result.summary },
|
|
849
|
+
},
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
} else {
|
|
853
|
+
skipped.push({
|
|
854
|
+
check: "friction.validate",
|
|
855
|
+
reason: opts.invoke === undefined ? "no-invoke" : "unresolvable",
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// RFC-1546: every other check passed — the manifest drift is the sole
|
|
860
|
+
// violation, so the owner command regenerates in place and the validator
|
|
861
|
+
// re-runs. A coexisting violation already refused above without ever
|
|
862
|
+
// reaching the regeneration.
|
|
863
|
+
if (manifestDrift !== undefined) {
|
|
864
|
+
if (resolvable("ecosystem.manifest.generate")) {
|
|
865
|
+
const regen = await opts.invoke!(
|
|
866
|
+
"ecosystem.manifest.generate",
|
|
867
|
+
REGEN_FLAGS["ecosystem.manifest.generate"] ?? {},
|
|
868
|
+
);
|
|
869
|
+
if (regen.ok !== false && (regen.exitCode === undefined || regen.exitCode === 0)) {
|
|
870
|
+
checked.push("ecosystem.manifest.generate", "ecosystem.manifest.validate");
|
|
871
|
+
const result = await opts.invoke!("ecosystem.manifest.validate", {});
|
|
872
|
+
if (result.ok !== false && (result.exitCode === undefined || result.exitCode === 0)) {
|
|
873
|
+
manifestDrift = undefined;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
if (manifestDrift !== undefined) {
|
|
878
|
+
return {
|
|
879
|
+
ok: false,
|
|
880
|
+
checked,
|
|
881
|
+
skipped,
|
|
882
|
+
tolerated,
|
|
883
|
+
refuse: {
|
|
884
|
+
ruleId: "FLOW-INT-12",
|
|
885
|
+
message: `preflight: ecosystem.manifest.validate refused — ${manifestDrift.summary ?? `exit ${manifestDrift.exitCode}`}`,
|
|
886
|
+
fixHint:
|
|
887
|
+
"regenerate the manifest via `pnpm exec werkstatt run ecosystem.manifest.generate`, commit, then re-run flow.integrate",
|
|
888
|
+
data: { command: "ecosystem.manifest.validate", summary: manifestDrift.summary },
|
|
889
|
+
},
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
return { ok: true, checked, skipped, tolerated };
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
// ── RFC-1538: generated-conflict classification ──────────────────────────
|
|
898
|
+
|
|
899
|
+
export interface ConflictOwner {
|
|
900
|
+
path: string;
|
|
901
|
+
command: string;
|
|
902
|
+
flags: Record<string, ForgeFlagValue>;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
export interface RebaseConflictVerdict {
|
|
906
|
+
/** Generated paths with a discoverable owner command — auto-resolvable. */
|
|
907
|
+
owners: ConflictOwner[];
|
|
908
|
+
/** Non-generated paths, or generated paths with no owner → FLOW-INT-02. */
|
|
909
|
+
nonGenerated: string[];
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/** `.generated.` basenames whose owner command is fixed by convention. */
|
|
913
|
+
export const GENERATED_BASENAME_OWNERS: Record<string, string> = {
|
|
914
|
+
"ecosystem.generated.yaml": "ecosystem.manifest.generate",
|
|
915
|
+
"command-manifest.generated.yaml": "command.manifest.generate",
|
|
916
|
+
};
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* Classify a rebase conflict set (RFC-1538): every path must classify
|
|
920
|
+
* generated via isGeneratedPathName/isGeneratedContent (stage-2/3 content),
|
|
921
|
+
* and every generated path must name an owner command — from its own
|
|
922
|
+
* generated header (`command:`/`regenerateCommand:`/`ownerCommand:`), or the
|
|
923
|
+
* `.generated.` basename registry. Anything else stays nonGenerated and the
|
|
924
|
+
* integrate refuses FLOW-INT-02 exactly as before.
|
|
925
|
+
*/
|
|
926
|
+
export async function classifyRebaseConflicts(
|
|
927
|
+
repo: string,
|
|
928
|
+
io: WorkspaceIO,
|
|
929
|
+
paths: string[],
|
|
930
|
+
deps: { runGit: typeof git } = { runGit: git },
|
|
931
|
+
): Promise<RebaseConflictVerdict> {
|
|
932
|
+
const owners: ConflictOwner[] = [];
|
|
933
|
+
const nonGenerated: string[] = [];
|
|
934
|
+
for (const p of paths) {
|
|
935
|
+
let content = "";
|
|
936
|
+
for (const stage of [":2:", ":3:"]) {
|
|
937
|
+
const r = await deps.runGit(repo, io, ["show", `${stage}${p}`]);
|
|
938
|
+
if (r.exitCode === 0 && r.stdout.length > 0) {
|
|
939
|
+
content = r.stdout;
|
|
940
|
+
break;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
const byName = isGeneratedPathName(p);
|
|
944
|
+
const byContent = content !== "" && isGeneratedContent(content);
|
|
945
|
+
if (!byName && !byContent) {
|
|
946
|
+
nonGenerated.push(p);
|
|
947
|
+
continue;
|
|
948
|
+
}
|
|
949
|
+
const header = /^(?:command|regenerateCommand|ownerCommand):\s*(\S.*?)\s*$/m.exec(
|
|
950
|
+
content.split("\n").slice(0, 15).join("\n"),
|
|
951
|
+
)?.[1];
|
|
952
|
+
const line = header ?? GENERATED_BASENAME_OWNERS[basename(p)] ?? null;
|
|
953
|
+
if (line === null) {
|
|
954
|
+
nonGenerated.push(p);
|
|
955
|
+
continue;
|
|
956
|
+
}
|
|
957
|
+
const [name, ...rest] = line.split(/\s+/);
|
|
958
|
+
const flags: Record<string, ForgeFlagValue> = { ...(REGEN_FLAGS[name] ?? {}) };
|
|
959
|
+
for (let i = 0; i < rest.length; i++) {
|
|
960
|
+
const t = rest[i];
|
|
961
|
+
if (!t.startsWith("--")) continue;
|
|
962
|
+
const eq = t.indexOf("=");
|
|
963
|
+
if (eq > 2) {
|
|
964
|
+
flags[t.slice(2, eq)] = t.slice(eq + 1);
|
|
965
|
+
} else if (i + 1 < rest.length && !rest[i + 1].startsWith("--")) {
|
|
966
|
+
flags[t.slice(2)] = rest[++i];
|
|
967
|
+
} else {
|
|
968
|
+
flags[t.slice(2)] = true;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
owners.push({ path: p, command: name, flags });
|
|
972
|
+
}
|
|
973
|
+
return { owners, nonGenerated };
|
|
974
|
+
}
|