@ikon85/agent-workflow-kit 0.40.0 → 0.41.0

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/README.md CHANGED
@@ -469,6 +469,14 @@ the old way. Decision record:
469
469
 
470
470
  ## Release notes
471
471
 
472
+ ### 0.41.0
473
+
474
+ - added: `docs/adr/0009-teardown-authority-is-stateless-repository-classification.md`
475
+ - changed: `agent-workflow-kit.package.json`
476
+ - changed: `docs/adr/0007-session-teardown-requires-provenance-bound-ownership.md`
477
+ - changed: `scripts/pr-body-check.py`
478
+ - changed: `scripts/test_pr_body_check.py`
479
+
472
480
  ### 0.40.0 — planning ignore rules are offered, never installed
473
481
 
474
482
  Nothing in this release requires a consumer action. `kit-update` reconciles it.
@@ -1,5 +1,5 @@
1
1
  {
2
- "kitVersion": "0.40.0",
2
+ "kitVersion": "0.41.0",
3
3
  "files": [
4
4
  {
5
5
  "path": ".agents/skills/ask-matt/SKILL.md",
@@ -2627,7 +2627,7 @@
2627
2627
  "path": "scripts/pr-body-check.py",
2628
2628
  "kind": "script",
2629
2629
  "installRole": "consumer",
2630
- "sha256": "864dad50be7904cf0c1d70956352c70d2195a350a5a6875de6b866c494f16612",
2630
+ "sha256": "7fa67a672d6f6986b0fba99e78157d51225ab91f61b691a4cc184d316b521882",
2631
2631
  "mode": 493,
2632
2632
  "origin": "kit"
2633
2633
  },
@@ -1,6 +1,6 @@
1
1
  # Session teardown requires provenance-bound ownership
2
2
 
3
- Status: accepted (2026-07-26, Wave #271)
3
+ Status: superseded by [ADR-0009](./0009-teardown-authority-is-stateless-repository-classification.md) (2026-07-27, #320)
4
4
 
5
5
  Long agent sessions create branches, linked worktrees, setup outputs, and
6
6
  landing-time build artifacts. The desired end state is that every
@@ -0,0 +1,101 @@
1
+ # Teardown authority is stateless repository classification
2
+
3
+ Status: accepted (2026-07-27, #320) — supersedes
4
+ [ADR-0007](./0007-session-teardown-requires-provenance-bound-ownership.md)
5
+
6
+ ADR-0007 derived teardown authority from persisted lifecycle evidence:
7
+ ownership-proof refs acquired in atomic git transactions, frozen
8
+ landing-attempt journals, baseline digests, no-follow identity binding, and a
9
+ post-merge reload of the canonical cleanup policy. Every piece was locally
10
+ justified, and the aggregate failed in practice: fifteen teardown/cleanup
11
+ issues in two weeks (#245–#319), ~5,600 lines of lifecycle code, two recovery
12
+ flags for the machinery's own bookkeeping, a legacy receipt contract, and
13
+ refusals that did not name their cause (#319: 68,856 paths, 7.4 MB, zero
14
+ actionable lines). The protection was aimed at narrow races between assessment
15
+ and deletion; the cost was that ordinary sessions could no longer finish.
16
+
17
+ We decided that teardown authority comes from the repository's **current
18
+ state**, read at the moment of action, and from nothing else:
19
+
20
+ 1. **Git's own classification is the file taxonomy.** A tracked modification
21
+ blocks teardown. An untracked, non-ignored file blocks with a bounded
22
+ report (count plus top directories — never an unbounded path dump). An
23
+ ignored file is Scratch: the repository declared it not-work, and it is
24
+ deletable. "Ignored" means git's standard exclude sources
25
+ (`--exclude-standard`: repository `.gitignore` files, `.git/info/exclude`,
26
+ the global excludes file) — whatever the repository's own tooling treats as
27
+ ignored is deletion authority here too.
28
+ 2. **One hardcoded exception: `.env*` (basename glob).** Ignored yet
29
+ potentially irreplaceable. Before removal each `.env*` regular file is
30
+ compared byte-wise with its counterpart at the same relative path in the
31
+ main checkout, both opened no-follow: identical → derived copy, deletable;
32
+ divergent, absent in the main checkout, or either side not a regular file →
33
+ block with the exact files named. The check is a present-state comparison,
34
+ not a receipt.
35
+ 3. **The platform PR record authorizes branch deletion.** Force-deletion
36
+ requires exactly one PR matching the full tuple — this repository as base
37
+ repo, head repository equal to the base repo (no fork heads), head ref
38
+ equal to the branch name, base ref equal to the configured protected
39
+ branch, state merged — whose head SHA equals the branch tip OID; the OID
40
+ is re-read immediately before deletion, and zero matches, multiple
41
+ matches, an open PR on the same head, or any drift retains the branch.
42
+ Ancestry-merged branches (against a freshly fetched configured protected
43
+ branch — stale ancestry stops rather than guesses) delete normally. A
44
+ branch with neither stays and is reported. Without platform access this
45
+ degrades to ancestry-only, reported honestly.
46
+ 4. **Idempotency by re-check, not journal.** An interrupted landing is resumed
47
+ by re-running it; every step verifies present state (PR exists? merged?
48
+ worktree present?) and skips or proceeds. There is no persisted attempt
49
+ state to validate, archive, or recover.
50
+ 5. **A direct `/wrapup` invocation is the teardown authorization.** It lands
51
+ and tears down the worktree it runs in — including worktrees created by
52
+ external tools under foreign names and paths. The kit never conditions
53
+ teardown on its own naming or location conventions; the four classification
54
+ rules above are the only protection.
55
+ 6. **Deletion policy has exactly one configuration surface: the ignore
56
+ mechanism.** The consumer profile keeps structural facts only (worktree
57
+ root, templates, protected branches, sweep opt-in). `scratchPatterns` and
58
+ `landingGeneratedArtifactPatterns` are removed without migration —
59
+ including the shipped consumer migration that seeded them; making a file
60
+ deletable means ignoring it (ADR-0008's offered seeding remains the
61
+ supported way; its consequence about deriving `scratchPatterns` from the
62
+ seeded rules is obsolete with this decision).
63
+
64
+ ## Considered options
65
+
66
+ - **Keep ADR-0007's provenance machinery:** rejected on empirical grounds. The
67
+ races it closes (a foreign file occupying an assessed path between
68
+ assessment and deletion, a same-name branch created concurrently) are rare
69
+ and low-harm next to the observed failure mode: routine teardown becoming
70
+ impossible and each repair adding machinery. The branch race is additionally
71
+ closed cheaper by the tip-SHA/PR comparison.
72
+ - **Shipping default scratch patterns:** rejected. A default allowlist of the
73
+ deletable restarts the pattern catalog and its seeding, sync, and dialect
74
+ problems; `.gitignore` already encodes the same fact with universal
75
+ tooling.
76
+ - **Migrating existing profiles and receipts:** rejected. The green-slate cut
77
+ is deliberate (#320): old keys are ignored, journaled attempts are inert
78
+ files, and no code path reads either. Maintaining both models would preserve
79
+ the complexity this decision removes.
80
+ - **Location heuristic for externally created worktrees (land, don't tear
81
+ down):** rejected by the user. `/wrapup` means tear down; splitting the
82
+ outcome by worktree origin reintroduces an ownership notion.
83
+
84
+ ## Consequences
85
+
86
+ - A worktree whose only untracked content is ignored dependency or build
87
+ output is removable with zero configuration. #319's failure class cannot
88
+ occur.
89
+ - Refusals are bounded and name their cause; the fix is always visible
90
+ (commit the tracked change, handle the named `.env*`, ignore or remove the
91
+ named untracked files).
92
+ - The accepted residual risk is explicit: between assessment and deletion a
93
+ file could in principle be replaced; a valuable file a consumer keeps
94
+ gitignored outside `.env*` is deletable at teardown. We trade these narrow
95
+ windows for a lifecycle that ordinary sessions can actually complete.
96
+ - Planning sessions stop being a special case: durable content lands through
97
+ wrapup's Content route as ordinary work, scratch dies with the worktree,
98
+ and worktree creation binds to implementation, not planning.
99
+ - The lifecycle implementation shrinks from a transaction protocol to a
100
+ classification function plus plumbing; its tests shift from race
101
+ choreography to classification truth tables.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikon85/agent-workflow-kit",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "Portable AI-agent workflow skills (plan → execute → land → learn) for Claude Code & Codex — grilling, TDD, diagnosis, two-axis code review, cross-model Codex review, design & domain-modeling, plus a skill router (ask-matt). npx init/update/diff/uninstall.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -208,13 +208,26 @@ def fetch_pr_body(branch: str):
208
208
  return out if rc == 0 else None
209
209
 
210
210
 
211
+ def _anchor_labels() -> set:
212
+ """Labels that mark an issue as a never-auto-close anchor: the wave
213
+ cluster label plus the board profile's Program-PRD label (a Program-PRD
214
+ is closed last, manually — `closes` must never target it)."""
215
+ labels = {"type:cluster"}
216
+ try:
217
+ import board_config
218
+ labels.add(board_config.program_type_label(board_config.load_board_config()))
219
+ except Exception:
220
+ labels.add("type:program") # profile unavailable → literal default
221
+ return labels
222
+
223
+
211
224
  def fetch_is_anchor(number: int) -> bool:
212
- """True wenn das Issue selbst ein Wellen-Anker ist (Label type:cluster)."""
225
+ """True wenn das Issue selbst ein Anker ist (type:cluster oder Program-PRD)."""
213
226
  rc, out = _run(["gh", "issue", "view", str(number),
214
227
  "--json", "labels", "-q", ".labels[].name"])
215
228
  if rc != 0:
216
229
  return False # fail-open in den Leaf-Pfad (bisheriges Verhalten)
217
- return "type:cluster" in out.splitlines()
230
+ return bool(_anchor_labels() & set(out.splitlines()))
218
231
 
219
232
 
220
233
  def resolve_has_e2e_na(args, branch: str) -> bool:
@@ -79,6 +79,16 @@ class ExistingBodyRules(unittest.TestCase):
79
79
  def test_retro_line_still_required(self):
80
80
  self.assertTrue(any("Retro" in item for item in pbc.check_pr_body("closes #149", 149, None)))
81
81
 
82
+ def test_program_prd_label_counts_as_anchor(self):
83
+ with mock.patch.object(pbc, "_run",
84
+ return_value=(0, "type:program\npriority:medium")):
85
+ self.assertTrue(pbc.fetch_is_anchor(320))
86
+
87
+ def test_cluster_label_still_counts_as_anchor(self):
88
+ with mock.patch.object(pbc, "_run",
89
+ return_value=(0, "type:cluster")):
90
+ self.assertTrue(pbc.fetch_is_anchor(41))
91
+
82
92
  def test_wave_pr_still_requires_part_of_without_closing_anchor(self):
83
93
  body = f"Part of #130\ncloses #149\n{RETRO}"
84
94
  self.assertEqual(pbc.check_pr_body(body, 130, None, is_anchor=True), [])