@warpgogol/forge 9.1.1 → 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 +31 -0
- 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 +10 -8
- package/docs/reference/cli.md +0 -3
- 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
package/os/flow/locks.ts
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>Exclusive file locks for flow commands (RFC-1487): O_EXCL lock files
|
|
4
|
+
carrying { pid, host, at }, wait-with-progress while a live holder exists,
|
|
5
|
+
stale locks broken by age, always released in finally. Used for the short
|
|
6
|
+
registry lock (10 s) and the long integration lock (30 min).</purpose>
|
|
7
|
+
<non-goals>
|
|
8
|
+
<item>No registry semantics — callers choose paths, budgets and diagnostics.</item>
|
|
9
|
+
</non-goals>
|
|
10
|
+
</MODULE_CONTRACT>
|
|
11
|
+
<KEY_DECISIONS>
|
|
12
|
+
<item>Staleness reads the lock file's `at` timestamp, not mtime — a crashed holder leaves a frozen file whose content is authoritative (DNA-105).</item>
|
|
13
|
+
<item>Timeout throws LockTimeoutError naming the file — each command maps it to its own diagnostic (FLOW-07 for the registry, FLOW-INT-08 for integrate).</item>
|
|
14
|
+
</KEY_DECISIONS>
|
|
15
|
+
<CHANGE_SUMMARY>
|
|
16
|
+
<item>RFC-1487: step 1 — exclusive file locks</item>
|
|
17
|
+
<item>RFC-1487: step 1 — worktree path contracts, O_EXCL locks, branch registry and journal</item>
|
|
18
|
+
<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
|
|
19
|
+
|
|
20
|
+
The dirty gate for session worktrees now uses full porcelain status
|
|
21
|
+
(untracked files included) because it predicts 'git worktree remove';
|
|
22
|
+
the primary-clean gate keeps tracked-only semantics because it predicts
|
|
23
|
+
'merge --ff-only'. Lock release verifies the held payload before
|
|
24
|
+
unlinking. Registry/journal failures map to FLOW-07 in every handler.
|
|
25
|
+
The final branch-name collision reports FLOW-OPEN-04, flow.discard
|
|
26
|
+
propagates its teardown result and predicts FLOW-DIS-03 on --dry-run,
|
|
27
|
+
and integrate exposes teardown as its own field.</item>
|
|
28
|
+
</CHANGE_SUMMARY>
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import { hostname } from "node:os";
|
|
32
|
+
import { open, rm } from "node:fs/promises";
|
|
33
|
+
|
|
34
|
+
export interface FlowLockOptions {
|
|
35
|
+
/** Maximum time to wait for a live lock before throwing LockTimeoutError. */
|
|
36
|
+
waitMs: number;
|
|
37
|
+
/** A lock whose `at` is older than this is broken with an onStale warning. */
|
|
38
|
+
staleMs: number;
|
|
39
|
+
/** Emit onProgress at this interval while waiting (0/undefined = silent). */
|
|
40
|
+
progressEveryMs?: number;
|
|
41
|
+
onProgress?: (message: string) => void;
|
|
42
|
+
/** Called when a stale lock is broken — the caller logs the warning. */
|
|
43
|
+
onStale?: (lock: { path: string; at: string; ageMs: number }) => void;
|
|
44
|
+
/** Injectable clock for tests. */
|
|
45
|
+
now?: () => number;
|
|
46
|
+
/** Injectable sleep for tests. */
|
|
47
|
+
sleep?: (ms: number) => Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Thrown when the wait budget elapses while a live lock is held. */
|
|
51
|
+
export class LockTimeoutError extends Error {
|
|
52
|
+
readonly lockPath: string;
|
|
53
|
+
constructor(lockPath: string, waitedMs: number) {
|
|
54
|
+
super(`lock ${lockPath} still held after ${waitedMs} ms`);
|
|
55
|
+
this.name = "LockTimeoutError";
|
|
56
|
+
this.lockPath = lockPath;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface LockFileContent {
|
|
61
|
+
pid: number;
|
|
62
|
+
host: string;
|
|
63
|
+
at: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const defaultSleep = (ms: number): Promise<void> =>
|
|
67
|
+
new Promise((resolve) => setTimeout(resolve, ms));
|
|
68
|
+
|
|
69
|
+
async function tryAcquire(lockPath: string, content: LockFileContent): Promise<boolean> {
|
|
70
|
+
try {
|
|
71
|
+
const handle = await open(lockPath, "wx");
|
|
72
|
+
try {
|
|
73
|
+
await handle.writeFile(JSON.stringify(content));
|
|
74
|
+
} finally {
|
|
75
|
+
await handle.close();
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
} catch (error) {
|
|
79
|
+
if ((error as NodeJS.ErrnoException).code === "EEXIST") return false;
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Age of the held lock in ms; null when the file vanished or is unreadable. */
|
|
85
|
+
async function lockAgeMs(
|
|
86
|
+
lockPath: string,
|
|
87
|
+
readFile: (path: string) => Promise<string>,
|
|
88
|
+
nowMs: number,
|
|
89
|
+
): Promise<number | null> {
|
|
90
|
+
let raw: string;
|
|
91
|
+
try {
|
|
92
|
+
raw = await readFile(lockPath);
|
|
93
|
+
} catch {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const parsed = JSON.parse(raw) as { at?: unknown };
|
|
98
|
+
if (typeof parsed.at !== "string") return null;
|
|
99
|
+
const at = Date.parse(parsed.at);
|
|
100
|
+
if (Number.isNaN(at)) return null;
|
|
101
|
+
return nowMs - at;
|
|
102
|
+
} catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Hold `lockPath` exclusively for the duration of `fn`. Waits while a live
|
|
109
|
+
* holder exists, breaks a lock older than `staleMs` with an onStale warning,
|
|
110
|
+
* throws LockTimeoutError when the budget elapses. The lock is always
|
|
111
|
+
* released — a failed `fn` never leaks it.
|
|
112
|
+
*/
|
|
113
|
+
export async function withFlowLock<T>(
|
|
114
|
+
lockPath: string,
|
|
115
|
+
opts: FlowLockOptions,
|
|
116
|
+
fn: () => Promise<T>,
|
|
117
|
+
io: { readFile: (path: string) => Promise<string> },
|
|
118
|
+
): Promise<T> {
|
|
119
|
+
const now = opts.now ?? (() => Date.now());
|
|
120
|
+
const sleep = opts.sleep ?? defaultSleep;
|
|
121
|
+
const deadline = now() + opts.waitMs;
|
|
122
|
+
let nextProgress = now() + (opts.progressEveryMs ?? Number.POSITIVE_INFINITY);
|
|
123
|
+
|
|
124
|
+
let heldPayload: { pid: number; at: string } | null = null;
|
|
125
|
+
for (;;) {
|
|
126
|
+
const at = new Date(now()).toISOString();
|
|
127
|
+
const acquired = await tryAcquire(lockPath, {
|
|
128
|
+
pid: process.pid,
|
|
129
|
+
host: hostname(),
|
|
130
|
+
at,
|
|
131
|
+
});
|
|
132
|
+
if (acquired) {
|
|
133
|
+
heldPayload = { pid: process.pid, at };
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const age = await lockAgeMs(lockPath, io.readFile, now());
|
|
138
|
+
if (age !== null && age > opts.staleMs) {
|
|
139
|
+
opts.onStale?.({
|
|
140
|
+
path: lockPath,
|
|
141
|
+
at: new Date(now() - age).toISOString(),
|
|
142
|
+
ageMs: age,
|
|
143
|
+
});
|
|
144
|
+
await rm(lockPath, { force: true });
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (now() >= deadline) {
|
|
148
|
+
throw new LockTimeoutError(lockPath, now() - (deadline - opts.waitMs));
|
|
149
|
+
}
|
|
150
|
+
if (opts.progressEveryMs && now() >= nextProgress) {
|
|
151
|
+
opts.onProgress?.(`waiting for ${lockPath}`);
|
|
152
|
+
nextProgress = now() + opts.progressEveryMs;
|
|
153
|
+
}
|
|
154
|
+
await sleep(Math.min(50, Math.max(1, deadline - now())));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
return await fn();
|
|
159
|
+
} finally {
|
|
160
|
+
// Release only the lock we hold: after a stale-break takeover the file
|
|
161
|
+
// may carry a newer holder's payload — unlinking it would leave no
|
|
162
|
+
// mutual exclusion at all.
|
|
163
|
+
let stillOurs = false;
|
|
164
|
+
try {
|
|
165
|
+
const raw = await io.readFile(lockPath);
|
|
166
|
+
const parsed = JSON.parse(raw) as { pid?: number; at?: string };
|
|
167
|
+
stillOurs = parsed.pid === heldPayload?.pid && parsed.at === heldPayload?.at;
|
|
168
|
+
} catch {
|
|
169
|
+
stillOurs = false;
|
|
170
|
+
}
|
|
171
|
+
// Residual TOCTOU: a takeover between the read above and this rm could
|
|
172
|
+
// still unlink a fresh holder's lock — only reachable once our own lock
|
|
173
|
+
// aged past staleMs, which the stale-breaker already accepts as dead.
|
|
174
|
+
// A true fix needs compare-and-delete semantics the filesystem lacks.
|
|
175
|
+
if (stillOurs) await rm(lockPath, { force: true });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>The forge.generated.yaml extract marker (RFC-1491): written into
|
|
4
|
+
every package-line directory by flow.install's `markers` step, checked by
|
|
5
|
+
flow.check FLOW-10 and flow.push FLOW-PUSH-06. repo-extract copies the
|
|
6
|
+
marker into the extract repository, where the top-level presence exempts
|
|
7
|
+
that repository from the flow guard.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>No marker creation at the repository root — a root marker would exempt the monorepo itself.</item>
|
|
10
|
+
<item>No npm packaging policy — package `files` lists keep the marker out of tarballs.</item>
|
|
11
|
+
</non-goals>
|
|
12
|
+
</MODULE_CONTRACT>
|
|
13
|
+
<KEY_DECISIONS>
|
|
14
|
+
<item>"Valid" is the strict content contract: parseable YAML carrying schema forge/generated@1 and generator repo-extract — the flow.check FLOW-10 wording matches exactly this test.</item>
|
|
15
|
+
<item>`source` accepts only network origins (RFC-1498): http/https/ssh/git schemes or scp form, userinfo stripped; a local path or file:// URL falls back to the directory basename and reports its rejection kind — the path is never written into a marker.</item>
|
|
16
|
+
</KEY_DECISIONS>
|
|
17
|
+
<CHANGE_SUMMARY>
|
|
18
|
+
<item>RFC-1491: step 2 — extract markers (flow.install step, FLOW-10, FLOW-PUSH-06 input)</item>
|
|
19
|
+
<item>RFC-1491: step 2 — pre-push guard mode, install steps pre-push + markers, FLOW-10</item>
|
|
20
|
+
<item>RFC-1498: step 2 — network-only marker source + rejectedOrigin reporting</item>
|
|
21
|
+
</CHANGE_SUMMARY>
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { basename, join } from "node:path";
|
|
25
|
+
|
|
26
|
+
import { parse as yamlParse } from "yaml";
|
|
27
|
+
|
|
28
|
+
import type { WorkspaceIO } from "../../src/types.ts";
|
|
29
|
+
|
|
30
|
+
import { git } from "./git.ts";
|
|
31
|
+
import { discoverReleaseLines, type ReleaseLine } from "./release-lines.ts";
|
|
32
|
+
|
|
33
|
+
export const MARKER_FILE = "forge.generated.yaml";
|
|
34
|
+
export const MARKER_SCHEMA = "forge/generated@1";
|
|
35
|
+
export const MARKER_GENERATOR = "repo-extract";
|
|
36
|
+
|
|
37
|
+
export interface LineMarker {
|
|
38
|
+
/** Release-line id (the package directory basename). */
|
|
39
|
+
line: string;
|
|
40
|
+
/** The package line directory relative to the repository root. */
|
|
41
|
+
dir: string;
|
|
42
|
+
/** Absolute marker path. */
|
|
43
|
+
file: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Marker file content for one package line directory. */
|
|
47
|
+
export function markerContent(source: string): string {
|
|
48
|
+
return `schema: ${MARKER_SCHEMA}\ngenerator: ${MARKER_GENERATOR}\nsource: ${source}\n`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Why an origin URL was rejected as a marker source (RFC-1498). */
|
|
52
|
+
export type RejectedOriginKind = "local-path" | "file-url";
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* True for origins that can reach a remote: a network scheme
|
|
56
|
+
* (http, https, ssh, git) or the scp form `<user>@<host>:<path>`
|
|
57
|
+
* (RFC-1498). Local paths, `file://` URLs and anything else are not
|
|
58
|
+
* marker sources — they would leak a machine-local path into the
|
|
59
|
+
* extract repository's forge.generated.yaml.
|
|
60
|
+
*/
|
|
61
|
+
export function isNetworkOriginUrl(url: string): boolean {
|
|
62
|
+
if (/^(https?|ssh|git):\/\//i.test(url)) return true;
|
|
63
|
+
// scp-like syntax — user@host:path (git's shorthand for ssh).
|
|
64
|
+
return /^[^/@\s]+@[^:/\s]+:[^\s]+$/.test(url);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The marker `source` value for a repository (RFC-1498): the
|
|
69
|
+
* credential-stripped `origin` URL when it is network-shaped, else the
|
|
70
|
+
* repository directory basename with `rejectedOrigin` naming the kind —
|
|
71
|
+
* never the path itself, so no machine-local path is written into an
|
|
72
|
+
* extract repository.
|
|
73
|
+
*/
|
|
74
|
+
export async function markerSource(
|
|
75
|
+
repoRoot: string,
|
|
76
|
+
io: WorkspaceIO,
|
|
77
|
+
): Promise<{ source: string; rejectedOrigin: RejectedOriginKind | null }> {
|
|
78
|
+
const url = await git(repoRoot, io, ["remote", "get-url", "origin"]);
|
|
79
|
+
const raw = url.exitCode === 0 ? url.stdout.trim() : "";
|
|
80
|
+
if (raw.length === 0) {
|
|
81
|
+
return { source: basename(repoRoot), rejectedOrigin: null };
|
|
82
|
+
}
|
|
83
|
+
if (isNetworkOriginUrl(raw)) {
|
|
84
|
+
// Strip userinfo — https://user:pass@host/path → https://host/path.
|
|
85
|
+
return {
|
|
86
|
+
source: raw.replace(/^([a-z][a-z0-9+.-]*:\/\/)[^/@]*@/i, "$1"),
|
|
87
|
+
rejectedOrigin: null,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
source: basename(repoRoot),
|
|
92
|
+
rejectedOrigin: /^file:/i.test(raw) ? "file-url" : "local-path",
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** True when marker content parses and carries the schema + generator. */
|
|
97
|
+
export function markerContentIsValid(content: string | null): boolean {
|
|
98
|
+
if (content === null) return false;
|
|
99
|
+
let raw: unknown;
|
|
100
|
+
try {
|
|
101
|
+
raw = yamlParse(content);
|
|
102
|
+
} catch {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (raw === null || typeof raw !== "object") return false;
|
|
106
|
+
const rec = raw as Record<string, unknown>;
|
|
107
|
+
return rec.schema === MARKER_SCHEMA && rec.generator === MARKER_GENERATOR;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** True when `file` parses and carries the marker schema + generator. */
|
|
111
|
+
export async function markerIsValid(file: string, io: WorkspaceIO): Promise<boolean> {
|
|
112
|
+
if (!(await io.exists(file))) return false;
|
|
113
|
+
return markerContentIsValid(await io.readFile(file));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Package lines whose directory lacks a valid marker. The repo line
|
|
118
|
+
* (`paths: []`) never gets one — a root marker would exempt the monorepo.
|
|
119
|
+
*/
|
|
120
|
+
export async function missingLineMarkers(
|
|
121
|
+
repoRoot: string,
|
|
122
|
+
io: WorkspaceIO,
|
|
123
|
+
): Promise<{ markers: LineMarker[]; lines: ReleaseLine[] }> {
|
|
124
|
+
const { lines } = await discoverReleaseLines(repoRoot, io);
|
|
125
|
+
const markers: LineMarker[] = [];
|
|
126
|
+
for (const line of lines) {
|
|
127
|
+
const dir = line.paths[0];
|
|
128
|
+
if (dir === undefined) continue; // repo line — no marker
|
|
129
|
+
const file = join(repoRoot, dir, MARKER_FILE);
|
|
130
|
+
if (!(await markerIsValid(file, io))) {
|
|
131
|
+
markers.push({ line: line.id, dir, file });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return { markers, lines };
|
|
135
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>Generated-artifact publication for one release tag (RFC-1491):
|
|
4
|
+
repo-extract the package line's extract repo at the tag, run the
|
|
5
|
+
extract-verify hook, push the destination once — reconciling with a single
|
|
6
|
+
ours-merge only on a non-fast-forward rejection, never force-pushing —
|
|
7
|
+
and return the RFC publications[] row for the journal.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>No push orchestration — handlers/flow-push.ts owns preflight and the atomic push.</item>
|
|
10
|
+
<item>No real repo-extract in tests — fixtures install a fake node_modules/.bin/repo-extract.</item>
|
|
11
|
+
</non-goals>
|
|
12
|
+
</MODULE_CONTRACT>
|
|
13
|
+
<KEY_DECISIONS>
|
|
14
|
+
<item>Destination resolution mirrors the retired publish-forge.mjs (RFC-1499) resolveDest(): destBase/destName parsed from extract.config.yaml, anchored at dirname(primary), destBase default "packages".</item>
|
|
15
|
+
<item>Reconcile only on non-fast-forward (the same regex as the retired publish-forge.mjs, RFC-1499) — auth, hook and transient failures never trigger an ours-merge.</item>
|
|
16
|
+
</KEY_DECISIONS>
|
|
17
|
+
<CHANGE_SUMMARY>
|
|
18
|
+
<item>RFC-1491: step 5 — publishTag (extract, verify, dest push, single ours-merge reconcile)</item>
|
|
19
|
+
<item>RFC-1491: step 5 — flow.push atomic outbound path + extract publication</item>
|
|
20
|
+
<item>RFC-1491: independent-review pass — shared lock constants, publishable pending filter, declared rules, hold ordering, sha-pinned refspecs</item>
|
|
21
|
+
<item>RFC-1499: step 2 — retire publish-forge/bump-forge scripts, add extract-verify hook</item>
|
|
22
|
+
</CHANGE_SUMMARY>
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { dirname, join, resolve } from "node:path";
|
|
26
|
+
|
|
27
|
+
import type { WorkspaceIO } from "../../src/types.ts";
|
|
28
|
+
import { git, gitCommit } from "./git.ts";
|
|
29
|
+
import { runFlowScript, type FlowScriptResult } from "./scripts.ts";
|
|
30
|
+
import type { ReleaseLine } from "./release-lines.ts";
|
|
31
|
+
|
|
32
|
+
export interface PublicationRow {
|
|
33
|
+
tag: string;
|
|
34
|
+
line: string;
|
|
35
|
+
status: "published" | "failed" | "skipped-baseline" | "pending";
|
|
36
|
+
dest: string | null;
|
|
37
|
+
verify: FlowScriptResult | null;
|
|
38
|
+
reconciled: boolean;
|
|
39
|
+
destHead: string | null;
|
|
40
|
+
/** FLOW-PUSH-05 detail when status === "failed". */
|
|
41
|
+
error?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** `destBase`/`destName` from extract.config.yaml, anchored at dirname(primary) (resolveDest parity). */
|
|
45
|
+
export async function resolveExtractDest(
|
|
46
|
+
primary: string,
|
|
47
|
+
io: WorkspaceIO,
|
|
48
|
+
line: ReleaseLine,
|
|
49
|
+
): Promise<string | null> {
|
|
50
|
+
const dir = line.paths[0];
|
|
51
|
+
if (dir === undefined) return null;
|
|
52
|
+
const configPath = join(primary, dir, "extract.config.yaml");
|
|
53
|
+
if (!(await io.exists(configPath))) return null;
|
|
54
|
+
const raw = await io.readFile(configPath);
|
|
55
|
+
const unquote = (v: string | undefined): string | undefined =>
|
|
56
|
+
v?.replace(/^["']|["']$/g, "");
|
|
57
|
+
const destBase = unquote(raw.match(/^destBase:\s*(\S+)\s*$/m)?.[1]);
|
|
58
|
+
const destName = unquote(raw.match(/^destName:\s*(\S+)\s*$/m)?.[1]);
|
|
59
|
+
if (destName === undefined) return null;
|
|
60
|
+
return resolve(
|
|
61
|
+
dirname(primary),
|
|
62
|
+
destBase ?? "packages",
|
|
63
|
+
destName,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The annotation's `level:` field — baseline tags are never published. */
|
|
68
|
+
export async function tagAnnotationLevel(
|
|
69
|
+
repoRoot: string,
|
|
70
|
+
io: WorkspaceIO,
|
|
71
|
+
tag: string,
|
|
72
|
+
): Promise<string | null> {
|
|
73
|
+
const result = await git(repoRoot, io, [
|
|
74
|
+
"for-each-ref",
|
|
75
|
+
`refs/tags/${tag}`,
|
|
76
|
+
"--format=%(contents)",
|
|
77
|
+
]);
|
|
78
|
+
if (result.exitCode !== 0) return null;
|
|
79
|
+
return result.stdout.match(/^level:\s*(\S+)\s*$/m)?.[1] ?? null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Publish one package-line tag: extract at the tag ref, verify via the hook,
|
|
84
|
+
* push the destination. A non-fast-forward rejection reconciles once with
|
|
85
|
+
* fetch + ours-merge (local tree is the authoritative export), never force.
|
|
86
|
+
*/
|
|
87
|
+
export async function publishTag(
|
|
88
|
+
primary: string,
|
|
89
|
+
io: WorkspaceIO,
|
|
90
|
+
opts: { line: ReleaseLine; tag: string },
|
|
91
|
+
): Promise<PublicationRow> {
|
|
92
|
+
const { line, tag } = opts;
|
|
93
|
+
const row: PublicationRow = {
|
|
94
|
+
tag,
|
|
95
|
+
line: line.id,
|
|
96
|
+
status: "published",
|
|
97
|
+
dest: null,
|
|
98
|
+
verify: null,
|
|
99
|
+
reconciled: false,
|
|
100
|
+
destHead: null,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const dir = line.paths[0];
|
|
104
|
+
if (dir === undefined) {
|
|
105
|
+
row.status = "failed";
|
|
106
|
+
row.error = `line ${line.id} has no package directory`;
|
|
107
|
+
return row;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const level = await tagAnnotationLevel(primary, io, tag);
|
|
111
|
+
if (level === "baseline") {
|
|
112
|
+
row.status = "skipped-baseline";
|
|
113
|
+
return row;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 1. Extract — the binary lives in the adopting repository's own install.
|
|
117
|
+
const extract = await io.exec(
|
|
118
|
+
join(primary, "node_modules", ".bin", "repo-extract"),
|
|
119
|
+
["--config", `${dir}/extract.config.yaml`, "--ref", tag, "--no-push"],
|
|
120
|
+
{ cwd: primary },
|
|
121
|
+
);
|
|
122
|
+
if (extract.exitCode !== 0) {
|
|
123
|
+
row.status = "failed";
|
|
124
|
+
row.error = `repo-extract failed (exit ${extract.exitCode}): ${extract.stderr.trim().split("\n").slice(-1)[0] ?? ""}`;
|
|
125
|
+
return row;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 2. Destination — same resolution as the retired publish-forge.mjs (RFC-1499).
|
|
129
|
+
const dest = await resolveExtractDest(primary, io, line);
|
|
130
|
+
row.dest = dest;
|
|
131
|
+
if (dest === null || !(await io.exists(join(dest, ".git")))) {
|
|
132
|
+
row.status = "failed";
|
|
133
|
+
row.error = `extract destination could not be resolved for ${tag} (destName in ${dir}/extract.config.yaml)`;
|
|
134
|
+
return row;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 3. Verify hook — absent script reports skipped, a failure stops here.
|
|
138
|
+
const verify = await runFlowScript(io, "extract-verify", {
|
|
139
|
+
primary,
|
|
140
|
+
cwd: primary,
|
|
141
|
+
env: {
|
|
142
|
+
FORGE_FLOW_EXTRACT_DEST: dest,
|
|
143
|
+
FORGE_FLOW_TAG: tag,
|
|
144
|
+
FORGE_FLOW_LINE: line.id,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
row.verify = verify;
|
|
148
|
+
if (verify.status === "failed") {
|
|
149
|
+
row.status = "failed";
|
|
150
|
+
row.error = `extract-verify failed (exit ${verify.exitCode}): ${verify.stderrTail}`;
|
|
151
|
+
return row;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 4. Push the extract destination — `branch --show-current` first, the
|
|
155
|
+
// rev-parse fallback keeps a detached export HEAD pushable.
|
|
156
|
+
const branchShown = await git(dest, io, ["branch", "--show-current"]);
|
|
157
|
+
const branch =
|
|
158
|
+
branchShown.stdout.trim() ||
|
|
159
|
+
(await git(dest, io, ["rev-parse", "--abbrev-ref", "HEAD"])).stdout.trim();
|
|
160
|
+
const firstPush = await git(dest, io, ["push", "-u", "origin", branch]);
|
|
161
|
+
if (firstPush.exitCode !== 0) {
|
|
162
|
+
const out = `${firstPush.stdout}\n${firstPush.stderr}`;
|
|
163
|
+
if (!/non-fast-forward|\(fetch first\)/i.test(out)) {
|
|
164
|
+
row.status = "failed";
|
|
165
|
+
row.error = `destination push failed: ${out.trim().split("\n").slice(-1)[0] ?? ""}`;
|
|
166
|
+
return row;
|
|
167
|
+
}
|
|
168
|
+
// Reconcile once — the exported tree is authoritative; remote history
|
|
169
|
+
// is preserved. Never force-push.
|
|
170
|
+
row.reconciled = true;
|
|
171
|
+
await git(dest, io, ["fetch", "origin"]);
|
|
172
|
+
const merge = await gitCommit(
|
|
173
|
+
dest,
|
|
174
|
+
io,
|
|
175
|
+
[
|
|
176
|
+
"merge",
|
|
177
|
+
"-s",
|
|
178
|
+
"ours",
|
|
179
|
+
"--allow-unrelated-histories",
|
|
180
|
+
"-m",
|
|
181
|
+
"merge: reconcile remote export history (local tree is authoritative export)",
|
|
182
|
+
`origin/${branch}`,
|
|
183
|
+
],
|
|
184
|
+
"publish",
|
|
185
|
+
);
|
|
186
|
+
if (merge.exitCode !== 0) {
|
|
187
|
+
row.status = "failed";
|
|
188
|
+
row.error = `reconcile merge failed: ${merge.stderr.trim().split("\n").slice(-1)[0] ?? ""}`;
|
|
189
|
+
return row;
|
|
190
|
+
}
|
|
191
|
+
const retry = await git(dest, io, ["push", "-u", "origin", branch]);
|
|
192
|
+
if (retry.exitCode !== 0) {
|
|
193
|
+
row.status = "failed";
|
|
194
|
+
row.error = `destination push failed after reconcile: ${retry.stderr.trim().split("\n").slice(-1)[0] ?? ""}`;
|
|
195
|
+
return row;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
row.destHead = (await git(dest, io, ["rev-parse", "HEAD"])).stdout.trim();
|
|
200
|
+
return row;
|
|
201
|
+
}
|