From 8a0fd169a9a555dff06db7cb4db5778f14293bd7 Mon Sep 17 00:00:00 2001 From: "napkinstack-agent[bot]" <330339777+napkinstack-agent[bot]@users.noreply.github.com> Date: Sun, 29 Nov 2026 23:20:10 +0100 Subject: [PATCH 1/2] =?UTF-8?q?D313=20=E2=80=94=20the=20refusal=20off=20ma?= =?UTF-8?q?in=20says=20the=20command=20makes=20its=20own=20branch,=20and?= =?UTF-8?q?=20the=20way=20from=20a=20worktree?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Downstream, the coordinator made a branch and a worktree for the update first; the refusal said `git switch main`, which a worktree beside main's cannot do. nstack update, update --forge and config now share one Action: switch to the default branch, or detach at its tip in a worktree (#261), and the command makes its own branch: none is made before. Agent-Session: napkinstack-os-1e Co-Authored-By: Claude Opus 5.5 --- docs/governance/workstreams.md | 1 + platform/tests/test_config.py | 7 +++++-- platform/tests/test_update_tree.py | 5 ++++- src/napkinstack/project.py | 13 ++++++++++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/docs/governance/workstreams.md b/docs/governance/workstreams.md index 688da3a..bb61cf9 100644 --- a/docs/governance/workstreams.md +++ b/docs/governance/workstreams.md @@ -328,6 +328,7 @@ state to its index: [`docs/adr/`](../adr/README.md), [`docs/pdr/`](../pdr/README | D309 | **A table after the test sheet in a comment was read as its rows** (no issue; reported by the consumer project's coordinator, 2026-11-29). D305 moved the signed sheet into a comment, where no template heading ends the section: a verifier's "Mutants" table after the sheet was read as scenarios, and T2 failed ("scenario M1 …", 4 of 5) | **Done**: `read_sheet` leaves out a table after the sheet that GitHub renders apart — its own header, other than the sheet's, over a delimiter line —, in a description as in a comment: it is the verifier's own. Rows after a blank line, which GitHub shows as text, are still read as the sheet's: a failed one fails rather than vanishes (a fresh verifier's finding). A comment written with CRLF line endings, as a browser sends it, is read too | | D310 | **An agent's run stopped at start on Claude Code's trust screen for its skills folder** (#578). Downstream, 2026-11-29, Claude Code 2.1.332: the folder D261 hands Claude Code with `--add-dir` asked "Adding a new directory … Is this a directory you created or one you trust?" at every start, `No, exit` the default, so no unattended agent began. A deliberate safeguard of Claude Code, never stepped around | **Done**: `nstack agent run -- claude` lays the default branch's skills as a plugin of the session (`.claude-plugin/plugin.json` named `project`, `skills//`) and passes `--plugin-dir`, the path Claude Code documents for a program handing a session skills. Measured on 2.1.332 through a pseudo-terminal: `--add-dir` asks, `--plugin-dir` does not and loads the skills; `permissions.additionalDirectories` in `--settings` does not ask but loads no skill. In the session the skills are named `project:`, said by the run and in `INSTALL.md`. Not taken: a persistent trust entry (the person's setting, a manual step); any flag that skips the trust check. Not caught by the tests: Claude Code's own screen — CI runs a stand-in for `claude` | | D311 | **An agent's skills lost their skip-worktree bit, and its commit stopped in the sandbox's mask** (#584). Downstream, 2026-11-29, nstack 0.35.3: the five agents' clones kept D261's sparse patterns, but their committed skills showed as deleted; pre-commit's stash wrote them back into the mask, and `git checkout -- .` failed with "Device or resource busy". The loss itself was not reproduced beyond one clone's commit of the sandbox's masks: git clears the bit wherever the file is present | **Done**: at each `nstack agent run`, a skill outside the patterns that is absent from the working tree gets its bit back, in the index alone; one the working tree holds stays and is said kept, as before. Not taken: `git sparse-checkout reapply`, which leaves them while the sandbox's placeholder stands; `--assume-unchanged`, a hint git may drop. Not caught: a bit lost during a session is set again only at the agent's next run | +| D313 | **The update's refusal off main did not say it makes its own branch, nor the way from a worktree** (#589). Downstream, 2026-11-29, 0.35.4: the coordinator made a branch and a worktree for the update first, as for any change; the refusal said `git switch main`, which a worktree beside main's cannot do | **Done**: `nstack update`, `nstack update --forge` and `nstack config` refuse with one Action: `git switch `, or in a worktree beside the one that holds it `git switch --detach ` (#261), and the command makes its own branch: none is made before | | v0.6.0 | **What is announced refuses, and the documents say what is true**: D51 to D54, and the documentary lot of the internal audit | **Done (2026-09-20)**: five workstreams merged (#83, #84, #85, #86, #87), **v0.6.0 published**, tag on `8ae544c`, verified on published artefacts — including an update of `tool-library` from v0.5.0, 9 files and no conflict, still compliant. Found doing it: D55. Next: the pilot, and M11 beside it | | Pilot | **`NapkinStack/flet`, the first real project**, run by a session that knew nothing of this repository, with the maintainer as decider and this repository's agent as observer — public on the Free plan, where the whole checklist is available, rather than private on Team where G5 is paid and G6 does not exist | **Set aside by the maintainer, 2026-10-15**, at its cycle boundary; the real product followed since is `summit`. **Ran from 2026-09-20**: discovery decided *go* after three rounds and two independent challenges, charter accepted; cycle 01 closed `stopped/reframed`, **cycle 02 closed** with two deliverables accepted and one deferred (its #27), **cycle 03 framed and approved** (#28, #30), which starts its first `critical` module; the framework taken to v0.6.1 by itself at the boundary (#29), v0.6.2 proposed (#31). It has produced D56 to D63, D68, D70 to D77, replicated D26 and D55, and measured D49 — the first figures on what an independent verifier finds (PDR-0003) | | M11 | **Ceremony follows consequence** (PDR-0011): the framework charges what a failure costs, per module and per project, and states each price before it is paid; with PDR-0004's routing, and PDR-0007, PDR-0008 and PDR-0010 — through to v0.7.0 | **Published as v0.7.0 (2026-10-12).** Planned 2026-09-23 (#98). Merged: **M11f** (#101), **M11a** (#102), **M11b** (#103), **M11d** (#104), **M11e** (#105), **M11c** (#106), **M11h** (#107), **M11g** (#108) closed by its probe — not clean, returned to M13; **M11m** (D68, D74, D75); **M11l** (PDR-0010, D59, D60); **M11n** (D79); **M11o** (PDR-0010 extended: every document has its moment); **M11p** (PDR-0002's three levels given a place: `docs/project/rules/`); **M11j** (PDR-0007: the unframed stage); **M11q** (no folder created empty; PDR-0012 proposed: a project's tree is the project's). **M11k** (PDR-0008's print mode: `nstack settings`; D77, D78). **M11s** (PDR-0012 accepted; the framework's files under `.nstack/`; an update carries what a project adapted); **M11u** (an update rewrites the old addresses a project wrote in its own files, D85). **M11t** (`nstack new-contract`: the contracts module is created by the first contract; PDR-0012 built in full); **M11v** (what the third project found: D81, D82, D83, D86, D87). **M11i**: v0.7.0 published 2026-10-12 (#125, D88). To do: **M11r** PDR-0008's apply mode and D57, after a probe on the real forge; the two earlier projects take v0.7.0 themselves, observed | diff --git a/platform/tests/test_config.py b/platform/tests/test_config.py index c1de10e..7b253fa 100644 --- a/platform/tests/test_config.py +++ b/platform/tests/test_config.py @@ -214,6 +214,7 @@ def test_a_version_that_does_not_ask_the_setting_is_refused_leaving_the_tree_as_ @pytest.mark.parametrize("held", ["branch", "dirty", "elsewhere", "forge by hand"]) def test_a_change_is_refused_where_it_would_carry_or_lose_something(tmp_path, made, capsys, held): root = _project(tmp_path, made) + said_too = "" if held == "branch": _git(root, "branch", "nstack/config-hold-days") said = "Branch nstack/config-hold-days already exists" @@ -222,7 +223,8 @@ def test_a_change_is_refused_where_it_would_carry_or_lose_something(tmp_path, ma said = "Working tree modified" elif held == "elsewhere": _git(root, "switch", "-q", "-c", "feature") - said = "feature is checked out, not main" + said = "feature is checked out, not main" # D313: and the command makes its own branch + said_too = "nstack config makes its own branch: none is made before" else: answers = root / ".copier-answers.yml" answers.write_text(answers.read_text(encoding="utf-8").replace("forge: github", "forge: gitlab"), encoding="utf-8") @@ -230,7 +232,8 @@ def test_a_change_is_refused_where_it_would_carry_or_lose_something(tmp_path, ma said = "the answer was changed by hand" capsys.readouterr() assert config.run(root, "hold_days", "10") == 1 - assert said in capsys.readouterr().out + out = capsys.readouterr().out + assert said in out and said_too in out, out assert "nstack/config-hold-days" not in _branches(root) or held == "branch" diff --git a/platform/tests/test_update_tree.py b/platform/tests/test_update_tree.py index 43eb3fa..4ca2404 100644 --- a/platform/tests/test_update_tree.py +++ b/platform/tests/test_update_tree.py @@ -107,7 +107,10 @@ def test_a_detached_head_elsewhere_is_still_refused(old, tmp_path, capsys): git(elsewhere, "commit", "-q", "--allow-empty", "-m", "a commit of its own") capsys.readouterr() assert project.update(elsewhere, "HEAD") == 1 - assert "a detached HEAD is checked out, not main" in capsys.readouterr().out + said = capsys.readouterr().out + assert "a detached HEAD is checked out, not main" in said + # D313: the way back from a worktree, and that the update makes its own branch + assert "git switch --detach main" in said and "nstack update makes its own branch: none is made before" in said def test_copier_s_old_git_warning_is_not_shown(old, capfd): diff --git a/src/napkinstack/project.py b/src/napkinstack/project.py index a0dc38f..9491f40 100644 --- a/src/napkinstack/project.py +++ b/src/napkinstack/project.py @@ -386,6 +386,13 @@ def _elsewhere(root: Path, default: str | None) -> str | None: return current or "a detached HEAD" +def _start_from(default: str, what: str) -> str: + """The way back to where the command starts (D313, #589): it makes its own branch, which a person + who made one first, as for any change, did not expect; a worktree beside main's cannot switch to it.""" + return (f"Action: git switch {default}, then run again — or, in a worktree beside the one that holds {default}, " + f"git switch --detach {default}. {what} makes its own branch: none is made before.") + + def _held(root: Path, command: str, default: str | None) -> str | None: """Why the working tree cannot take an update, naming what holds it; None when it is clean. Copier reads an untracked file as a change too, and `git stash` leaves one in place (#261).""" @@ -613,7 +620,7 @@ def update(root: Path, ref: str, session: str | None = None) -> int: # branch's commits, and the pull request that should hold the framework alone does not. if (where := _elsewhere(root, default)) is not None: print(f"FAIL [update] {where} is checked out, not {default}: the update branch would " - f"carry its commits.\n Action: git switch {default}, then run again.") + f"carry its commits.\n {_start_from(default, 'nstack update')}") return 1 base = _git(root, "rev-parse", "HEAD").stdout.strip() try: @@ -886,7 +893,7 @@ def change_forge(root: Path, new: str, github_repo: str | None = None, repositor return 1 if (where := _elsewhere(root, default)) is not None: print(f"FAIL [update] {where} is checked out, not {default}: the " - f"change's branch would carry its commits.\n Action: git switch {default}, then run again.") + f"change's branch would carry its commits.\n {_start_from(default, 'nstack update --forge')}") return 1 version = str(answers.get("_commit")) base = _git(root, "rev-parse", "HEAD").stdout.strip() @@ -984,7 +991,7 @@ def change_answer(root: Path, name: str, wanted: object, was: str, session: str return 1 if (where := _elsewhere(root, default)) is not None: print(f"FAIL [config] {where} is checked out, not {default}: the change's branch would carry its " - f"commits.\n Action: git switch {default}, then run again.") + f"commits.\n {_start_from(default, 'nstack config')}") return 1 answers = _answers(root) version = str(answers.get("_commit")) From 2636bac8a915057c3bce7a3c7f085fa2b09c2ef8 Mon Sep 17 00:00:00 2001 From: "napkinstack-agent[bot]" <330339777+napkinstack-agent[bot]@users.noreply.github.com> Date: Sun, 29 Nov 2026 23:27:38 +0100 Subject: [PATCH 2/2] =?UTF-8?q?D313=20=E2=80=94=20the=20forge=20change's?= =?UTF-8?q?=20refusal=20off=20main=20is=20tested;=20the=20Action=20reads?= =?UTF-8?q?=20plainly=20(#589)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The verifier found change_forge's guard untested, before D313 and since: a test now refuses it off main, with the way back and no branch made. "make none before" replaces "none is made before"; INSTALL.md says the update makes its own branch. Agent-Session: napkinstack-os-1e Co-Authored-By: Claude Opus 5.5 --- docs/governance/workstreams.md | 2 +- platform/tests/test_config.py | 2 +- platform/tests/test_forge.py | 13 +++++++++++++ platform/tests/test_update_tree.py | 2 +- skeleton/.nstack/handbook/INSTALL.md.jinja | 2 +- src/napkinstack/project.py | 2 +- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/docs/governance/workstreams.md b/docs/governance/workstreams.md index bb61cf9..3e84964 100644 --- a/docs/governance/workstreams.md +++ b/docs/governance/workstreams.md @@ -328,7 +328,7 @@ state to its index: [`docs/adr/`](../adr/README.md), [`docs/pdr/`](../pdr/README | D309 | **A table after the test sheet in a comment was read as its rows** (no issue; reported by the consumer project's coordinator, 2026-11-29). D305 moved the signed sheet into a comment, where no template heading ends the section: a verifier's "Mutants" table after the sheet was read as scenarios, and T2 failed ("scenario M1 …", 4 of 5) | **Done**: `read_sheet` leaves out a table after the sheet that GitHub renders apart — its own header, other than the sheet's, over a delimiter line —, in a description as in a comment: it is the verifier's own. Rows after a blank line, which GitHub shows as text, are still read as the sheet's: a failed one fails rather than vanishes (a fresh verifier's finding). A comment written with CRLF line endings, as a browser sends it, is read too | | D310 | **An agent's run stopped at start on Claude Code's trust screen for its skills folder** (#578). Downstream, 2026-11-29, Claude Code 2.1.332: the folder D261 hands Claude Code with `--add-dir` asked "Adding a new directory … Is this a directory you created or one you trust?" at every start, `No, exit` the default, so no unattended agent began. A deliberate safeguard of Claude Code, never stepped around | **Done**: `nstack agent run -- claude` lays the default branch's skills as a plugin of the session (`.claude-plugin/plugin.json` named `project`, `skills//`) and passes `--plugin-dir`, the path Claude Code documents for a program handing a session skills. Measured on 2.1.332 through a pseudo-terminal: `--add-dir` asks, `--plugin-dir` does not and loads the skills; `permissions.additionalDirectories` in `--settings` does not ask but loads no skill. In the session the skills are named `project:`, said by the run and in `INSTALL.md`. Not taken: a persistent trust entry (the person's setting, a manual step); any flag that skips the trust check. Not caught by the tests: Claude Code's own screen — CI runs a stand-in for `claude` | | D311 | **An agent's skills lost their skip-worktree bit, and its commit stopped in the sandbox's mask** (#584). Downstream, 2026-11-29, nstack 0.35.3: the five agents' clones kept D261's sparse patterns, but their committed skills showed as deleted; pre-commit's stash wrote them back into the mask, and `git checkout -- .` failed with "Device or resource busy". The loss itself was not reproduced beyond one clone's commit of the sandbox's masks: git clears the bit wherever the file is present | **Done**: at each `nstack agent run`, a skill outside the patterns that is absent from the working tree gets its bit back, in the index alone; one the working tree holds stays and is said kept, as before. Not taken: `git sparse-checkout reapply`, which leaves them while the sandbox's placeholder stands; `--assume-unchanged`, a hint git may drop. Not caught: a bit lost during a session is set again only at the agent's next run | -| D313 | **The update's refusal off main did not say it makes its own branch, nor the way from a worktree** (#589). Downstream, 2026-11-29, 0.35.4: the coordinator made a branch and a worktree for the update first, as for any change; the refusal said `git switch main`, which a worktree beside main's cannot do | **Done**: `nstack update`, `nstack update --forge` and `nstack config` refuse with one Action: `git switch `, or in a worktree beside the one that holds it `git switch --detach ` (#261), and the command makes its own branch: none is made before | +| D313 | **The update's refusal off main did not say it makes its own branch, nor the way from a worktree** (#589). Downstream, 2026-11-29, 0.35.4: the coordinator made a branch and a worktree for the update first, as for any change; the refusal said `git switch main`, which a worktree beside main's cannot do | **Done**: `nstack update`, `nstack update --forge` and `nstack config` refuse with one Action: `git switch `, or in a worktree beside the one that holds it `git switch --detach ` (#261), and the command makes its own branch: make none before | | v0.6.0 | **What is announced refuses, and the documents say what is true**: D51 to D54, and the documentary lot of the internal audit | **Done (2026-09-20)**: five workstreams merged (#83, #84, #85, #86, #87), **v0.6.0 published**, tag on `8ae544c`, verified on published artefacts — including an update of `tool-library` from v0.5.0, 9 files and no conflict, still compliant. Found doing it: D55. Next: the pilot, and M11 beside it | | Pilot | **`NapkinStack/flet`, the first real project**, run by a session that knew nothing of this repository, with the maintainer as decider and this repository's agent as observer — public on the Free plan, where the whole checklist is available, rather than private on Team where G5 is paid and G6 does not exist | **Set aside by the maintainer, 2026-10-15**, at its cycle boundary; the real product followed since is `summit`. **Ran from 2026-09-20**: discovery decided *go* after three rounds and two independent challenges, charter accepted; cycle 01 closed `stopped/reframed`, **cycle 02 closed** with two deliverables accepted and one deferred (its #27), **cycle 03 framed and approved** (#28, #30), which starts its first `critical` module; the framework taken to v0.6.1 by itself at the boundary (#29), v0.6.2 proposed (#31). It has produced D56 to D63, D68, D70 to D77, replicated D26 and D55, and measured D49 — the first figures on what an independent verifier finds (PDR-0003) | | M11 | **Ceremony follows consequence** (PDR-0011): the framework charges what a failure costs, per module and per project, and states each price before it is paid; with PDR-0004's routing, and PDR-0007, PDR-0008 and PDR-0010 — through to v0.7.0 | **Published as v0.7.0 (2026-10-12).** Planned 2026-09-23 (#98). Merged: **M11f** (#101), **M11a** (#102), **M11b** (#103), **M11d** (#104), **M11e** (#105), **M11c** (#106), **M11h** (#107), **M11g** (#108) closed by its probe — not clean, returned to M13; **M11m** (D68, D74, D75); **M11l** (PDR-0010, D59, D60); **M11n** (D79); **M11o** (PDR-0010 extended: every document has its moment); **M11p** (PDR-0002's three levels given a place: `docs/project/rules/`); **M11j** (PDR-0007: the unframed stage); **M11q** (no folder created empty; PDR-0012 proposed: a project's tree is the project's). **M11k** (PDR-0008's print mode: `nstack settings`; D77, D78). **M11s** (PDR-0012 accepted; the framework's files under `.nstack/`; an update carries what a project adapted); **M11u** (an update rewrites the old addresses a project wrote in its own files, D85). **M11t** (`nstack new-contract`: the contracts module is created by the first contract; PDR-0012 built in full); **M11v** (what the third project found: D81, D82, D83, D86, D87). **M11i**: v0.7.0 published 2026-10-12 (#125, D88). To do: **M11r** PDR-0008's apply mode and D57, after a probe on the real forge; the two earlier projects take v0.7.0 themselves, observed | diff --git a/platform/tests/test_config.py b/platform/tests/test_config.py index 7b253fa..dd71add 100644 --- a/platform/tests/test_config.py +++ b/platform/tests/test_config.py @@ -224,7 +224,7 @@ def test_a_change_is_refused_where_it_would_carry_or_lose_something(tmp_path, ma elif held == "elsewhere": _git(root, "switch", "-q", "-c", "feature") said = "feature is checked out, not main" # D313: and the command makes its own branch - said_too = "nstack config makes its own branch: none is made before" + said_too = "nstack config makes its own branch: make none before" else: answers = root / ".copier-answers.yml" answers.write_text(answers.read_text(encoding="utf-8").replace("forge: github", "forge: gitlab"), encoding="utf-8") diff --git a/platform/tests/test_forge.py b/platform/tests/test_forge.py index 3adca61..f4ac5e2 100644 --- a/platform/tests/test_forge.py +++ b/platform/tests/test_forge.py @@ -565,6 +565,19 @@ def test_a_forge_change_refuses_what_the_forge_does_not_take(tmp_path, capsys, f assert _git(root, "branch", "--show-current") == "main" +def test_a_forge_change_off_main_is_refused_with_the_way_back(tmp_path, capsys): + """D74: the change's branch would carry the feature's commits; D313 (#589): the Action says the + way back from a worktree, and that the command makes its own branch.""" + root = create(tmp_path, "github") + _git(root, "switch", "-q", "-c", "feature") + capsys.readouterr() + assert project.change_forge(root, "gitlab", repository="acme/demo") == 1 + said = capsys.readouterr().out + assert "feature is checked out, not main" in said and "git switch --detach main" in said, said + assert "nstack update --forge makes its own branch: make none before" in said, said + assert not [line for line in _git(root, "branch", "--list", "nstack/forge-*").splitlines() if line.strip()] + + def test_the_same_forge_is_no_change(tmp_path, capsys): root = create(tmp_path, "gitlab") assert project.change_forge(root, "gitlab") == 0 diff --git a/platform/tests/test_update_tree.py b/platform/tests/test_update_tree.py index 4ca2404..0f41e72 100644 --- a/platform/tests/test_update_tree.py +++ b/platform/tests/test_update_tree.py @@ -110,7 +110,7 @@ def test_a_detached_head_elsewhere_is_still_refused(old, tmp_path, capsys): said = capsys.readouterr().out assert "a detached HEAD is checked out, not main" in said # D313: the way back from a worktree, and that the update makes its own branch - assert "git switch --detach main" in said and "nstack update makes its own branch: none is made before" in said + assert "git switch --detach main" in said and "nstack update makes its own branch: make none before" in said def test_copier_s_old_git_warning_is_not_shown(old, capfd): diff --git a/skeleton/.nstack/handbook/INSTALL.md.jinja b/skeleton/.nstack/handbook/INSTALL.md.jinja index 71b0b62..05bb54d 100644 --- a/skeleton/.nstack/handbook/INSTALL.md.jinja +++ b/skeleton/.nstack/handbook/INSTALL.md.jinja @@ -94,7 +94,7 @@ repository, and every run then says an unpublished framework judges it. ```bash uv tool install "napkinstack==X.Y.Z" --refresh-package napkinstack --with-executables-from pre-commit # the version you want; the index read afresh -git switch main # an update starts from the default branch +git switch main # an update starts from the default branch, and makes its own nstack update # branch nstack/update-vX.Y.Z, merged and committed {% if forge == "none" %}nstack attest # then merge it as the project merges its changes{% else %}git push -u origin nstack/update-vX.Y.Z # then the PR, validated by {{ ci }}{% endif %} ``` diff --git a/src/napkinstack/project.py b/src/napkinstack/project.py index 9491f40..9a7f733 100644 --- a/src/napkinstack/project.py +++ b/src/napkinstack/project.py @@ -390,7 +390,7 @@ def _start_from(default: str, what: str) -> str: """The way back to where the command starts (D313, #589): it makes its own branch, which a person who made one first, as for any change, did not expect; a worktree beside main's cannot switch to it.""" return (f"Action: git switch {default}, then run again — or, in a worktree beside the one that holds {default}, " - f"git switch --detach {default}. {what} makes its own branch: none is made before.") + f"git switch --detach {default}. {what} makes its own branch: make none before.") def _held(root: Path, command: str, default: str | None) -> str | None: