Initializers bind PLAN_ID for the attestation call but not PWF_PLAN_ROOT, so an inherited pin redirects attestation

Author: OthmanAdiCreated Sep 17, 2026Updated Sep 17, 2026
Labelsbughelp wantedgood first issue

Problem

Both initializers attest the plan they just created by calling the attester with PLAN_ID bound to the new plan (init-session.sh line PLAN_ID="${PLAN_ID:-}" sh "${_attest}", init-session.ps1 sets $env:PLAN_ID = $PlanId around the attest-plan.ps1 call). Neither binds PWF_PLAN_ROOT for that call. The attester resolves through resolve-plan-dir and honours an inherited PWF_PLAN_ROOT, so a pin left in the environment from another project redirects or blocks the attestation of the plan that was just written in the current directory.

Scope: users who export PWF_PLAN_ROOT (the nested-project pin from issue #212) and then run the initializer in a different directory. With the variable unset there is no problem. The planning files themselves are created correctly in every case; only the attestation step is affected, and its failure is silent because both initializers swallow the attester's output.

How to reproduce

bash
export PWF_PLAN_ROOT=/path/to/other-project      # holds its own .planning
cd /path/to/this-project
sh scripts/init-session.sh "Fresh Plan"
sh scripts/attest-plan.sh --show                   # or inspect .planning/<id>/.attestation

Observed: the attester looks for <date>-fresh-plan under /path/to/other-project/.planning, prints [plan-attest] PWF_PLAN_ROOT=... did not resolve to a project root holding a plan (suppressed by the initializer), and the new plan carries no attestation. In root mode (no name argument) the inherited pin makes the attester attest the other project's root task_plan.md instead of the one just created.

Suggested fix

Bind PWF_PLAN_ROOT to the current project root for the duration of the attest call, in the same place PLAN_ID is bound:

  • init-session.sh: PWF_PLAN_ROOT="$PWD" PLAN_ID="${PLAN_ID:-}" sh "${_attest}" (the initializer already runs from the project root).
  • init-session.ps1: save $env:PWF_PLAN_ROOT, set it to (Get-Location).Path (or the recovered project root) inside the existing try, restore it in the finally next to the PLAN_ID restore.

Keep the twins identical in behaviour. A regression test can export a pin to a second temporary project, run each initializer in the first, and assert the attestation file exists for the new plan.

Origin

Found by the v3.19.0 release review (PRs #247, #248, #249). Tracked as item 8 of #250 before that issue was split into one issue per item.

Source: OthmanAdi/planning-with-files