Skip to content

fix(Pull-SDLC): scaffold runs in worktree in auto-worktree mode; output lies when PR fails #166

Description

@MarkMichaelis

Problem

In auto-worktree mode (steady-state sync on protected branch), Pull-SDLC.ai.ps1 prints

Scaffolded consumer-owned files from templates:
  + .github/instructions/project.instructions.md
  + README.md
Open each file and fill in the sections, then commit them to your repo.

but those files are NOT present in the consumer's project tree. They were scaffolded into .worktrees/sdlc-sync/ (the inner Invoke-PullSDLC call's RepoRoot) and committed to chore/sdlc-sync. The intent is that the PR merge brings them back into main, but:

  • If PR creation fails (e.g. force-push race against a previously-merged scratch branch, Head sha can't be blank GraphQL error), the files are stranded in the worktree branch and never appear in the consumer's working tree.
  • Even when the PR succeeds, the files are not visible until the user merges the PR and pulls main -- which contradicts the printed message Open each file and fill in the sections, then commit them to your repo (implying they exist right now).

This is misleading at best and a silent data-loss vector at worst.

Proposal

Move the scaffold step out of the inner (worktree) Invoke-PullSDLC and run it in the parent consumer tree from the outer call, AFTER Invoke-AutoWorktreeSync returns. Consumer-owned scaffolded files are already in \ -- they're never part of the upstream-replay diff -- so creating them outside the PR commit is correct.

Concretely:

  • Add -NoScaffold switch to Invoke-PullSDLC; Invoke-AutoWorktreeSync passes it to the inner call so the worktree no longer scaffolds.
  • In Invoke-PullSDLC, after Invoke-AutoWorktreeSync returns rc=0, run Invoke-TemplateScaffold against the parent \ so the consumer immediately sees the new files in their project tree.
  • The Open each file ... message follows the actual file creation, in the same shell.

Tests to add

  • In auto-worktree mode, scaffolded files appear in the parent \, not in the worktree.
  • Scaffold runs even when Invoke-AutoWorktreeSync returns 0 with a failed PR step.
  • Direct (commit-on-main / bootstrap) mode continues to scaffold in-place exactly as before.

Note

.gitattributes is being removed from the scaffold map in a separate change -- it will be owned by Initialize-GitDefaults.ps1 instead. This issue concerns the remaining scaffolded files: CLAUDE.project.md, .github/instructions/project.instructions.md, README.md, tasks/README.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions