Skip to content

fix: Graceful Default-Init Skip in Non-Fab-Managed Repos#29

Merged
sahil-noon merged 4 commits into
mainfrom
260705-irnt-graceful-default-init-skip
Jul 5, 2026
Merged

fix: Graceful Default-Init Skip in Non-Fab-Managed Repos#29
sahil-noon merged 4 commits into
mainfrom
260705-irnt-graceful-default-init-skip

Conversation

@sahil-noon

Copy link
Copy Markdown
Collaborator

Meta

Change ID Type Confidence Plan Review
irnt fix 4.7/5.0 9/9 tasks, 20/20 acceptance ✓ ✓ 1 cycle
Impact +/− Net
raw +812 / −43 +769
true +335 / −23 +312
└ impl +111 / −18 +93
└ tests +224 / −5 +219

excludes fab/, docs/ · generated by fab-kit v2.13.4

Pipeline: intake ✓ → apply ✓ → review ✓ → hydrate ✓ → ship → review-pr

Summary

wt's default init script (fab sync) previously treated any non-fab-managed repo as a hard init failure (exit 7, kept-worktree banner, open-anyway prompt), even though the user never opted into that default. This change treats fab-kit's ExitNotManaged = 3 exit code as a graceful no-op when the init script is the built-in default, while an explicitly configured WORKTREE_INIT_SCRIPT still hard-fails on any non-zero exit.

Changes

  • InitScriptPath() now signals provenance (isDefault) alongside the script string, so downstream logic can distinguish the built-in default from an explicit override
  • Run-time skip classification: after fab sync exits non-zero, a default script + exit code 3 is treated as "does not apply" (stderr warning, exit 0, no banner, no prompt); all other cases keep today's hard-failure behavior
  • Threaded isDefault through RunWorktreeSetup/RunWorktreeSetupWithObserver (crud.go) and wt init (cmd/wt/init.go), plus both wt create call sites (cmd/wt/create.go)
  • Old fab-kit (pre-#471, exits 1) degrades to unchanged hard-fail behavior — no version detection or fallback probe
  • Unit and integration test coverage for the classification helper, InitScriptPath provenance, and end-to-end wt create/wt init behavior via a stubbed fab binary
  • Spec update to docs/specs/init-protocol.md documenting the new skip case and provenance-based lookup contract

sahil87 added 2 commits July 6, 2026 00:38
Treats fab sync exit code 3 (ExitNotManaged) as a no-op when the init
script is the built-in default, instead of a hard init failure. An
explicit WORKTREE_INIT_SCRIPT still hard-fails on any non-zero exit.
@sahil-noon sahil-noon marked this pull request as ready for review July 5, 2026 19:10
@sahil-noon sahil-noon requested a review from Copilot July 5, 2026 19:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates wt’s default worktree init behavior so that when the built-in default init script (fab sync) is run in a non-fab-managed repository and exits with fab-kit’s ExitNotManaged = 3, wt treats it as a graceful “does not apply” no-op (warning + exit 0) rather than an init failure (exit 7 + banner/prompt). It also threads “default vs explicit” provenance (isDefault) so only the built-in default gets this carve-out; explicitly configured init scripts still hard-fail on any non-zero exit.

Changes:

  • InitScriptPath() now returns (script, isDefault) so callers can distinguish the built-in default from an explicit WORKTREE_INIT_SCRIPT override (even if the override equals "fab sync").
  • Added a shared run-time classifier (DefaultNotApplicable) and canonical warning renderer (RenderDefaultSkipWarning) and applied them consistently in both init run sites (wt create and wt init).
  • Added unit + integration tests (via stubbed fab) and updated specs/memory docs to document the new “default-not-applicable” skip semantics.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/internal/worktree/init.go Adds exit-code classifier + shared skip-warning renderer for the default “fab sync” non-managed case.
src/internal/worktree/init_test.go Unit tests for the classifier and warning renderer.
src/internal/worktree/crud.go Threads isDefault into init runner and applies the skip classification in wt create’s init path.
src/internal/worktree/context.go Changes InitScriptPath() to return both script and provenance (isDefault).
src/internal/worktree/context_test.go Updates/adds provenance tests for InitScriptPath() (including explicit "fab sync").
src/cmd/wt/create.go Passes (script, isDefault) through both init call sites.
src/cmd/wt/init.go Applies the same skip classification in wt init, preserving TTY reclaim ordering.
src/cmd/wt/integration_test.go Integration coverage using a stub fab to validate exit-3 skip vs exit-1 hard-fail and provenance gating.
docs/specs/init-protocol.md Documents provenance reporting + the new run-time skip case and exit-3 carve-out.
docs/specs/cli-surface.md Updates CLI exit-code semantics to reflect ExitInitFailed and the new non-failure skip outcomes.
docs/memory/wt-cli/init-failure-contract.md Records the new default-not-applicable carve-out and shared-helper behavior.
docs/memory/wt-cli/create-output-phases.md Notes the carve-out’s effect on wt init/wt create output/exit behavior.
fab/changes/260705-irnt-graceful-default-init-skip/intake.md Captures requirements and design rationale for the change.
fab/changes/260705-irnt-graceful-default-init-skip/plan.md Implementation plan and acceptance checklist for the change.
fab/changes/260705-irnt-graceful-default-init-skip/.status.yaml Change metadata/status tracking.
fab/changes/260705-irnt-graceful-default-init-skip/.history.jsonl Change execution history log.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/internal/worktree/crud.go Outdated
Comment on lines +126 to +129
// - On the default-not-applicable skip (isDefault AND exit 3, per
// DefaultNotApplicable), prints the skip warning to stderr and returns nil.
// - Returns the exec error verbatim on any other init-script non-zero exit so
// callers can extract *exec.ExitError via errors.As.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — doc comment now says the exec error is wrapped via %w (not returned verbatim), while keeping the errors.As extraction guarantee. (6294663)

@sahil-noon sahil-noon merged commit 3976025 into main Jul 5, 2026
2 checks passed
@sahil-noon sahil-noon deleted the 260705-irnt-graceful-default-init-skip branch July 5, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants