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