@warpgogol/forge 9.1.0 → 9.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/README.md +15 -8
- package/README.uk.md +15 -8
- package/bin/cli.ts +3 -2
- package/dist/bin/cli.js +3 -2
- package/dist/bin/cli.js.map +1 -1
- package/dist/os/core/core.module.d.ts.map +1 -1
- package/dist/os/core/core.module.js +6 -4
- package/dist/os/core/core.module.js.map +1 -1
- package/dist/os/flow/branch-name.d.ts +56 -0
- package/dist/os/flow/branch-name.d.ts.map +1 -0
- package/dist/os/flow/branch-name.js +108 -0
- package/dist/os/flow/branch-name.js.map +1 -0
- package/dist/os/flow/digest.d.ts +73 -0
- package/dist/os/flow/digest.d.ts.map +1 -0
- package/dist/os/flow/digest.js +634 -0
- package/dist/os/flow/digest.js.map +1 -0
- package/dist/os/flow/flow.module.d.ts +3 -0
- package/dist/os/flow/flow.module.d.ts.map +1 -0
- package/dist/os/flow/flow.module.js +716 -0
- package/dist/os/flow/flow.module.js.map +1 -0
- package/dist/os/flow/git.d.ts +68 -0
- package/dist/os/flow/git.d.ts.map +1 -0
- package/dist/os/flow/git.js +257 -0
- package/dist/os/flow/git.js.map +1 -0
- package/dist/os/flow/guard-files.d.ts +50 -0
- package/dist/os/flow/guard-files.d.ts.map +1 -0
- package/dist/os/flow/guard-files.js +147 -0
- package/dist/os/flow/guard-files.js.map +1 -0
- package/dist/os/flow/handlers/flow-backmerge.d.ts +27 -0
- package/dist/os/flow/handlers/flow-backmerge.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-backmerge.js +332 -0
- package/dist/os/flow/handlers/flow-backmerge.js.map +1 -0
- package/dist/os/flow/handlers/flow-check.d.ts +42 -0
- package/dist/os/flow/handlers/flow-check.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-check.js +347 -0
- package/dist/os/flow/handlers/flow-check.js.map +1 -0
- package/dist/os/flow/handlers/flow-cut.d.ts +63 -0
- package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-cut.js +636 -0
- package/dist/os/flow/handlers/flow-cut.js.map +1 -0
- package/dist/os/flow/handlers/flow-digest.d.ts +5 -0
- package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-digest.js +110 -0
- package/dist/os/flow/handlers/flow-digest.js.map +1 -0
- package/dist/os/flow/handlers/flow-discard.d.ts +22 -0
- package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-discard.js +200 -0
- package/dist/os/flow/handlers/flow-discard.js.map +1 -0
- package/dist/os/flow/handlers/flow-fix.d.ts +47 -0
- package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-fix.js +443 -0
- package/dist/os/flow/handlers/flow-fix.js.map +1 -0
- package/dist/os/flow/handlers/flow-hold.d.ts +32 -0
- package/dist/os/flow/handlers/flow-hold.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-hold.js +359 -0
- package/dist/os/flow/handlers/flow-hold.js.map +1 -0
- package/dist/os/flow/handlers/flow-install.d.ts +92 -0
- package/dist/os/flow/handlers/flow-install.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-install.js +883 -0
- package/dist/os/flow/handlers/flow-install.js.map +1 -0
- package/dist/os/flow/handlers/flow-integrate.d.ts +35 -0
- package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-integrate.js +419 -0
- package/dist/os/flow/handlers/flow-integrate.js.map +1 -0
- package/dist/os/flow/handlers/flow-open.d.ts +63 -0
- package/dist/os/flow/handlers/flow-open.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-open.js +294 -0
- package/dist/os/flow/handlers/flow-open.js.map +1 -0
- package/dist/os/flow/handlers/flow-push.d.ts +22 -0
- package/dist/os/flow/handlers/flow-push.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-push.js +306 -0
- package/dist/os/flow/handlers/flow-push.js.map +1 -0
- package/dist/os/flow/handlers/flow-status.d.ts +65 -0
- package/dist/os/flow/handlers/flow-status.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-status.js +193 -0
- package/dist/os/flow/handlers/flow-status.js.map +1 -0
- package/dist/os/flow/handlers/flow-unhold.d.ts +20 -0
- package/dist/os/flow/handlers/flow-unhold.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-unhold.js +158 -0
- package/dist/os/flow/handlers/flow-unhold.js.map +1 -0
- package/dist/os/flow/handlers/flow-version.d.ts +39 -0
- package/dist/os/flow/handlers/flow-version.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-version.js +122 -0
- package/dist/os/flow/handlers/flow-version.js.map +1 -0
- package/dist/os/flow/index.d.ts +30 -0
- package/dist/os/flow/index.d.ts.map +1 -0
- package/dist/os/flow/index.js +83 -0
- package/dist/os/flow/index.js.map +1 -0
- package/dist/os/flow/line-version.d.ts +23 -0
- package/dist/os/flow/line-version.d.ts.map +1 -0
- package/dist/os/flow/line-version.js +83 -0
- package/dist/os/flow/line-version.js.map +1 -0
- package/dist/os/flow/locks.d.ts +34 -0
- package/dist/os/flow/locks.d.ts.map +1 -0
- package/dist/os/flow/locks.js +147 -0
- package/dist/os/flow/locks.js.map +1 -0
- package/dist/os/flow/markers.d.ts +49 -0
- package/dist/os/flow/markers.d.ts.map +1 -0
- package/dist/os/flow/markers.js +112 -0
- package/dist/os/flow/markers.js.map +1 -0
- package/dist/os/flow/publish.d.ts +28 -0
- package/dist/os/flow/publish.d.ts.map +1 -0
- package/dist/os/flow/publish.js +153 -0
- package/dist/os/flow/publish.js.map +1 -0
- package/dist/os/flow/registry.d.ts +142 -0
- package/dist/os/flow/registry.d.ts.map +1 -0
- package/dist/os/flow/registry.js +198 -0
- package/dist/os/flow/registry.js.map +1 -0
- package/dist/os/flow/release-level.d.ts +23 -0
- package/dist/os/flow/release-level.d.ts.map +1 -0
- package/dist/os/flow/release-level.js +102 -0
- package/dist/os/flow/release-level.js.map +1 -0
- package/dist/os/flow/release-lines.d.ts +25 -0
- package/dist/os/flow/release-lines.d.ts.map +1 -0
- package/dist/os/flow/release-lines.js +172 -0
- package/dist/os/flow/release-lines.js.map +1 -0
- package/dist/os/flow/release-tags.d.ts +72 -0
- package/dist/os/flow/release-tags.d.ts.map +1 -0
- package/dist/os/flow/release-tags.js +166 -0
- package/dist/os/flow/release-tags.js.map +1 -0
- package/dist/os/flow/repo-kind.d.ts +41 -0
- package/dist/os/flow/repo-kind.d.ts.map +1 -0
- package/dist/os/flow/repo-kind.js +92 -0
- package/dist/os/flow/repo-kind.js.map +1 -0
- package/dist/os/flow/scripts.d.ts +20 -0
- package/dist/os/flow/scripts.d.ts.map +1 -0
- package/dist/os/flow/scripts.js +49 -0
- package/dist/os/flow/scripts.js.map +1 -0
- package/dist/os/flow/semver.d.ts +21 -0
- package/dist/os/flow/semver.d.ts.map +1 -0
- package/dist/os/flow/semver.js +73 -0
- package/dist/os/flow/semver.js.map +1 -0
- package/dist/os/flow/tests/helpers.d.ts +52 -0
- package/dist/os/flow/tests/helpers.d.ts.map +1 -0
- package/dist/os/flow/tests/helpers.js +189 -0
- package/dist/os/flow/tests/helpers.js.map +1 -0
- package/dist/os/flow/version-files.d.ts +21 -0
- package/dist/os/flow/version-files.d.ts.map +1 -0
- package/dist/os/flow/version-files.js +94 -0
- package/dist/os/flow/version-files.js.map +1 -0
- package/dist/os/flow/worktree-path.d.ts +31 -0
- package/dist/os/flow/worktree-path.d.ts.map +1 -0
- package/dist/os/flow/worktree-path.js +80 -0
- package/dist/os/flow/worktree-path.js.map +1 -0
- package/dist/os/mission/handlers/archive.d.ts.map +1 -1
- package/dist/os/mission/handlers/archive.js +43 -6
- package/dist/os/mission/handlers/archive.js.map +1 -1
- package/dist/os/program/handlers/seal.d.ts.map +1 -1
- package/dist/os/program/handlers/seal.js +1 -1
- package/dist/os/program/handlers/seal.js.map +1 -1
- package/dist/os/program/handlers/validate.d.ts.map +1 -1
- package/dist/os/program/handlers/validate.js +1 -1
- package/dist/os/program/handlers/validate.js.map +1 -1
- package/dist/os/program/program.module.d.ts.map +1 -1
- package/dist/os/program/program.module.js +2 -1
- package/dist/os/program/program.module.js.map +1 -1
- package/dist/os/program/schemas.d.ts +4 -6
- package/dist/os/program/schemas.d.ts.map +1 -1
- package/dist/os/program/schemas.js +16 -6
- package/dist/os/program/schemas.js.map +1 -1
- package/dist/os/program/state.d.ts +0 -1
- package/dist/os/program/state.d.ts.map +1 -1
- package/dist/os/program/state.js +1 -7
- package/dist/os/program/state.js.map +1 -1
- package/dist/os/rfc/acceptance.d.ts +21 -0
- package/dist/os/rfc/acceptance.d.ts.map +1 -1
- package/dist/os/rfc/acceptance.js +62 -13
- package/dist/os/rfc/acceptance.js.map +1 -1
- package/dist/os/rfc/frontmatter-io.d.ts +19 -0
- package/dist/os/rfc/frontmatter-io.d.ts.map +1 -1
- package/dist/os/rfc/frontmatter-io.js +65 -12
- package/dist/os/rfc/frontmatter-io.js.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts +2 -5
- package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.js +10 -8
- 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 +15 -5
- package/dist/os/rfc/handlers/validate.js.map +1 -1
- package/dist/os/rfc/index.d.ts +2 -2
- package/dist/os/rfc/index.d.ts.map +1 -1
- package/dist/os/rfc/index.js +5 -2
- package/dist/os/rfc/index.js.map +1 -1
- package/dist/os/rfc/probe-batch.d.ts +71 -0
- package/dist/os/rfc/probe-batch.d.ts.map +1 -0
- package/dist/os/rfc/probe-batch.js +251 -0
- package/dist/os/rfc/probe-batch.js.map +1 -0
- package/dist/os/rfc/rfc.module.d.ts.map +1 -1
- package/dist/os/rfc/rfc.module.js +16 -2
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
- package/dist/os/rfc/verification-evidence.js +21 -10
- package/dist/os/rfc/verification-evidence.js.map +1 -1
- package/dist/os/rfc/verification-refresh.d.ts.map +1 -1
- package/dist/os/rfc/verification-refresh.js +20 -13
- package/dist/os/rfc/verification-refresh.js.map +1 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +1 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +21 -7
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +1 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +1 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +1 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +1 -1
- package/dist/os/werkstatt/werkstatt.module.d.ts.map +1 -1
- package/dist/os/werkstatt/werkstatt.module.js +2 -82
- package/dist/os/werkstatt/werkstatt.module.js.map +1 -1
- package/dist/src/config/forge-config.d.ts +0 -3
- package/dist/src/config/forge-config.d.ts.map +1 -1
- package/dist/src/config/forge-config.js +2 -4
- package/dist/src/config/forge-config.js.map +1 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
- package/dist/src/onboarding/agents-generate.js +49 -4
- package/dist/src/onboarding/agents-generate.js.map +1 -1
- package/dist/src/onboarding/create.d.ts +13 -0
- package/dist/src/onboarding/create.d.ts.map +1 -1
- package/dist/src/onboarding/create.js +95 -9
- package/dist/src/onboarding/create.js.map +1 -1
- package/dist/src/onboarding/doctor.d.ts.map +1 -1
- package/dist/src/onboarding/doctor.js +2 -47
- package/dist/src/onboarding/doctor.js.map +1 -1
- package/dist/src/onboarding/upgrade.d.ts +5 -0
- package/dist/src/onboarding/upgrade.d.ts.map +1 -1
- package/dist/src/onboarding/upgrade.js +70 -1
- package/dist/src/onboarding/upgrade.js.map +1 -1
- package/dist/src/types.d.ts +9 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +2 -2
- package/docs/branch-model.md +98 -0
- package/docs/maintainers/publishing.md +14 -6
- package/docs/reference/cli.md +125 -0
- package/docs/reference/profiles.md +1 -0
- package/os/core/core.module.ts +7 -4
- package/os/flow/assets/flow-guard.sh +176 -0
- package/os/flow/branch-name.ts +139 -0
- package/os/flow/digest.ts +761 -0
- package/os/flow/flow.module.ts +740 -0
- package/os/flow/git.ts +342 -0
- package/os/flow/guard-files.ts +172 -0
- package/os/flow/handlers/flow-backmerge.ts +488 -0
- package/os/flow/handlers/flow-check.ts +450 -0
- package/os/flow/handlers/flow-cut.ts +912 -0
- package/os/flow/handlers/flow-digest.ts +124 -0
- package/os/flow/handlers/flow-discard.ts +301 -0
- package/os/flow/handlers/flow-fix.ts +597 -0
- package/os/flow/handlers/flow-hold.ts +500 -0
- package/os/flow/handlers/flow-install.ts +1185 -0
- package/os/flow/handlers/flow-integrate.ts +607 -0
- package/os/flow/handlers/flow-open.ts +447 -0
- package/os/flow/handlers/flow-push.ts +373 -0
- package/os/flow/handlers/flow-status.ts +283 -0
- package/os/flow/handlers/flow-unhold.ts +220 -0
- package/os/flow/handlers/flow-version.ts +196 -0
- package/os/flow/index.ts +102 -0
- package/os/flow/line-version.ts +113 -0
- package/os/flow/locks.ts +177 -0
- package/os/flow/markers.ts +135 -0
- package/os/flow/publish.ts +201 -0
- package/os/flow/registry.ts +266 -0
- package/os/flow/release-level.ts +139 -0
- package/os/flow/release-lines.ts +208 -0
- package/os/flow/release-tags.ts +231 -0
- package/os/flow/repo-kind.ts +117 -0
- package/os/flow/scripts.ts +73 -0
- package/os/flow/semver.ts +82 -0
- package/os/flow/tests/branch-name.test.ts +136 -0
- package/os/flow/tests/fixtures/branch-names.yaml +56 -0
- package/os/flow/tests/flow-backmerge.test.ts +267 -0
- package/os/flow/tests/flow-check-version.test.ts +138 -0
- package/os/flow/tests/flow-check.test.ts +213 -0
- package/os/flow/tests/flow-cut.rerun.test.ts +95 -0
- package/os/flow/tests/flow-cut.test.ts +319 -0
- package/os/flow/tests/flow-digest.test.ts +313 -0
- package/os/flow/tests/flow-discard.test.ts +220 -0
- package/os/flow/tests/flow-fix.test.ts +359 -0
- package/os/flow/tests/flow-guard-merge.test.ts +100 -0
- package/os/flow/tests/flow-guard-parity.test.ts +115 -0
- package/os/flow/tests/flow-guard-push.test.ts +100 -0
- package/os/flow/tests/flow-guard.test.ts +135 -0
- package/os/flow/tests/flow-hold.test.ts +465 -0
- package/os/flow/tests/flow-install-baseline.rerun.test.ts +73 -0
- package/os/flow/tests/flow-install-baseline.test.ts +164 -0
- package/os/flow/tests/flow-install-markers.test.ts +161 -0
- package/os/flow/tests/flow-install.rerun.test.ts +212 -0
- package/os/flow/tests/flow-install.test.ts +330 -0
- package/os/flow/tests/flow-integrate.rerun.test.ts +92 -0
- package/os/flow/tests/flow-integrate.test.ts +229 -0
- package/os/flow/tests/flow-open.test.ts +200 -0
- package/os/flow/tests/flow-push-publish.test.ts +282 -0
- package/os/flow/tests/flow-push.test.ts +160 -0
- package/os/flow/tests/flow-stale.test.ts +136 -0
- package/os/flow/tests/flow-status.test.ts +93 -0
- package/os/flow/tests/flow-version-level.test.ts +116 -0
- package/os/flow/tests/flow-version.test.ts +169 -0
- package/os/flow/tests/helpers.ts +235 -0
- package/os/flow/tests/is-flow-adopted.test.ts +71 -0
- package/os/flow/tests/registry.test.ts +150 -0
- package/os/flow/tests/repository-line-version.test.ts +100 -0
- package/os/flow/tests/scripts.test.ts +97 -0
- package/os/flow/tests/state-roots.test.ts +127 -0
- package/os/flow/tests/version-files.test.ts +145 -0
- package/os/flow/version-files.ts +115 -0
- package/os/flow/worktree-path.ts +107 -0
- package/os/mission/handlers/archive.test.ts +27 -0
- package/os/mission/handlers/archive.ts +46 -6
- package/os/program/handlers/seal.ts +1 -1
- package/os/program/handlers/validate.ts +1 -1
- package/os/program/program.module.ts +2 -1
- package/os/program/schemas.ts +51 -34
- package/os/program/state.ts +1 -9
- package/os/rfc/acceptance.ts +84 -19
- package/os/rfc/frontmatter-io.ts +78 -12
- package/os/rfc/handlers/implement-stamp-stale.test.ts +22 -0
- package/os/rfc/handlers/validate-rules.test.ts +9 -6
- package/os/rfc/handlers/validate-rules.ts +12 -10
- package/os/rfc/handlers/validate.ts +17 -5
- package/os/rfc/index.ts +13 -1
- package/os/rfc/probe-batch.ts +329 -0
- package/os/rfc/rfc.module.ts +19 -2
- package/os/rfc/verification-emit-check.test.ts +22 -0
- package/os/rfc/verification-emit-freshness.test.ts +22 -0
- package/os/rfc/verification-emit.test.ts +22 -0
- package/os/rfc/verification-evidence.ts +21 -16
- package/os/rfc/verification-refresh.test.ts +22 -0
- package/os/rfc/verification-refresh.ts +20 -18
- package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +9 -0
- package/os/werkstatt/handlers/werkstatt-lock-recover.ts +22 -5
- package/os/werkstatt/handlers/werkstatt-operation-validate.ts +1 -1
- package/os/werkstatt/werkstatt.module.ts +2 -85
- package/package.json +17 -1
- package/profiles/forge-shell.yaml +22 -10
- package/profiles/godot-game.yaml +24 -13
- package/profiles/knowledge.yaml +19 -0
- package/profiles/phaser-game.yaml +25 -13
- package/profiles/site-workshop.yaml +27 -10
- package/profiles/typescript.yaml +26 -9
- package/skills/fo/fo-session-retro/SKILL.md +18 -7
- package/skills/fo/fo-step-commit/SKILL.md +2 -1
- package/src/config/forge-config.ts +2 -6
- package/src/index.ts +8 -0
- package/src/onboarding/agents-generate.ts +49 -5
- package/src/onboarding/create.ts +101 -9
- package/src/onboarding/doctor.ts +2 -51
- package/src/onboarding/upgrade.ts +86 -1
- package/src/tests/agents-generate-flow.test.ts +132 -0
- package/src/tests/create-flow.test.ts +114 -0
- package/src/tests/create.test.ts +22 -21
- package/src/tests/doctor-autonomy.test.ts +2 -1
- package/src/tests/implement-stamp.test.ts +26 -3
- package/src/tests/profile-flow-hooks.test.ts +77 -0
- package/src/tests/program-schemas.test.ts +66 -6
- package/src/tests/program-spec-node.test.ts +1 -5
- package/src/tests/rfc-evidence-sync.test.ts +22 -0
- package/src/tests/rfc-implement-stamp-governance.test.ts +25 -1
- package/src/tests/rfc-verification-verdict-ingest.test.ts +22 -0
- package/src/tests/upgrade-flow.test.ts +174 -0
- package/src/types.ts +11 -2
- package/dist/os/werkstatt/handlers/session-close.d.ts +0 -13
- package/dist/os/werkstatt/handlers/session-close.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/session-close.js +0 -56
- package/dist/os/werkstatt/handlers/session-close.js.map +0 -1
- package/dist/os/werkstatt/handlers/session-engine.d.ts +0 -3
- package/dist/os/werkstatt/handlers/session-engine.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/session-engine.js +0 -28
- package/dist/os/werkstatt/handlers/session-engine.js.map +0 -1
- package/dist/os/werkstatt/handlers/session-open.d.ts +0 -10
- package/dist/os/werkstatt/handlers/session-open.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/session-open.js +0 -46
- package/dist/os/werkstatt/handlers/session-open.js.map +0 -1
- package/dist/os/werkstatt/handlers/session-status.d.ts +0 -9
- package/dist/os/werkstatt/handlers/session-status.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/session-status.js +0 -34
- package/dist/os/werkstatt/handlers/session-status.js.map +0 -1
- package/os/werkstatt/handlers/session-close.ts +0 -82
- package/os/werkstatt/handlers/session-engine.ts +0 -34
- package/os/werkstatt/handlers/session-open.ts +0 -68
- package/os/werkstatt/handlers/session-status.ts +0 -55
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>
|
|
4
|
+
RFC-1495 step 1 — resolveStateRoots distinguishes the session worktree from
|
|
5
|
+
the primary checkout, degrades on non-git dirs, and forge's own mission.archive
|
|
6
|
+
writes the archive into the primary while the mission source stays where the
|
|
7
|
+
command ran.
|
|
8
|
+
</purpose>
|
|
9
|
+
<non-goals>
|
|
10
|
+
<item>Not a contract source of truth — resolveStateRoots and the archive handler own the authoritative behavior.</item>
|
|
11
|
+
</non-goals>
|
|
12
|
+
</MODULE_CONTRACT>
|
|
13
|
+
<CHANGE_SUMMARY>
|
|
14
|
+
<item>RFC-1495: step 1 — state-roots + primary-archive tests</item>
|
|
15
|
+
<item>RFC-1495: step 1 - forge state roots</item>
|
|
16
|
+
</CHANGE_SUMMARY>
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { test, expect, describe, afterEach } from "vitest";
|
|
20
|
+
import { mkdtemp, mkdir, writeFile, rm } from "node:fs/promises";
|
|
21
|
+
import { existsSync } from "node:fs";
|
|
22
|
+
import { tmpdir } from "node:os";
|
|
23
|
+
import { basename, dirname, join } from "node:path";
|
|
24
|
+
|
|
25
|
+
import { ambientIo } from "../../../src/utils/io.ts";
|
|
26
|
+
import type { ForgeCommandInput, ForgeRuntimeContext } from "../../../src/types.ts";
|
|
27
|
+
|
|
28
|
+
import { resolveStateRoots } from "../worktree-path.ts";
|
|
29
|
+
import { runMissionArchive } from "../../mission/handlers/archive.ts";
|
|
30
|
+
import { gitExec, initRepo } from "./helpers.ts";
|
|
31
|
+
|
|
32
|
+
const io = ambientIo;
|
|
33
|
+
const dirs: string[] = [];
|
|
34
|
+
|
|
35
|
+
afterEach(async () => {
|
|
36
|
+
for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
function makeContext(workspaceRoot: string): ForgeRuntimeContext {
|
|
40
|
+
return {
|
|
41
|
+
workspaceRoot,
|
|
42
|
+
io,
|
|
43
|
+
logger: {
|
|
44
|
+
info: () => {},
|
|
45
|
+
success: () => {},
|
|
46
|
+
warn: () => {},
|
|
47
|
+
error: () => {},
|
|
48
|
+
debug: () => {},
|
|
49
|
+
},
|
|
50
|
+
outputFormat: "json",
|
|
51
|
+
dryRun: false,
|
|
52
|
+
} as unknown as ForgeRuntimeContext;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function makeInput(flags: Record<string, unknown> = {}): ForgeCommandInput {
|
|
56
|
+
return { commandName: "mission.archive", flags } as unknown as ForgeCommandInput;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
describe("resolveStateRoots (RFC-1495)", () => {
|
|
60
|
+
test("single-worktree repo resolves every root to itself", async () => {
|
|
61
|
+
const repo = await initRepo({ prefix: "state-roots-" });
|
|
62
|
+
dirs.push(repo);
|
|
63
|
+
const roots = await resolveStateRoots(repo, io);
|
|
64
|
+
expect(roots.worktreeRoot).toBe(repo);
|
|
65
|
+
expect(roots.primaryRoot).toBe(repo);
|
|
66
|
+
expect(roots.isPrimary).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("from a linked worktree, primary is the first worktree", async () => {
|
|
70
|
+
const repo = await initRepo({ prefix: "state-roots-" });
|
|
71
|
+
dirs.push(repo);
|
|
72
|
+
const wt = join(dirname(repo), `${basename(repo)}@session-x`);
|
|
73
|
+
const add = await gitExec(repo, ["worktree", "add", "-b", "session-x", wt]);
|
|
74
|
+
expect(add.exitCode).toBe(0);
|
|
75
|
+
// Worktree dirs land inside the tracked rm — the worktree itself is
|
|
76
|
+
// removed with the parent dir.
|
|
77
|
+
dirs.push(wt);
|
|
78
|
+
|
|
79
|
+
const roots = await resolveStateRoots(wt, io);
|
|
80
|
+
expect(roots.worktreeRoot).toBe(wt);
|
|
81
|
+
expect(roots.primaryRoot).toBe(repo);
|
|
82
|
+
expect(roots.isPrimary).toBe(false);
|
|
83
|
+
|
|
84
|
+
const primary = await resolveStateRoots(repo, io);
|
|
85
|
+
expect(primary.isPrimary).toBe(true);
|
|
86
|
+
expect(primary.worktreeRoot).toBe(repo);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test("non-git directory degrades to itself", async () => {
|
|
90
|
+
const dir = await mkdtemp(join(tmpdir(), "state-roots-"));
|
|
91
|
+
dirs.push(dir);
|
|
92
|
+
const roots = await resolveStateRoots(dir, io);
|
|
93
|
+
expect(roots).toEqual({
|
|
94
|
+
worktreeRoot: dir,
|
|
95
|
+
primaryRoot: dir,
|
|
96
|
+
isPrimary: true,
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("mission.archive run in a session worktree lands in the primary archive", async () => {
|
|
101
|
+
const repo = await initRepo({ prefix: "state-roots-" });
|
|
102
|
+
dirs.push(repo);
|
|
103
|
+
const wt = join(dirname(repo), `${basename(repo)}@session-y`);
|
|
104
|
+
const add = await gitExec(repo, ["worktree", "add", "-b", "session-y", wt]);
|
|
105
|
+
expect(add.exitCode).toBe(0);
|
|
106
|
+
dirs.push(wt);
|
|
107
|
+
|
|
108
|
+
// A closed mission exists in the session worktree only.
|
|
109
|
+
const missionId = "acme-m000001";
|
|
110
|
+
const missionDir = join(wt, "missions", missionId);
|
|
111
|
+
await mkdir(missionDir, { recursive: true });
|
|
112
|
+
await writeFile(
|
|
113
|
+
join(missionDir, "mission.yaml"),
|
|
114
|
+
`missionId: ${missionId}\nstate: closed\n`,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const result = await runMissionArchive(makeInput(), makeContext(wt));
|
|
118
|
+
expect(result.exitCode ?? 0).toBe(0);
|
|
119
|
+
|
|
120
|
+
// Durable target: the primary's missions/archive/closed/, never the wt's.
|
|
121
|
+
expect(
|
|
122
|
+
existsSync(join(repo, "missions", "archive", "closed", missionId, "mission.yaml")),
|
|
123
|
+
).toBe(true);
|
|
124
|
+
expect(existsSync(join(wt, "missions", "archive"))).toBe(false);
|
|
125
|
+
expect(existsSync(missionDir)).toBe(false);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>version-files tests (RFC-1490 step 2): verified textual writes keep
|
|
4
|
+
formatting and key order, a nested-first `"version"` key throws
|
|
5
|
+
VersionWriteError, forge.yaml syncedVersion keeps indentation, and the
|
|
6
|
+
widened registry schema accepts kind fix + base main while rejecting
|
|
7
|
+
session + main.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>No cut orchestration — flow-cut tests own that.</item>
|
|
10
|
+
</non-goals>
|
|
11
|
+
</MODULE_CONTRACT>
|
|
12
|
+
<CHANGE_SUMMARY>
|
|
13
|
+
<item>RFC-1490: step 2 — version-files + registry-schema coverage</item>
|
|
14
|
+
<item>RFC-1490: step 2 — registry fix/port widening, FORGE_FLOW_COMMIT gitCommit helper, verified version-files writes</item>
|
|
15
|
+
</CHANGE_SUMMARY>
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
19
|
+
import { join } from "node:path";
|
|
20
|
+
|
|
21
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
22
|
+
|
|
23
|
+
import { ambientIo } from "../../../src/utils/io.ts";
|
|
24
|
+
import { flowRegistryEntrySchema } from "../registry.ts";
|
|
25
|
+
import type { ReleaseLine } from "../release-lines.ts";
|
|
26
|
+
import {
|
|
27
|
+
VersionWriteError,
|
|
28
|
+
writeLineVersion,
|
|
29
|
+
writeSyncedForgeVersion,
|
|
30
|
+
} from "../version-files.ts";
|
|
31
|
+
import { initRepo } from "./helpers.ts";
|
|
32
|
+
|
|
33
|
+
const dirs: string[] = [];
|
|
34
|
+
|
|
35
|
+
afterEach(async () => {
|
|
36
|
+
for (const dir of dirs.splice(0)) {
|
|
37
|
+
await rm(dir, { recursive: true, force: true });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function lineWith(versionFile: string | null): ReleaseLine {
|
|
42
|
+
return {
|
|
43
|
+
id: "repo",
|
|
44
|
+
tagPrefix: "v",
|
|
45
|
+
versionFile,
|
|
46
|
+
paths: [],
|
|
47
|
+
packages: [],
|
|
48
|
+
} as ReleaseLine;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function repo(): Promise<string> {
|
|
52
|
+
const dir = await initRepo({ prefix: "ver-files-" });
|
|
53
|
+
dirs.push(dir);
|
|
54
|
+
return dir;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const ENTRY = {
|
|
58
|
+
name: "auto/fix-260102-01-x",
|
|
59
|
+
baseSha: "a".repeat(40),
|
|
60
|
+
worktree: "/tmp/wt",
|
|
61
|
+
owner: { kind: "session", id: "s1" },
|
|
62
|
+
brief: null,
|
|
63
|
+
openedAt: "2026-01-02T00:00:00.000Z",
|
|
64
|
+
updatedAt: "2026-01-02T00:00:00.000Z",
|
|
65
|
+
held: null,
|
|
66
|
+
port: null,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
describe("writeLineVersion", () => {
|
|
70
|
+
it("replaces the version field preserving formatting and key order", async () => {
|
|
71
|
+
const dir = await repo();
|
|
72
|
+
const doc = '{\n\t"name": "x",\n\t"version": "1.2.0",\n\t"license": "MIT"\n}\n';
|
|
73
|
+
await writeFile(join(dir, "package.json"), doc);
|
|
74
|
+
await writeLineVersion(dir, lineWith("package.json"), "1.3.0", ambientIo);
|
|
75
|
+
const after = await ambientIo.readFile(join(dir, "package.json"));
|
|
76
|
+
expect(after).toBe(doc.replace('"version": "1.2.0"', '"version": "1.3.0"'));
|
|
77
|
+
expect(after).toContain("\t");
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("a nested-first version key fails verification as VersionWriteError", async () => {
|
|
81
|
+
const dir = await repo();
|
|
82
|
+
await writeFile(
|
|
83
|
+
join(dir, "package.json"),
|
|
84
|
+
'{ "engines": { "version": ">=18" }, "version": "1.2.0" }\n',
|
|
85
|
+
);
|
|
86
|
+
await expect(
|
|
87
|
+
writeLineVersion(dir, lineWith("package.json"), "1.3.0", ambientIo),
|
|
88
|
+
).rejects.toBeInstanceOf(VersionWriteError);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("throws VersionWriteError when the line has no version file", async () => {
|
|
92
|
+
const dir = await repo();
|
|
93
|
+
await expect(
|
|
94
|
+
writeLineVersion(dir, lineWith(null), "1.3.0", ambientIo),
|
|
95
|
+
).rejects.toBeInstanceOf(VersionWriteError);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe("writeSyncedForgeVersion", () => {
|
|
100
|
+
it("replaces syncedVersion keeping indentation", async () => {
|
|
101
|
+
const dir = await repo();
|
|
102
|
+
await mkdir(join(dir, "sub"), { recursive: true });
|
|
103
|
+
const yaml = "forge:\n syncedVersion: 9.1.1\n other: keep\n";
|
|
104
|
+
await writeFile(join(dir, "forge.yaml"), yaml);
|
|
105
|
+
await writeSyncedForgeVersion(dir, "9.2.0", ambientIo);
|
|
106
|
+
expect(await ambientIo.readFile(join(dir, "forge.yaml"))).toBe(
|
|
107
|
+
"forge:\n syncedVersion: 9.2.0\n other: keep\n",
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe("flowRegistryEntrySchema (RFC-1490 widening)", () => {
|
|
113
|
+
it("accepts kind fix with base main", () => {
|
|
114
|
+
const parsed = flowRegistryEntrySchema.safeParse({ ...ENTRY, kind: "fix", base: "main" });
|
|
115
|
+
expect(parsed.success).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("rejects kind session with base main", () => {
|
|
119
|
+
const parsed = flowRegistryEntrySchema.safeParse({
|
|
120
|
+
...ENTRY,
|
|
121
|
+
kind: "session",
|
|
122
|
+
base: "main",
|
|
123
|
+
});
|
|
124
|
+
expect(parsed.success).toBe(false);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("rejects kind fix with base develop", () => {
|
|
128
|
+
const parsed = flowRegistryEntrySchema.safeParse({
|
|
129
|
+
...ENTRY,
|
|
130
|
+
kind: "fix",
|
|
131
|
+
base: "develop",
|
|
132
|
+
});
|
|
133
|
+
expect(parsed.success).toBe(false);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("accepts a port object on any kind", () => {
|
|
137
|
+
const parsed = flowRegistryEntrySchema.safeParse({
|
|
138
|
+
...ENTRY,
|
|
139
|
+
kind: "session",
|
|
140
|
+
base: "develop",
|
|
141
|
+
port: { mainSha: "b".repeat(40), tags: ["v1.3.1"] },
|
|
142
|
+
});
|
|
143
|
+
expect(parsed.success).toBe(true);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>Version-file writes for flow.cut (RFC-1490): replace a release
|
|
4
|
+
line's `package.json` `"version"` field and the repo's `forge.yaml`
|
|
5
|
+
`syncedVersion` textually — formatting, key order and comments are
|
|
6
|
+
preserved — then verify the JSON result deep-equals the pre-write document
|
|
7
|
+
with only `version` changed. A mismatch throws VersionWriteError (the cut
|
|
8
|
+
maps it to FLOW-CUT-11).</purpose>
|
|
9
|
+
<non-goals>
|
|
10
|
+
<item>No version math — semver.ts/release-level.ts decide the next version.</item>
|
|
11
|
+
<item>No commits — callers stage and commit the written files.</item>
|
|
12
|
+
</non-goals>
|
|
13
|
+
</MODULE_CONTRACT>
|
|
14
|
+
<KEY_DECISIONS>
|
|
15
|
+
<item>Textual first-`"version"`-key replacement: a JSON round-trip would reformat the file; the post-write JSON deep-equal is the safety net that catches a nested `"version"` (e.g. under engines) hit by accident.</item>
|
|
16
|
+
<item>`syncedVersion` is a YAML scalar — regex the whole line keeping leading indentation so comments elsewhere in forge.yaml survive.</item>
|
|
17
|
+
</KEY_DECISIONS>
|
|
18
|
+
<CHANGE_SUMMARY>
|
|
19
|
+
<item>RFC-1490: step 2 — verified textual version writes for flow.cut</item>
|
|
20
|
+
<item>RFC-1490: step 2 — registry fix/port widening, FORGE_FLOW_COMMIT gitCommit helper, verified version-files writes</item>
|
|
21
|
+
</CHANGE_SUMMARY>
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { join } from "node:path";
|
|
25
|
+
|
|
26
|
+
import type { WorkspaceIO } from "../../src/types.ts";
|
|
27
|
+
|
|
28
|
+
import type { ReleaseLine } from "./release-lines.ts";
|
|
29
|
+
|
|
30
|
+
/** The verified-write contract failed — flow.cut maps this to FLOW-CUT-11. */
|
|
31
|
+
export class VersionWriteError extends Error {
|
|
32
|
+
readonly file: string;
|
|
33
|
+
constructor(file: string, detail: string) {
|
|
34
|
+
super(`version write to ${file} failed verification: ${detail}`);
|
|
35
|
+
this.name = "VersionWriteError";
|
|
36
|
+
this.file = file;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Replace the FIRST `"version": "…"` key in the line's version file and
|
|
42
|
+
* verify `JSON.parse(after)` deep-equals `{ ...before, version: next }`.
|
|
43
|
+
* Absent file, absent/unparseable JSON, or a verification mismatch all
|
|
44
|
+
* throw VersionWriteError.
|
|
45
|
+
*/
|
|
46
|
+
export async function writeLineVersion(
|
|
47
|
+
worktree: string,
|
|
48
|
+
line: ReleaseLine,
|
|
49
|
+
nextVersion: string,
|
|
50
|
+
io: WorkspaceIO,
|
|
51
|
+
): Promise<void> {
|
|
52
|
+
if (line.versionFile === null) {
|
|
53
|
+
throw new VersionWriteError("(none)", `release line '${line.id}' has no version file`);
|
|
54
|
+
}
|
|
55
|
+
const file = join(worktree, line.versionFile);
|
|
56
|
+
if (!(await io.exists(file))) {
|
|
57
|
+
throw new VersionWriteError(line.versionFile, "file does not exist");
|
|
58
|
+
}
|
|
59
|
+
const before = await io.readFile(file);
|
|
60
|
+
let beforeDoc: Record<string, unknown>;
|
|
61
|
+
try {
|
|
62
|
+
beforeDoc = JSON.parse(before) as Record<string, unknown>;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw new VersionWriteError(
|
|
65
|
+
line.versionFile,
|
|
66
|
+
`unparseable JSON: ${error instanceof Error ? error.message : String(error)}`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const match = before.match(/"version"\s*:\s*"[^"]*"/);
|
|
70
|
+
if (match === null || match.index === undefined) {
|
|
71
|
+
throw new VersionWriteError(line.versionFile, "no top-level '\"version\"' key found");
|
|
72
|
+
}
|
|
73
|
+
const after = before.slice(0, match.index) + `"version": "${nextVersion}"` +
|
|
74
|
+
before.slice(match.index + match[0].length);
|
|
75
|
+
let afterDoc: Record<string, unknown>;
|
|
76
|
+
try {
|
|
77
|
+
afterDoc = JSON.parse(after) as Record<string, unknown>;
|
|
78
|
+
} catch {
|
|
79
|
+
throw new VersionWriteError(line.versionFile, "post-write JSON failed to parse");
|
|
80
|
+
}
|
|
81
|
+
const expected = JSON.stringify({ ...beforeDoc, version: nextVersion });
|
|
82
|
+
if (JSON.stringify(afterDoc) !== expected) {
|
|
83
|
+
throw new VersionWriteError(
|
|
84
|
+
line.versionFile,
|
|
85
|
+
`verified content differs — the replaced key was not the document's version field`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
await io.writeFile(file, after);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Replace the `syncedVersion:` scalar in forge.yaml, keeping its
|
|
93
|
+
* indentation and any trailing comment. Absent file or key throws
|
|
94
|
+
* VersionWriteError.
|
|
95
|
+
*/
|
|
96
|
+
export async function writeSyncedForgeVersion(
|
|
97
|
+
repoRoot: string,
|
|
98
|
+
nextVersion: string,
|
|
99
|
+
io: WorkspaceIO,
|
|
100
|
+
): Promise<void> {
|
|
101
|
+
const file = join(repoRoot, "forge.yaml");
|
|
102
|
+
if (!(await io.exists(file))) {
|
|
103
|
+
throw new VersionWriteError("forge.yaml", "file does not exist");
|
|
104
|
+
}
|
|
105
|
+
const before = await io.readFile(file);
|
|
106
|
+
const match = before.match(/^([ \t]*)syncedVersion:\s*\S[^\n]*$/m);
|
|
107
|
+
if (match === null || match.index === undefined) {
|
|
108
|
+
throw new VersionWriteError("forge.yaml", "no 'syncedVersion' key found");
|
|
109
|
+
}
|
|
110
|
+
const after =
|
|
111
|
+
before.slice(0, match.index) +
|
|
112
|
+
`${match[1]}syncedVersion: ${nextVersion}` +
|
|
113
|
+
before.slice(match.index + match[0].length);
|
|
114
|
+
await io.writeFile(file, after);
|
|
115
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>Worktree path contracts for the session lifecycle (RFC-1487): the
|
|
4
|
+
primary checkout is always the first entry of `git worktree list --porcelain`,
|
|
5
|
+
and a flow branch's worktree sits beside the primary as
|
|
6
|
+
<parent>/<repo>@<branch-slug> — the sibling depth keeps
|
|
7
|
+
sibling-relative paths (../systems-cache, link:../…) resolving unchanged.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>No worktree creation — flow.open decides names and calls git.</item>
|
|
10
|
+
</non-goals>
|
|
11
|
+
</MODULE_CONTRACT>
|
|
12
|
+
<KEY_DECISIONS>
|
|
13
|
+
<item>`@` in the directory name is a fixed operator decision (resolutions #1, FI-1) — it cannot collide with a real checkout because no governed branch slug contains it.</item>
|
|
14
|
+
<item>The path derives from the branch name only — renames of the primary directory stay invisible to the registry entry.</item>
|
|
15
|
+
</KEY_DECISIONS>
|
|
16
|
+
<CHANGE_SUMMARY>
|
|
17
|
+
<item>RFC-1487: step 1 — worktree path contracts</item>
|
|
18
|
+
<item>RFC-1487: step 1 — worktree path contracts, O_EXCL locks, branch registry and journal</item>
|
|
19
|
+
<item>RFC-1487: close rfc-1487 review findings — dirty-check parity with git worktree remove, ownership-verified lock release, FLOW-07 registry-error mapping, residual RFC-1462 docs removed
|
|
20
|
+
|
|
21
|
+
The dirty gate for session worktrees now uses full porcelain status
|
|
22
|
+
(untracked files included) because it predicts 'git worktree remove';
|
|
23
|
+
the primary-clean gate keeps tracked-only semantics because it predicts
|
|
24
|
+
'merge --ff-only'. Lock release verifies the held payload before
|
|
25
|
+
unlinking. Registry/journal failures map to FLOW-07 in every handler.
|
|
26
|
+
The final branch-name collision reports FLOW-OPEN-04, flow.discard
|
|
27
|
+
propagates its teardown result and predicts FLOW-DIS-03 on --dry-run,
|
|
28
|
+
and integrate exposes teardown as its own field.</item>
|
|
29
|
+
<item>RFC-1495: step 1 - forge state roots</item>
|
|
30
|
+
<item>RFC-1495: steps 2-3 - workshop paths resolver and call-site migration</item>
|
|
31
|
+
</CHANGE_SUMMARY>
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import { basename, dirname, join } from "node:path";
|
|
35
|
+
|
|
36
|
+
import type { WorkspaceIO } from "../../src/types.ts";
|
|
37
|
+
|
|
38
|
+
import { topLevel, worktreeList } from "./git.ts";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Absolute path of the repository's primary worktree — the first entry of
|
|
42
|
+
* `git worktree list --porcelain`, callable from any linked worktree. Throws
|
|
43
|
+
* when the output lists no worktree; when every entry is bare it falls back
|
|
44
|
+
* to the first entry.
|
|
45
|
+
*/
|
|
46
|
+
export async function primaryWorktree(
|
|
47
|
+
io: WorkspaceIO,
|
|
48
|
+
anyWorktree: string,
|
|
49
|
+
): Promise<string> {
|
|
50
|
+
const worktrees = await worktreeList(anyWorktree, io);
|
|
51
|
+
const primary = worktrees.find((w) => !w.bare) ?? worktrees[0];
|
|
52
|
+
if (!primary) {
|
|
53
|
+
throw new Error("git worktree list returned no worktree — bare repository?");
|
|
54
|
+
}
|
|
55
|
+
return primary.path;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* `<parent>/<repo>@<branch-slug>` — e.g.
|
|
60
|
+
* `/home/u/projects/warpgogol/werkstatt` + `auto/session-261101-01-forge-flow`
|
|
61
|
+
* → `/home/u/projects/warpgogol/werkstatt@auto-session-261101-01-forge-flow`.
|
|
62
|
+
*/
|
|
63
|
+
export function flowWorktreePath(primary: string, branch: string): string {
|
|
64
|
+
return join(dirname(primary), `${basename(primary)}@${branch.replaceAll("/", "-")}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* RFC-1495: the two state roots — the current worktree (per-session code and
|
|
69
|
+
* open missions) and the primary checkout (durable state). In a single
|
|
70
|
+
* worktree both are the same directory, so unadopted repositories resolve
|
|
71
|
+
* every path exactly as before. Non-git directories degrade to the passed
|
|
72
|
+
* root rather than throwing.
|
|
73
|
+
*/
|
|
74
|
+
export interface StateRoots {
|
|
75
|
+
/** `git rev-parse --show-toplevel` — the worktree this call runs in. */
|
|
76
|
+
worktreeRoot: string;
|
|
77
|
+
/** The first non-bare entry of `git worktree list` — the primary checkout. */
|
|
78
|
+
primaryRoot: string;
|
|
79
|
+
/** worktreeRoot === primaryRoot. */
|
|
80
|
+
isPrimary: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export async function resolveStateRoots(
|
|
84
|
+
repoRoot: string,
|
|
85
|
+
io: WorkspaceIO,
|
|
86
|
+
): Promise<StateRoots> {
|
|
87
|
+
const top = await topLevel(repoRoot, io);
|
|
88
|
+
// The workshop anchor is the caller's root — only when that root IS the
|
|
89
|
+
// repository worktree root does worktree topology apply. A subdirectory
|
|
90
|
+
// of a repo (or a non-git dir) has no workshop layout to resolve.
|
|
91
|
+
if (!top || top !== repoRoot.replace(/[/\\]+$/, "")) {
|
|
92
|
+
return { worktreeRoot: repoRoot, primaryRoot: repoRoot, isPrimary: true };
|
|
93
|
+
}
|
|
94
|
+
let primaryRoot: string;
|
|
95
|
+
try {
|
|
96
|
+
primaryRoot = await primaryWorktree(io, repoRoot);
|
|
97
|
+
} catch {
|
|
98
|
+
// worktree list empty or unparseable (non-git io, bare fixtures) —
|
|
99
|
+
// degrade to single-root rather than throwing.
|
|
100
|
+
return { worktreeRoot: repoRoot, primaryRoot: repoRoot, isPrimary: true };
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
worktreeRoot: repoRoot,
|
|
104
|
+
primaryRoot,
|
|
105
|
+
isPrimary: repoRoot === primaryRoot,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -454,6 +454,33 @@ describe("mission.archive", () => {
|
|
|
454
454
|
expect(commitCall![0]).toContain("refresh pnpm-lock.yaml after mission.archive");
|
|
455
455
|
});
|
|
456
456
|
|
|
457
|
+
test("W5-6: on a protected branch of an adopted repo the lockfile is neither staged nor committed", async () => {
|
|
458
|
+
execSyncMock.mockReset();
|
|
459
|
+
execSyncMock.mockImplementation((cmd: string) => {
|
|
460
|
+
if (cmd.startsWith("pnpm install")) return "";
|
|
461
|
+
if (cmd.startsWith("git status --porcelain pnpm-lock.yaml")) return "M pnpm-lock.yaml";
|
|
462
|
+
if (cmd.startsWith("git symbolic-ref")) return "develop\n";
|
|
463
|
+
return "";
|
|
464
|
+
});
|
|
465
|
+
await fs.mkdir(path.join(tmpDir, "hooks"), { recursive: true });
|
|
466
|
+
await fs.writeFile(path.join(tmpDir, "hooks", "flow-guard.sh"), "#!/bin/sh\n");
|
|
467
|
+
await writeMissionManifest(missionsDir, "test-m018b", "closed");
|
|
468
|
+
const warnings: string[] = [];
|
|
469
|
+
const context = makeContext(tmpDir);
|
|
470
|
+
(context.logger as { warn: (m: string) => void }).warn = (m: string) => warnings.push(m);
|
|
471
|
+
|
|
472
|
+
const data = unwrap(await runMissionArchive(makeInput(), context));
|
|
473
|
+
|
|
474
|
+
expect(data.moved).toHaveLength(1);
|
|
475
|
+
const gitWrites = execSyncMock.mock.calls.filter(
|
|
476
|
+
(c) =>
|
|
477
|
+
typeof c[0] === "string" &&
|
|
478
|
+
(c[0].startsWith("git add") || c[0].startsWith("git rm") || c[0].startsWith("git commit")),
|
|
479
|
+
);
|
|
480
|
+
expect(gitWrites).toEqual([]);
|
|
481
|
+
expect(warnings.some((w) => w.includes("develop") && w.includes("flow.open"))).toBe(true);
|
|
482
|
+
});
|
|
483
|
+
|
|
457
484
|
test("RFC-0804: pnpm install failure is non-fatal", async () => {
|
|
458
485
|
execSyncMock.mockReset();
|
|
459
486
|
execSyncMock.mockImplementation((cmd: string) => {
|
|
@@ -13,13 +13,11 @@ archive subdirectories back to missions/.
|
|
|
13
13
|
</non-goals>
|
|
14
14
|
</MODULE_CONTRACT>
|
|
15
15
|
<CHANGE_SUMMARY>
|
|
16
|
-
<item>RFC-1097: sweep — packages/forge + services clean
|
|
17
|
-
|
|
18
|
-
Sweep batch 2: real KEY_DECISIONS on 10 files, expanded purposes (CONTRACT-02/PURPOSE-02), headers on mission/index + gen-upstreams, sanitizeItemText in summary.record (literal Compass tags corrupted history), excludedPaths for wrangler types, test-fixtures testPattern. forge+services now 0 diagnostics under --mode error.</item>
|
|
19
16
|
<item>RFC-1138: pipeline hygiene — module-scoped exempt entries, archive gitignore guard, dns upsert to deploy phases, promote auto-sync, rfc.create claim protocol, siteHasRuntime filter</item>
|
|
20
17
|
<item>RFC-1397: ship-in-flight guard — per-candidate isShipInFlight check in both move phases; SHIP-INFLIGHT-01 skip, SHIP-INFLIGHT-02 stale warn, --ship-op self-exemption for the ship's own terminal archive step.</item>
|
|
21
18
|
<item>warpgogol-m000175 fo-fix: deferred-release guard — closed missions without releaseId keep workpiece node_modules on archive (archived dirs fall outside the pnpm-workspace glob, so deps cannot be reinstalled in place and release.prepare would fail on WORKPIECE-IMPORTS-01); released missions still get full service-folder cleanup.</item>
|
|
22
19
|
<item>RFC-1397: harden ship-in-flight guard per independent review (RFC-1397)</item>
|
|
20
|
+
<item>RFC-1495: step 1 - forge state roots</item>
|
|
23
21
|
<history>RFC-0573, RFC-0733, RFC-0801, RFC-0804, RFC-0982, RFC-1097</history>
|
|
24
22
|
</CHANGE_SUMMARY>
|
|
25
23
|
*/
|
|
@@ -48,6 +46,8 @@ import {
|
|
|
48
46
|
type MissionArchiveResult,
|
|
49
47
|
} from "../types.ts";
|
|
50
48
|
import { loadPinnedManifest, isPinned, isIntraDirMove } from "../../core/handlers/pinned-check.ts";
|
|
49
|
+
import { PROTECTED_BRANCHES } from "../../flow/branch-name.ts";
|
|
50
|
+
import { resolveStateRoots } from "../../flow/worktree-path.ts";
|
|
51
51
|
|
|
52
52
|
const SERVICE_FOLDERS = [
|
|
53
53
|
"node_modules",
|
|
@@ -261,6 +261,28 @@ async function moveMissionDir(
|
|
|
261
261
|
};
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
+
/**
|
|
265
|
+
* The current branch when it is a protected integration branch of a repository
|
|
266
|
+
* that carries the forge flow guard — commits there are refused. `null` when
|
|
267
|
+
* commits are allowed (no guard, an auto branch, detached HEAD).
|
|
268
|
+
*/
|
|
269
|
+
function protectedFlowBranch(workspaceRoot: string): string | null {
|
|
270
|
+
if (!existsSync(path.join(workspaceRoot, "hooks", "flow-guard.sh"))) return null;
|
|
271
|
+
let branch: string;
|
|
272
|
+
try {
|
|
273
|
+
branch = String(
|
|
274
|
+
execSync("git symbolic-ref --short -q HEAD", {
|
|
275
|
+
cwd: workspaceRoot,
|
|
276
|
+
encoding: "utf-8",
|
|
277
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
278
|
+
}),
|
|
279
|
+
).trim();
|
|
280
|
+
} catch {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
return (PROTECTED_BRANCHES as readonly string[]).includes(branch) ? branch : null;
|
|
284
|
+
}
|
|
285
|
+
|
|
264
286
|
export async function runMissionArchive(
|
|
265
287
|
input: ForgeCommandInput,
|
|
266
288
|
context: ForgeRuntimeContext,
|
|
@@ -289,6 +311,16 @@ export async function runMissionArchive(
|
|
|
289
311
|
// marker, never passed by hand).
|
|
290
312
|
const shipOp = typeof input.flags["ship-op"] === "string" ? input.flags["ship-op"] : undefined;
|
|
291
313
|
const io: WorkspaceIO = context.io ?? fs;
|
|
314
|
+
|
|
315
|
+
// RFC-1495: open missions live in the worktree they were opened in, but the
|
|
316
|
+
// archive is durable state — it belongs to the primary checkout. In a
|
|
317
|
+
// single-worktree repo both roots coincide and nothing changes.
|
|
318
|
+
const stateRoots = await resolveStateRoots(workspaceRoot, io).catch(() => ({
|
|
319
|
+
worktreeRoot: workspaceRoot,
|
|
320
|
+
primaryRoot: workspaceRoot,
|
|
321
|
+
isPrimary: true,
|
|
322
|
+
}));
|
|
323
|
+
const archiveRoot = path.join(stateRoots.primaryRoot, MISSIONS_DIR, ARCHIVE_DIR_NAME);
|
|
292
324
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
293
325
|
// @ts-ignore — workspace dep, may not be installed when forge is used standalone from npm
|
|
294
326
|
let shipInflightMod: typeof import("@warpgogol/werkstatt-shared/kernel/ship-inflight") | null =
|
|
@@ -485,7 +517,7 @@ export async function runMissionArchive(
|
|
|
485
517
|
}
|
|
486
518
|
}
|
|
487
519
|
|
|
488
|
-
const targetDir = path.join(
|
|
520
|
+
const targetDir = path.join(archiveRoot, state);
|
|
489
521
|
const targetPath = path.join(targetDir, missionId);
|
|
490
522
|
const targetRel = `${MISSIONS_DIR}/${ARCHIVE_DIR_NAME}/${state}/${missionId}`;
|
|
491
523
|
|
|
@@ -527,7 +559,7 @@ export async function runMissionArchive(
|
|
|
527
559
|
}
|
|
528
560
|
|
|
529
561
|
// Phase 2: Scan missions/archive/<state>/ for non-terminal missions to move back
|
|
530
|
-
const archivePath =
|
|
562
|
+
const archivePath = archiveRoot;
|
|
531
563
|
if (existsSync(archivePath)) {
|
|
532
564
|
const stateDirs = await fs.readdir(archivePath);
|
|
533
565
|
const stateDirNames = stateDirs.filter((e) => e.isDirectory).map((e) => e.name);
|
|
@@ -651,7 +683,15 @@ export async function runMissionArchive(
|
|
|
651
683
|
encoding: "utf-8",
|
|
652
684
|
stdio: ["pipe", "pipe", "pipe"],
|
|
653
685
|
}).trim();
|
|
654
|
-
|
|
686
|
+
// Fixed branch model: hooks/flow-guard.sh refuses commits on develop and
|
|
687
|
+
// main (FLOW-GUARD-01), and a refused commit would leave the lockfile
|
|
688
|
+
// staged in the primary checkout. There the refresh stays unstaged.
|
|
689
|
+
const protectedBranch = lockfileStatus ? protectedFlowBranch(workspaceRoot) : null;
|
|
690
|
+
if (lockfileStatus && protectedBranch) {
|
|
691
|
+
logger.warn(
|
|
692
|
+
` pnpm-lock.yaml changed on protected branch '${protectedBranch}' — not committed. Commit it from a flow session: pnpm exec werkstatt run flow.open --kind session --slug <slug>`,
|
|
693
|
+
);
|
|
694
|
+
} else if (lockfileStatus) {
|
|
655
695
|
execSync("git add pnpm-lock.yaml", {
|
|
656
696
|
cwd: workspaceRoot,
|
|
657
697
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -11,6 +11,7 @@ to sealed, and records the seal in the program manifest (RFC-0856).</purpose>
|
|
|
11
11
|
<CHANGE_SUMMARY>
|
|
12
12
|
<item>RFC-0856: initial seal command handler.</item>
|
|
13
13
|
<item>RFC-0857: reciprocal specRef/materializedAs mapping verification for spec-node packets (AC-7).</item>
|
|
14
|
+
<item>RFC-1499: step 3 — program manifests drop branch; legacy branch key stripped at parse</item>
|
|
14
15
|
</CHANGE_SUMMARY>
|
|
15
16
|
*/
|
|
16
17
|
|
|
@@ -154,7 +155,6 @@ export async function runSeal(
|
|
|
154
155
|
|
|
155
156
|
// Validate transition
|
|
156
157
|
const violations = validateSealTransition(manifest, entry, packet, {
|
|
157
|
-
branch,
|
|
158
158
|
head,
|
|
159
159
|
isClean,
|
|
160
160
|
hasActiveLease,
|
|
@@ -10,6 +10,7 @@ machine rules (RFC-0856).</purpose>
|
|
|
10
10
|
</MODULE_CONTRACT>
|
|
11
11
|
<CHANGE_SUMMARY>
|
|
12
12
|
<item>RFC-0856: initial validate command handler.</item>
|
|
13
|
+
<item>RFC-1499: step 3 — program manifests drop branch; legacy branch key stripped at parse</item>
|
|
13
14
|
</CHANGE_SUMMARY>
|
|
14
15
|
*/
|
|
15
16
|
|
|
@@ -162,7 +163,6 @@ export async function runValidate(
|
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
const sealViolations = validateSealTransition(manifest, entry, packet, {
|
|
165
|
-
branch,
|
|
166
166
|
head,
|
|
167
167
|
isClean,
|
|
168
168
|
hasActiveLease,
|