@deftai/directive-content 0.98.1 → 0.100.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.
Files changed (55) hide show
  1. package/Taskfile.yml +4 -0
  2. package/coding/coding.md +2 -3
  3. package/commands.md +29 -4
  4. package/context/tool-design.md +116 -0
  5. package/contracts/host-lifecycle-duties.md +9 -0
  6. package/docs/agent-docs.md +1 -0
  7. package/docs/consumer-check-contract.md +26 -3
  8. package/docs/decision-log.md +114 -0
  9. package/docs/delivery-attempt.md +17 -1
  10. package/docs/gate-integrity.md +112 -0
  11. package/docs/host-surface-assumptions.md +149 -0
  12. package/docs/inter-run-learning.md +4 -0
  13. package/docs/scope-provenance.md +1 -1
  14. package/docs/skill-pin-policy.md +9 -0
  15. package/main.md +24 -0
  16. package/meta/philosophy.md +8 -0
  17. package/meta/security.md +16 -2
  18. package/package.json +1 -1
  19. package/packs/patterns/patterns-pack-0.1.json +53 -15
  20. package/packs/rules/rules-pack-0.1.json +730 -914
  21. package/packs/skills/skills-pack-0.1.json +19 -9
  22. package/packs/strategies/strategies-pack-0.1.json +1 -1
  23. package/packs/swarm-spec/swarm-spec-pack-0.1.json +1 -1
  24. package/patterns/goal-gate-determinism.md +146 -0
  25. package/patterns/llm-app.md +9 -0
  26. package/skills/deft-directive-build/SKILL.md +62 -0
  27. package/skills/deft-directive-portfolio-priority/SKILL.md +3 -3
  28. package/skills/deft-directive-pre-pr/SKILL.md +32 -0
  29. package/skills/deft-directive-refinement/SKILL.md +8 -0
  30. package/skills/deft-directive-review-cycle/SKILL.md +47 -2
  31. package/skills/deft-directive-swarm/SKILL.md +32 -0
  32. package/skills/deft-directive-swarm/references/core-ops.md +8 -1
  33. package/skills/deft-directive-swarm/references/core-phase-0.md +2 -0
  34. package/skills/deft-directive-swarm/references/core-phase-3.md +18 -0
  35. package/skills/deft-directive-swarm/references/core-phase-4.md +63 -3
  36. package/skills/deft-directive-swarm/references/core-phase-5-6.md +6 -2
  37. package/skills/deft-directive-swarm/references/host-claude-code.md +7 -0
  38. package/skills/deft-directive-swarm/references/host-cursor.md +7 -0
  39. package/skills/deft-directive-swarm/references/host-generic.md +6 -0
  40. package/skills/deft-directive-swarm/references/host-grok-build.md +7 -0
  41. package/skills/deft-directive-swarm/references/host-openclaw.md +7 -0
  42. package/skills/deft-directive-swarm/references/host-warp.md +6 -0
  43. package/skills/deft-directive-write-skill/SKILL.md +2 -0
  44. package/strategies/rapid.md +11 -0
  45. package/swarm/swarm.md +54 -0
  46. package/tasks/decision.yml +30 -0
  47. package/tasks/swarm.yml +16 -0
  48. package/tasks/verify.yml +20 -0
  49. package/templates/agent-prompt-preamble.md +9 -5
  50. package/templates/agents-entry.md +18 -0
  51. package/templates/swarm-greptile-poller-prompt.md +48 -4
  52. package/vbrief/schemas/vbrief-core.schema.json +5 -0
  53. package/vbrief/schemas/xbrief-core-0.8.schema.json +5 -0
  54. package/vbrief/vbrief.md +37 -0
  55. package/verification/verification.md +2 -1
package/Taskfile.yml CHANGED
@@ -344,6 +344,10 @@ includes:
344
344
  value:
345
345
  taskfile: ./tasks/value.yml
346
346
  optional: true
347
+ # Structured agent decision log (#1396). Inner tasks write/list → decision:write / decision:list.
348
+ decision:
349
+ taskfile: ./tasks/decision.yml
350
+ optional: true
347
351
  product-signal:
348
352
  taskfile: ./tasks/product-signal.yml
349
353
  optional: true
package/coding/coding.md CHANGED
@@ -4,7 +4,6 @@
4
4
  <!-- Regenerate with: task packs:render -->
5
5
  <!-- Edit the source, not this file. Slice instead of loading every coding doc: task packs:slice rules by-tier --tier <TIER> (or by-domain, list) -->
6
6
 
7
-
8
7
  # Coding Guidelines
9
8
 
10
9
  Software development specific guidelines for AI agents.
@@ -126,7 +125,7 @@ See [../scm/git.md](../scm/git.md) for:
126
125
 
127
126
  The failure mode is the agent stating completion at the level of **intent** ("I ran the migration", "the tests pass", "the feature works") rather than at the level of **outcome verification** ("all 167 records migrated, 0 skipped", "42 tests collected, 42 passed, 0 skipped, 0 xfailed", "the edge case asked about was reproduced and now returns the expected value"). Outcome-blind completion claims hide silent skips, swallowed exceptions, suppressed errors, and unverified edge cases behind successful-sounding language. The example from the source: a database migration that completed "successfully" had silently skipped 14% of records on a constraint violation; the skip was logged but not surfaced; the bad reports were discovered 11 days later.
128
127
 
129
- This rule is the OPERATIONAL complement to the EPISTEMIC honesty rules elsewhere in the framework (`main.md` morals section: don't present speculation as fact; label unverified claims). Morals.md says "don't lie". Fail-loud says "count the records, check the logs, run the edge case, **then** claim completion." It is also the output-side complement to goal-gate-determinism (the gate specifies what evidence is required) and machine-verifiable-spec (verification commands prevent silent skips) -- without fail-loud, an agent can satisfy the letter of a gate ("tests pass") while hiding the gap ("some tests were skipped").
128
+ This rule is the OPERATIONAL complement to the EPISTEMIC honesty rules elsewhere in the framework (`main.md` morals section: don't present speculation as fact; label unverified claims). Morals.md says "don't lie". Fail-loud says "count the records, check the logs, run the edge case, **then** claim completion." It is also the output-side complement to [goal-gate-determinism](../patterns/goal-gate-determinism.md) (#852 — the gate specifies what evidence is required) and machine-verifiable-spec (verification commands prevent silent skips) -- without fail-loud, an agent can satisfy the letter of a gate ("tests pass") while hiding the gap ("some tests were skipped").
130
129
 
131
130
  - ! Before claiming a batch operation succeeded, MUST verify the record count and surface it in the claim ("migrated 167/167 records, 0 skipped, 0 errored" -- not "migration completed")
132
131
  - ! Before claiming "tests pass", MUST report the count of collected / passed / skipped / xfailed / errored tests ("42 collected, 42 passed, 0 skipped" -- not "tests pass"). A skipped or xfailed test is NOT a passing test for the purpose of this claim
@@ -144,7 +143,7 @@ This rule is the OPERATIONAL complement to the EPISTEMIC honesty rules elsewhere
144
143
 
145
144
  The rule applies to agent completion claims during task execution. It applies equally to claims to the user, claims in commit messages, claims in PR bodies, claims in CHANGELOG entries, and claims in status messages to a parent agent. A short, honest "the migration completed; I did not verify the per-record count" is strictly preferred over a confident "migration completed successfully" that hides the gap.
146
145
 
147
- **Cross-references:** strategies discuss/probe Graduation dual-path locks (#2899); `## Quality Standards` above (`⊗ Claim checks passed without running them` -- the sibling rule that this expands from process to outcome); `hygiene.md` `## Error Handling: No Hiding` (the same hiding pattern at the code-write level, not the claim level); `skills/deft-directive-pre-pr/SKILL.md` (pre-PR verification claims); `skills/deft-directive-build/SKILL.md` Step 4 Quality Gates (task-completion claims); `skills/deft-directive-review-cycle/SKILL.md` (Greptile adapter; universal review principles in [review.md](review.md); the adapter explicitly checks for hidden incompleteness in fix-batch completion claims).
146
+ **Cross-references:** strategies discuss/probe Graduation dual-path locks (#2899); `## Quality Standards` above (`⊗ Claim checks passed without running them` -- the sibling rule that this expands from process to outcome); `hygiene.md` `## Error Handling: No Hiding` (the same hiding pattern at the code-write level, not the claim level); [`patterns/goal-gate-determinism.md`](../patterns/goal-gate-determinism.md) (#852 — rigid goals/gates, flexible path); `skills/deft-directive-pre-pr/SKILL.md` (pre-PR verification claims); `skills/deft-directive-build/SKILL.md` Step 4 Quality Gates (task-completion claims); `skills/deft-directive-review-cycle/SKILL.md` (Greptile adapter; universal review principles in [review.md](review.md); the adapter explicitly checks for hidden incompleteness in fix-batch completion claims).
148
147
 
149
148
  ## Calling LLM APIs (#481)
150
149
 
package/commands.md CHANGED
@@ -183,6 +183,25 @@ flowchart TD
183
183
 
184
184
  ---
185
185
 
186
+ ## Structured decision log (#1396)
187
+
188
+ Lightweight intent-debt records for **significant** choices (architecture, product behavior, security, public/private boundary, data model, runtime topology, hard-to-reverse process). Not every trivial scope. Not ADR migration; leave `docs/decisions/ADR-*.md` alone. Split from lessons (#1513).
189
+
190
+ | Command | Purpose |
191
+ |---------|---------|
192
+ | `task decision:write` | Validate and write `xbrief/decisions/YYYY-MM-DD-<slug>.decision.json`; optional `--scope` appends a pointer under `plan.narratives.Decisions` |
193
+ | `task decision:list` | List/filter records (`--query`, `--scope`, `--issue`, `--json`) |
194
+
195
+ Required fields: decision, governing rule/constraint, alternatives considered, why winner, confidence, timestamp, revisit trigger; active scope ref(s) when applicable.
196
+
197
+ ! For significant choices during build / pre-PR / portfolio dispose, record via `task decision:write` (or `--body-file` on Windows for multi-line fields).
198
+ ⊗ Require a decision record before every `scope:complete` in v1 (guidance only; no deterministic complete-hook yet).
199
+ ⊗ Store chat transcripts or replace git history with this surface.
200
+
201
+ Docs: [docs/decision-log.md](./docs/decision-log.md) · layout: `xbrief/decisions/README.md`. Consumers: portfolio dispose (#3198/#3201), process dogfood (#1423).
202
+
203
+ ---
204
+
186
205
  ## Generated Document Commands
187
206
 
188
207
  Edit the xBRIEF source, then render the markdown view.
@@ -248,6 +267,9 @@ Current status: the validation, extractor, provider, registry, generated MAP, an
248
267
  - `task verify:xbrief-conformance` -- validate xBRIEF conformance surfaces.
249
268
  - `task verify:cache-fresh` -- validate cache freshness where required.
250
269
  - `task verify:capacity`, `task verify:wip-cap`, and `task verify:judgment-gates` -- policy/capacity gates.
270
+ - `task verify:orphan-active` -- fail closed when active/running xBRIEFs still point at closed issues or merged PRs (#2321).
271
+ - `task verify:completed-tracked` -- fail closed when closed scoped issues lack a tracked `xbrief/completed/` or `xbrief/cancelled/` artifact on the delivery tip (#3264); remediate with `task swarm:finalize-cohort` or a lifecycle PR. Standalone verb (not part of `task check`); use `--tip HEAD` when validating an in-flight land branch.
272
+ - `task verify:literal-ac` -- run stated acceptance commands from the active (or `--xbrief`) scope artifact **verbatim** before done (#3267); same flags/cwd; fail closed on non-zero. `--capture-only` lists resolved commands without executing. Standalone (not part of `task check`); required on ceremony dial rapid/minimal. Extends #973.
251
273
  - `task coverage:hotspots` / `deft coverage:hotspots` -- read the latest coverage report, compare global metrics to the project's vitest thresholds, fail closed below the branch floor or below configured headroom (default 0.3pp), and list lowest modules plus uncovered branch samples for git-diff paths (`--json` for agents). Complements `deft verify:forward-coverage` (#1310) and `--allow-coverage-debt=#N` (#2573); does not replace them.
252
274
 
253
275
  Use `task --list` for the exact current verify namespace.
@@ -280,15 +302,17 @@ When the workflow needs an Approach 1 monitor, scope the Cursor leaf `stop-at: p
280
302
 
281
303
  `directive init` and `deft update` idempotently merge Directive-owned entries into `.claude/settings.json`, `.grok/hooks/deft.json`, `.cursor/hooks.json`, and `.codex/hooks.json` while preserving unrelated settings. `SessionStart` refreshes resume bookkeeping on a non-blocking path. `PreToolUse` uses the lightweight `deft-hook` entrypoint rather than booting the full CLI router, reducing cold hook latency while retaining the same fail-closed ritual, scope, and runtime-authority decisions. Cursor `ApplyPatch` shares the direct-write registration, so each matched edit invokes one hook process. Cursor `preToolUse` deposits set `failClosed: true`, so allow decisions emit `{"permission":"allow"}` — empty stdout is treated as hook failure and would block Write tools. A second `PreToolUse` matcher covers spawn/Task tools (`Task`, `SubagentStart`, `spawn_subagent`, `start_agent`, `CreateAgent`) with the pre-`start_agent` gate stack for **implementation** spawns; explore and ephemeral postures skip active-xBRIEF (see three postures below).
282
304
 
283
- - **Spawn postures (#1185 / #3080):** PreToolUse classifies Task/spawn by **structural markers** (not free-text prompt NLP). Unmarked / default Multitask (`generalPurpose`) is treated as **implement** (fail closed). Session-level **assist** posture for direct scratch writes is the #1802 twin — see § Assist / research posture (#1802).
305
+ - **Spawn postures (#1185 / #3080 / #3259):** PreToolUse classifies Task/spawn by **structural markers** (not free-text prompt NLP). Unmarked / default Multitask (`generalPurpose`) is treated as **implement** (fail closed) unless session assist env is set (#3259). Session-level **assist** posture is the #1802 twin for scratch writes **and** for spawn when env markers apply — see § Assist / research posture (#1802).
284
306
 
285
307
  | Posture | Markers | Active xBRIEF | Typical work |
286
308
  |---|---|---|---|
287
309
  | **Implement** | default / `generalPurpose` / implement leaf / `drive-to: merge-ready` | **Required** | Features, bugs, PRs, scope lifecycle |
288
310
  | **Explore** | `subagent_type` or `worker_role` = `explore` (#1185) | Not required | Read-only research, orientation |
289
- | **Ephemeral** | `worker_role` (or `subagent_type`) ∈ {`ephemeral`, `docs`, `assist`} (#3080) | Not required | Brochure, pitch, disposable analysis notes |
311
+ | **Ephemeral** | Structural `worker_role`/`subagent_type` ∈ {`ephemeral`, `docs`, `assist`} (#3080); **or** session assist env `DEFT_SESSION_POSTURE` ∈ assist-set / `DEFT_HOOK_ASSIST=1` (#3259) | Not required | Brochure, pitch, disposable analysis, **local-dev ops** (`docker compose`, `pnpm dev`) |
312
+
313
+ Gate order: explore allow (`spawn-explore-ready`) → ephemeral allow (`spawn-ephemeral-ready`) → else implementation stack (`inspectMutationGates`). If an ephemeral marker (role field **or** session assist env) conflicts with implement envelope signals (`drive-to: merge-ready`, `worker_role: leaf-implementation`, swarm implement dispatch), **implement wins**. Ephemeral allowance does **not** authorize push/merge/deploy or skip `runtimeAuthority` / human-merge gates.
290
314
 
291
- Gate order: explore allow (`spawn-explore-ready`) ephemeral allow (`spawn-ephemeral-ready`) else implementation stack (`inspectMutationGates`). If an ephemeral marker conflicts with implement envelope signals (`drive-to: merge-ready`, `worker_role: leaf-implementation`, swarm implement dispatch), **implement wins**. Ephemeral allowance does **not** authorize push/merge/deploy or skip `runtimeAuthority` / human-merge gates. **Anti-pattern:** invent a fake `scope:activate` only to dispatch brochure/docs work — use `worker_role: ephemeral` (or continue in the parent) instead. Deny text for missing active scope on implement spawns lists activate \| explore \| ephemeral recoveries.
315
+ **Cursor Multitask delivery (#3259 residual of #3080):** Cursor often delivers only `subagent_type: generalPurpose` + prompt and cannot set structural `worker_role` fields. Free-text `[worker_role: ephemeral]` in the prompt is **not** sufficient (no NLP). Working Cursor local-dev paths: (1) parent Shell for `docker compose` / `pnpm dev` (no Task spawn gate); (2) session assist env (`DEFT_SESSION_POSTURE=assist` or `DEFT_HOOK_ASSIST=1`) so Multitask Task classifies as ephemeral; (3) hosts that can set structural `worker_role`/`subagent_type` ephemeral. **Anti-pattern:** invent a fake `scope:activate` only for brochure/docs/local-dev. Deny text for missing active scope lists activate \| explore \| ephemeral (structural/session-assist) \| parent Shell recoveries.
292
316
 
293
317
  - **Assist scratch direct writes (#1802):** PreToolUse allows Write/Edit under allowlisted gitignored roots (`.deft-scratch/**`, `temp/**`) when assist/ephemeral classification applies (`DEFT_SESSION_POSTURE=assist`, payload posture, or #3080 role markers) — decision code `write-assist-scratch-ready`. Skips ritual + active-scope; does **not** unlock tracked product paths. Fail closed outside the allowlist or without structural markers. Deny recovery for in-repo scope-not-ready mentions the assist scratch path (do not invent fake `scope:activate` for notes). Full rules: § Assist / research posture (#1802).
294
318
 
@@ -554,7 +578,8 @@ flowchart TD
554
578
  - `task release:*` -- release, publish, rollback, and e2e release rehearsal.
555
579
  - Step 3 (`Pre-flight vBRIEF lifecycle sync`) fetches GitHub issue states via REST. On HTTP 403 rate-limit exhaustion it sleeps once (capped at 120s) and retries before failing.
556
580
  - When Step 3 still fails with rate-limit exhaustion, stderr includes a `gh api rate_limit` probe (`core.remaining`, reset time) and recovery guidance. After local `task vbrief:validate` (or `task xbrief:validate`) exits 0, operators may pass `--allow-vbrief-drift` to skip Step 3 for that cut — reserved for transient SCM bucket stalls, not unreviewed lifecycle drift.
557
- - `task swarm:*` -- readiness, launch, review-clean verification, and cohort completion.
581
+ - `task swarm:*` -- readiness, launch, pre-dispatch deny gate (#3228), review-clean verification, and cohort completion.
582
+ - **Operator follow-up after dual-stop / hard stop (#3273):** when a dual-stop or conf-hold halt report lands, re-authorize one residual pass with phrases *pursue residual* / *follow-up hard-stop* / *same as conf-hold* / *continue dual-stopped PR* — steps in `skills/deft-directive-swarm` and `skills/deft-directive-review-cycle` § Operator follow-up after dual-stop / hard stop (not a separate task verb).
558
583
  - `task slice:*` -- feature-slice helpers.
559
584
  - `task policy:*` and `task capacity:*` -- policy inspection and allocation helpers.
560
585
 
@@ -4,6 +4,16 @@ Legend (from RFC2119): !=MUST, ~=SHOULD, ≉=SHOULD NOT, ⊗=MUST NOT, ?=MAY.
4
4
 
5
5
  Principles for designing tools that agents can use effectively.
6
6
 
7
+ **Load when:** authoring host tools, MCP/server tool schemas, skill-facing
8
+ task surfaces, or any agent-callable parameter shape. Also load when a
9
+ tool call fails in ways that look like "the model is dumb" but may be
10
+ dialect sampling cost.
11
+
12
+ **⚠️ See also**:
13
+ - [patterns/llm-app.md](../patterns/llm-app.md) `## Tool / function calling` — security, least privilege, validation (confused deputy)
14
+ - [patterns/tool-call-taxonomy.md](../patterns/tool-call-taxonomy.md) — explore / commit / verify activity buckets (orthogonal)
15
+ - [deterministic-split.md](./deterministic-split.md) — what must not be an LLM step at all
16
+
7
17
  ---
8
18
 
9
19
  ## Minimal, Non-Overlapping Tool Sets
@@ -12,6 +22,110 @@ Principles for designing tools that agents can use effectively.
12
22
  - ≉ Offering multiple tools that do the same thing with slight variations
13
23
  - ~ Each tool should have a **single, clear purpose**
14
24
 
25
+ ## Tool-surface grammar (#3085)
26
+
27
+ A tool "call" is **dialect sampling** in the token stream. The model does
28
+ not decide to call a tool as a special act. It continues the completion
29
+ loop under a harness dialect (`function_calls` / `invoke` / JSON args /
30
+ provider-specific tags). Schema design is a first-order **reliability and
31
+ cost** surface, not cosmetics.
32
+
33
+ **Rule of thumb:** reliability degrades with
34
+ **nesting × heterogeneity × cleverness**.
35
+
36
+ Source framing (practitioner ablation, not product UI): Can Bölük
37
+ ([@_can1357](https://x.com/_can1357/status/2084104053651317140), 2026-08-03).
38
+ The post's emoji / plaintext "control group" is **not** a product
39
+ recommendation. At roughly ten or more tools, native tool-calls win on
40
+ ergonomics; still design the **thinnest grammar** you can get away with.
41
+
42
+ ### Prefer flat, homogeneous params
43
+
44
+ - ~ Prefer **flat scalar/string parameters** over nested objects and
45
+ arrays-as-escaped-JSON inside a single parameter value
46
+ - ~ Prefer a **homogeneous** parameter set (similar types, predictable
47
+ names) over mixed clever packing (object + freeform JSON string +
48
+ parallel batch bag in one tool)
49
+ - ~ When the host owns the tools, prefer a **vector / flat** shape (one
50
+ named field per logical input) over "batch JSON in a string" when that
51
+ batch only exists to save parallel tool-call round-trips
52
+ - ≉ Nested argument bags that force the model to emit valid escaped JSON
53
+ for complex objects when plain scalar parameters would suffice
54
+ - ≉ Heterogeneous mega-tools that pack unrelated concerns into one clever
55
+ payload "for flexibility"
56
+ - ! Treat provider schema fields (`minimum`, `maximum`, `enum`, long
57
+ descriptions) as **documentation the harness may show**. Validation is
58
+ the application's job unless the harness (or provider) actually rejects
59
+ invalid args — do not assume the model "must" obey schema mins/maxes
60
+ - ! Validate tool arguments in the harness before side effects
61
+ (`patterns/llm-app.md` tool-call rules). A flat grammar still needs a
62
+ validator and common dialect failure handling (leaked call text,
63
+ truncated invoke blocks, wrong tool name tokens)
64
+
65
+ ### Good vs bad shapes (sketch)
66
+
67
+ Bad — nested / heterogeneous / JSON-in-string:
68
+
69
+ ```text
70
+ apply_batch({
71
+ "ops": "[{\"path\":\"a.ts\",\"edits\":[{\"start\":1,\"end\":2,\"text\":\"...\"}]}]"
72
+ })
73
+ ```
74
+
75
+ The model must sample valid escaped JSON for a nested array. One quote
76
+ or brace error fails the turn. High nesting × high cleverness.
77
+
78
+ Better — flat / homogeneous (host-owned tools):
79
+
80
+ ```text
81
+ edit_file(path="a.ts", start_line=1, end_line=2, text="...")
82
+ ```
83
+
84
+ Scalars and strings after named parameters. The dialect delimiter ends
85
+ the value; no JSON escape maze for the common case. Repeat the tool or
86
+ use parallel invokes when multiple edits are needed.
87
+
88
+ When composition is large (many steps, dynamic graphs), **do not** invent
89
+ deeper nested tool packs. Prefer fewer tools via code abstraction / Code
90
+ Mode / a host-side program (related: #1167, #2593) and multi-step token
91
+ breakpoints (#1170). Those reduce **how many** tools exist; this section
92
+ shapes **how each remaining tool looks** at the dialect layer.
93
+
94
+ ### Authoring checklist (Directive + consumers)
95
+
96
+ Use for Directive-owned task/skill tool surfaces, documented host schemas,
97
+ and consumer MCP / product-agent schemas:
98
+
99
+ | Prefer | Avoid |
100
+ |--------|--------|
101
+ | Flat named scalars/strings | Nested object trees as required args |
102
+ | One clear purpose per tool | Mega-tools with optional clever branches |
103
+ | Homogeneous repeated fields | Mixed types + freeform JSON bags |
104
+ | Host validation + repair | Trusting provider schema as enforcement |
105
+ | Code / DSL for multi-step | Deeper nesting to "express workflows" |
106
+
107
+ - ~ Document constraints in parameter descriptions for human and model
108
+ readers, then **enforce in code**
109
+ - ≉ Shipping emoji/plaintext tool channels as a product default (control
110
+ group only in the source post)
111
+ - ≉ Migrating every existing tool in one pass — land the principle first;
112
+ reshape high-failure surfaces when measured failure rates justify it
113
+ - ? Keep a short failure catalog of dialect errors for your harness
114
+ (sibling track: #3086) so "won't fix" provider quirks become harness
115
+ duties
116
+
117
+ ### Complementarity
118
+
119
+ | Concern | Where it lives |
120
+ |---------|----------------|
121
+ | **How each tool's args sample** (this doc) | Flat grammar, low nesting tax |
122
+ | **How many tools** exist | Code Mode / DSL / abstraction (#1167, #2593) |
123
+ | **When multi-step burns tokens** | Breakpoints / long-horizon (#1170) |
124
+ | **Security of tool use** | `patterns/llm-app.md` (schema validate, least privilege) |
125
+ | **Protocol / model-tier cost after shape** | Cost-envelope notes (e.g. #3078) |
126
+
127
+ ---
128
+
15
129
  ## Token-Efficient Outputs
16
130
 
17
131
  - ~ Support **filtering** — let the caller request only the fields they need
@@ -25,6 +139,8 @@ Principles for designing tools that agents can use effectively.
25
139
  - ! **Tool descriptions** should state what the tool does, when to use it, and what it returns
26
140
  - ~ **Parameters** should be self-documenting — use descriptive names and include constraints in descriptions
27
141
  - ≉ Relying on the agent to infer parameter semantics from names alone
142
+ - ~ Keep descriptions short enough to load on demand; put deep examples in
143
+ linked docs, not in every tool definition (token tax — see also #865)
28
144
 
29
145
  ## Error Messages
30
146
 
@@ -84,12 +84,21 @@ Full operator steps: [`../docs/openclaw-agent-host.md`](../docs/openclaw-agent-h
84
84
  | **Buzz / Pi** | Session-first family-2 peers. Implement a dedicated `host-*.md` adapter when scheduled; reuse this duty table. Do not invent full platform abstraction in this cut. |
85
85
  | **Warp / Grok Build** | Family-1-adjacent spawn hosts; deposit + AGENTS still own session orientation. Swarm launch adapters are separate from cold-start Skills Index load. |
86
86
 
87
+ ## Content-surface honesty (#3162)
88
+
89
+ Session start records a **host content-surface class** (`file-first` / `repl-first` / `self-mutating` / `unknown`) and managed AGENTS section drift. Operators set `DEFT_HOST_CONTENT_SURFACE` (or REPL / self-mutate env flags) when the host is not file-first.
90
+
91
+ ! Do not assume file gates or agent-only pins see host-kernel work product or host refine CRUDs.
92
+
93
+ Full honesty matrix and Tier-1 hook home: [`../docs/host-surface-assumptions.md`](../docs/host-surface-assumptions.md). Stance #3164 unchanged.
94
+
87
95
  ## Anti-patterns
88
96
 
89
97
  - ⊗ Freestyle host tools first on Deft-shaped intent, then maybe open a skill.
90
98
  - ⊗ Treat host skill inventory (`available_skills`, workspace skill folders) as the Directive Skills Index without a bridge.
91
99
  - ⊗ Assume IDE deposit behavior on a session-first host that started outside the project root.
92
100
  - ⊗ Abstract multi-host portability RFC with zero OpenClaw (or second-family) behavior change.
101
+ - ⊗ Assume file/git gates saw REPL-kernel or mid-run host-refine work product (#3162).
93
102
 
94
103
  ## Acceptance pointer
95
104
 
@@ -43,6 +43,7 @@ These are the specific blocks the study measured *hurting* agent quality — tre
43
43
 
44
44
  When a workflow skill must not be skipped on trigger miss (implementation, pre-PR, review-cycle, swarm), name it in AGENTS.md as an **always-pin** — not by pasting the skill body. Tier definitions, default pin list, and anti-patterns (do not pin entire language packs): [`skill-pin-policy.md`](./skill-pin-policy.md).
45
45
 
46
+ On REPL-first or self-mutating hosts, pins and file gates have honest limits — see [`host-surface-assumptions.md`](./host-surface-assumptions.md) (#3162).
46
47
  ## Relationship to directive's own dogfooding
47
48
 
48
49
  Directive holds its own AGENTS.md to this bar via the `verify:agents-md-budget` ratchet (#645) and the consumer-side advisory signal (`agentsMdAdvisory`, #2155). The doc-sprawl awareness step in the `deft-directive-sync` skill (#647) surfaces reachable-doc-volume drift before it silently degrades agent quality. This doc is the "how to structure it well" companion to those "keep it from bloating" guards.
@@ -16,11 +16,34 @@ A consumer could omit Directive enforcement gates from its `check` task and CI w
16
16
 
17
17
  It fails with a concrete repair path when definitions or explicit check deps omit them. CI workflows that neither invoke the gates nor a composing entrypoint (`task check` / `deft check`) produce **warnings** by default (migration).
18
18
 
19
+ ### Greenfield include-only Taskfile (#3218)
20
+
21
+ After `directive init`, the consumer root `Taskfile.yml` is often **include-only**:
22
+
23
+ ```yaml
24
+ includes:
25
+ deft:
26
+ taskfile: ./.deft/core/Taskfile.yml
27
+ optional: true
28
+ ```
29
+
30
+ Operators run `task deft:check` (namespaced include). Composition lives in the **included** framework `Taskfile.yml` + `.deft/core/tasks/verify.yml`, not in root `check` deps.
31
+
32
+ `verify:consumer-check-contract` **trusts that included graph** when:
33
+
34
+ 1. The root Taskfile declares the canonical `.deft/core/Taskfile.yml` include, and
35
+ 2. No local `check` / `check:consumer` / `check:framework-source` aggregate is defined at the root, and
36
+ 3. The included framework Taskfile defines the required gates in `tasks/verify.yml` and composes them (deps or check orchestrator body).
37
+
38
+ A **partial local** root check aggregate still fails closed — the include must not conceal incomplete root deps.
39
+
40
+ Root cause of red `greenfield-python-free-smoke` after #3145: the gate only inspected the root Taskfile, treated include-only greenfield as “no check composition,” and hard-failed (`exit 201` via #3188). That was a **gate false positive** for the intentional deposit shape, not a missing deposit wiring bug.
41
+
19
42
  ## Repair path
20
43
 
21
- 1. Restore deposit Taskfiles: `deft update` (includes `tasks/verify.yml`)
22
- 2. Ensure `check:consumer` / `check:framework-source` deps list the three gates (framework source already ships this wiring)
23
- 3. Prefer CI that runs `task check` or `deft check` rather than a partial custom graph
44
+ 1. Restore deposit Taskfiles: `deft update` (includes `tasks/verify.yml` under `.deft/core/`)
45
+ 2. Ensure `check:consumer` / `check:framework-source` deps list the three gates (framework source already ships this wiring), **or** keep the include-only greenfield shape so the gate follows the canonical include
46
+ 3. Prefer CI that runs `task check` / `task deft:check` / `deft check` rather than a partial custom graph (installer-only workflows such as `deft-core-guard` stay warn-only for CI composition)
24
47
 
25
48
  ## Relation to #3070
26
49
 
@@ -0,0 +1,114 @@
1
+ # Structured agent decision log (#1396)
2
+
3
+ Durable **intent-debt** records for significant agent and operator choices.
4
+
5
+ Git history records *what* changed. Decision records capture *why* A won over B, under which rule, and when a later agent should re-open the choice.
6
+
7
+ Legend (from RFC2119): !=MUST, ~=SHOULD, ≉=SHOULD NOT, ⊗=MUST NOT, ?=MAY.
8
+
9
+ ## When to record
10
+
11
+ ! Record a decision when the choice is **significant**:
12
+
13
+ - architecture
14
+ - product behavior
15
+ - security
16
+ - public / private boundary
17
+ - data model
18
+ - runtime topology
19
+ - hard-to-reverse process
20
+
21
+ ⊗ Record a decision for every trivial scope or routine bugfix.
22
+
23
+ ## Commands
24
+
25
+ ```bash
26
+ # Write (flags and/or --body-file JSON)
27
+ task decision:write -- \
28
+ --decision "Prefer dual location for decision records" \
29
+ --governing-rule "Significant choices leave durable rationale" \
30
+ --governing-path "content/docs/decision-log.md" \
31
+ --governing-rfc MUST \
32
+ --alternative "scope-only narratives" \
33
+ --alternative "ADR-only" \
34
+ --why-winner "Covers scope-bound and cross-cutting without ADR noise" \
35
+ --confidence high \
36
+ --revisit-trigger "If list/find is painful, revisit folder layout" \
37
+ --scope xbrief/active/2026-08-09-example.xbrief.json \
38
+ --related-issue 1396 \
39
+ --tag process
40
+
41
+ # List / filter
42
+ task decision:list --
43
+ task decision:list -- --query mirror --json
44
+ task decision:list -- --issue 1423
45
+ task decision:list -- --scope xbrief/active/
46
+ ```
47
+
48
+ On Windows, prefer `--body-file` for multi-line fields (UTF-8 no BOM temp file).
49
+
50
+ Invalid schema fails closed (exit 2).
51
+
52
+ ## Schema (lightweight, not xBRIEF lifecycle)
53
+
54
+ | Field | Required | Notes |
55
+ |-------|----------|--------|
56
+ | `schemaVersion` | yes | `deft.decision.v1` |
57
+ | `id` | yes | kebab slug (derived from decision if omitted) |
58
+ | `decision` | yes | what was decided |
59
+ | `governingRule` | yes | `{ description, path?, rfc2119? }` or string |
60
+ | `alternativesConsidered` | yes | non-empty array of `{ option, whyNot? }` |
61
+ | `whyWinner` | yes | why the chosen path won |
62
+ | `confidence` | yes | `low` \| `medium` \| `high` |
63
+ | `activeScopeRefs` | no | relative scope xBRIEF path(s) |
64
+ | `timestamp` | yes | ISO-8601 UTC |
65
+ | `revisitTrigger` | yes | when/why to re-open |
66
+ | `tags` / `relatedIssues` | no | list filters |
67
+
68
+ Files: `xbrief/decisions/YYYY-MM-DD-<slug>.decision.json` (committed; not gitignored).
69
+
70
+ ## Dual location
71
+
72
+ 1. **Always** write the JSON file under `xbrief/decisions/`.
73
+ 2. When `--scope` points at a scope xBRIEF, also append a pointer line under `plan.narratives.Decisions` (string narrative; validators accept extra narrative keys).
74
+ 3. Use `--standalone` to skip scope attach even if scope refs are present.
75
+
76
+ Cross-cutting process/architecture decisions often have empty `activeScopeRefs`.
77
+
78
+ ## Enforcement (v1)
79
+
80
+ ! Guidance only in build / pre-pr / portfolio (and related) skills for **significant** choices.
81
+
82
+ ⊗ Do **not** require a decision record before every `scope:complete` in v1 (deterministic complete-hook is later work).
83
+
84
+ ## Split from other surfaces
85
+
86
+ | Surface | Role |
87
+ |---------|------|
88
+ | This decision log (#1396) | Single durable rationale events |
89
+ | Lessons / compound memory (#1513) | Reusable patterns and anti-patterns |
90
+ | `docs/decisions/ADR-*.md` | Heavyweight architecture ADRs — leave alone |
91
+ | Portfolio brief (#3198/#3201) | Propose-not-apply; **dispose** into `decision:write` |
92
+ | Chat / transcripts | Non-goal |
93
+ | Full inter-run memory (#2741) | Related consumer later; not owned by this surface |
94
+
95
+ ## Consumers
96
+
97
+ - Portfolio dispose (#3198 / #3201 / pilot #3200)
98
+ - Process policy dogfood (SCM label-mirror first mass-apply #1423)
99
+ - Multi-agent handoff continuity (related #2741 class)
100
+
101
+ ## Dogfood seeds
102
+
103
+ - `xbrief/decisions/2026-08-08-scm-label-mirror-first-mass-apply.decision.json`
104
+ - `xbrief/decisions/2026-08-09-portfolio-dispose-into-decision-log.decision.json`
105
+
106
+ ## Cold-path discovery (#3211)
107
+
108
+ ! Always-on AGENTS managed pointer (via `content/templates/agents-entry.md` + `task agents:refresh`), Level-0 `REFERENCES.md` under context/long tasks, and [`inter-run-learning.md`](./inter-run-learning.md) link this surface so a fresh session can name `decision:list` without loading build or pre-pr skills.
109
+
110
+ ## See also
111
+
112
+ - [`xbrief/decisions/README.md`](../../xbrief/decisions/README.md)
113
+ - `task decision:write` / `task decision:list` in [`commands.md`](../commands.md)
114
+ - [`inter-run-learning.md`](./inter-run-learning.md) (cold memory SoTs; this log is the durable *why* lane)
@@ -90,13 +90,29 @@ and tool-call budgets still apply.
90
90
  `allowedAttempts`, and optional expiry. Overrides do **not** erase attempt
91
91
  history.
92
92
 
93
+ ## Swarm implement-leaf wiring (#3228)
94
+
95
+ Portable CLI gate on the swarm re-dispatch path (not library-only):
96
+
97
+ ```
98
+ task swarm:pre-dispatch -- --scope-id <story|issue|xbrief-id> --target-id <worktree|branch>
99
+ # exit 0 allow (beginAttempt) / 1 DENY_DUPLICATE_ACTIVE or other gate block / 2 config
100
+ ```
101
+
102
+ Default unit key: `scopeId` + `targetId` + `workflowId=drive-to:merge-ready`.
103
+ Actions: `begin` (default), `complete` (`--status succeeded|failed|cancelled|blocked`), `cancel` (takeover step 1).
104
+ Monitors MUST run begin before any peer implement spawn; spawn only on exit 0.
105
+ Takeover: cancel prior attempt, then begin again — never concurrent dual active.
106
+ Implementation: `packages/core/src/swarm/pre-dispatch.ts` + `task swarm:pre-dispatch`.
107
+
93
108
  ## Skill routing
94
109
 
95
110
  | Surface | Role |
96
111
  |---------|------|
97
112
  | `main.md` Dual Stop Rule (#2442) | Principle; points here for delivery/acceptance |
98
113
  | build / swarm / review-cycle skills | Behavioral dual-stop defaults; point here for mechanical gate |
99
- | swarm `core-ops` / `core-phase-4` | Prompt + monitor envelopes; do not invent a second ledger |
114
+ | swarm `core-ops` / `core-phase-4` | Prompt + monitor envelopes; pre-dispatch CLI pointer (#3228); do not invent a second ledger |
115
+ | `task swarm:pre-dispatch` | Authoritative implement-leaf gate (#3228); wires `DENY_DUPLICATE_ACTIVE` |
100
116
 
101
117
  ## Typical call shape
102
118
 
@@ -0,0 +1,112 @@
1
+ # Gate integrity — a failing gate must not be fixed by editing the gate (#3156)
2
+
3
+ General product and process rule for Directive fix loops, refine loops, and quality-gate repair: **when a gate is red, clear red by fixing the work under test — not by mutating the gate.**
4
+
5
+ Legend (RFC2119): `!`=MUST, `~`=SHOULD, `≉`=SHOULD NOT, `⊗`=MUST NOT, `?`=MAY.
6
+
7
+ Parent epic: [#3179](https://github.com/deftai/directive/issues/3179) (self-improving under gates). Stance: [#3164](https://github.com/deftai/directive/issues/3164) (**shipped** — constitution-tier changes go through issue/PR + review; this doc does not re-litigate that stance). Extends verification independence [#782](https://github.com/deftai/directive/issues/782) / [#1499](https://github.com/deftai/directive/issues/1499) and scope self-auth themes [#3145](https://github.com/deftai/directive/issues/3145).
8
+
9
+ ---
10
+
11
+ ## The rule (sharp form)
12
+
13
+ - ⊗ A self-modification, refine, fix, or pre-PR loop **MUST NOT** clear a failing gate by editing the **gate definition**, **verifier**, **reward**, **required check**, coverage floor, policy flag, eval fixture, or other evaluator surface that is currently failing — solely so the loop can report green.
14
+ - ! When a gate fails, fix the **product, process, test, or documentation under test**.
15
+ - ! Deliberate **gate definition** changes (raise/lower thresholds, rewrite verify scripts, change required checks) go through the normal **issue → PR → review** path with explicit rationale — same disposal model as constitution-tier content under [#3164](https://github.com/deftai/directive/issues/3164).
16
+ - ~ If the gate itself is wrong (false positive, obsolete check, wrong floor), open or amend an issue/PR that **names the gate change as the change**, not as a silent sibling edit inside a product fix.
17
+
18
+ One-line form:
19
+
20
+ > When a gate fails, the fix MUST NOT be an edit to the gate.
21
+
22
+ ---
23
+
24
+ ## What counts as a “gate” here
25
+
26
+ Any deterministic pass/fail surface that adjudicates work quality, including but not limited to:
27
+
28
+ | Surface | Examples |
29
+ |---------|----------|
30
+ | Aggregate quality | `task check`, CI required checks |
31
+ | Coverage / thresholds | coverage floors, hotspot floors, `--allow-coverage-debt` misuse |
32
+ | Verify scripts | `verify:*` tasks, content contracts, schema validators |
33
+ | Policy flags | `plan.policy.*` that weaken or skip enforcement |
34
+ | Eval / fixtures | golden eval cells, reward definitions, required fixture assertions |
35
+ | Scope / process | active xBRIEF `file_scope` self-expansion that self-authorizes (#3145) |
36
+
37
+ The **evaluator lives outside the editable surface under test** (#782 agent-loop / fixed evaluator). Moving the goalposts is not a valid fix.
38
+
39
+ ---
40
+
41
+ ## Separation from #2436 (refine-internal SkillOpt)
42
+
43
+ | Layer | Owner | What it protects |
44
+ |-------|-------|------------------|
45
+ | **Refine-loop-internal** | [#2436](https://github.com/deftai/directive/issues/2436) SkillOpt / control stack | Proposer cannot edit its own reward / slow-update / validator **region inside the refine runtime** (bounded patch algebra, reject buffer, protected region) |
46
+ | **General product/process gate integrity** | **This issue (#3156)** | Agents and fix loops must not clear **Directive product/process gates** (check, coverage, verify, policy, eval fixtures, scope) by mutating those gates |
47
+
48
+ - ⊗ Re-implement SkillOpt, proposer runtime, or refine-internal protected regions under this rule’s delivery.
49
+ - ! Treat #2436 as complementary machinery for self-improvement loops; treat **#3156 as the general behavioral rule** for every fix/pre-PR path that hits a red gate.
50
+ - ~ Host honesty limits when the **runtime** self-mutates or is REPL-first: [host-surface-assumptions.md](./host-surface-assumptions.md) (#3162). That doc names what file gates cannot see; it does not reverse this rule or #3164.
51
+
52
+ ---
53
+
54
+ ## Motivating evidence (Factorio / Continual Harness)
55
+
56
+ Prime Agent / Continual-Harness-class refine loops have packaged reward hacks as reusable skills. A concrete case study: in Factorio, a refine loop found a resource-spawn exploit and codified the exploit the same way it codifies good tactics — “self-improvement has no moral compass, only reward.”
57
+
58
+ That failure mode is exactly what #782 / #1499 / #2436 argue against, observed in a shipped MIT harness rather than only hypothesized. Directive’s answer at the **general product/process** layer is this gate-integrity rule; refine-internal machinery remains on #2436.
59
+
60
+ Field notes and parent framing: issue [#3156](https://github.com/deftai/directive/issues/3156); related safety-via-gates [#1200](https://github.com/deftai/directive/issues/1200).
61
+
62
+ ---
63
+
64
+ ## Legitimate gate change vs cheating the evaluator
65
+
66
+ | Allowed | Forbidden in a fix/refine loop |
67
+ |---------|--------------------------------|
68
+ | Fix product code so tests/coverage pass honestly | Lower coverage floor or delete failing tests only to go green |
69
+ | Fix a broken product test that asserts wrong behavior (with rationale) | Weaken the assert until anything passes |
70
+ | PR that **is** “raise coverage floor to 90%” with review | Same PR as a feature fix that silently drops the floor |
71
+ | Issue + PR changing a verify script with explicit AC | Edit verify script mid-loop because it failed your change |
72
+ | Scoped `#N` coverage-debt allow with tracked issue | Blanket skip of required checks without policy path |
73
+
74
+ - ! Gate-definition PRs MUST state the intended standard change in the PR body and issue link.
75
+ - ⊗ Bundle silent gate weakening with an unrelated product fix to “make CI green.”
76
+ - ? Temporary operator-approved debt (`--allow-coverage-debt=#N`, policy override with audit) MAY exist when the framework already defines that escape hatch — still not a free rewrite of the gate.
77
+
78
+ ---
79
+
80
+ ## Discoverability
81
+
82
+ - Pre-PR Diff phase checklist: [deft-directive-pre-pr](../skills/deft-directive-pre-pr/SKILL.md) (gate-integrity bullet).
83
+ - Stance / propose-not-apply: [main.md § Self-Improving, Not Self-Editing (#3164)](../../main.md#self-improving-not-self-editing-3164), [philosophy.md](../meta/philosophy.md).
84
+ - Verification outcomes: [verification.md](../verification/verification.md).
85
+ - Goal/gate rigidity: [goal-gate-determinism.md](../patterns/goal-gate-determinism.md) (#852).
86
+ - Scope self-auth instance: [scope-provenance.md](./scope-provenance.md) (#3145).
87
+
88
+ Full CI automation that blocks “diff touches a gate that just failed” without operator acknowledgment is an **optional follow-up** — this story ships the sharp rule and pre-PR discoverability, not a new verify binary.
89
+
90
+ ---
91
+
92
+ ## Cross-links
93
+
94
+ | Topic | Where |
95
+ |-------|--------|
96
+ | Parent epic | [#3179](https://github.com/deftai/directive/issues/3179) |
97
+ | Stance (propose-not-apply) | [#3164](https://github.com/deftai/directive/issues/3164), [main.md](../../main.md#self-improving-not-self-editing-3164) |
98
+ | Refine-internal SkillOpt | [#2436](https://github.com/deftai/directive/issues/2436) |
99
+ | Fixed evaluator / agent-loop | [#782](https://github.com/deftai/directive/issues/782) |
100
+ | Verification independence | [#1499](https://github.com/deftai/directive/issues/1499) |
101
+ | Scope self-authorization | [#3145](https://github.com/deftai/directive/issues/3145), [scope-provenance.md](./scope-provenance.md) |
102
+ | Host self-mutate honesty | [#3162](https://github.com/deftai/directive/issues/3162), [host-surface-assumptions.md](./host-surface-assumptions.md) |
103
+ | Safety via formal gates | [#1200](https://github.com/deftai/directive/issues/1200) |
104
+
105
+ ---
106
+
107
+ ## Non-goals (#3156)
108
+
109
+ - ⊗ Implementing full SkillOpt / proposer runtime (#2436)
110
+ - ⊗ Host hook enforcement for self-mutating hosts (#3162)
111
+ - ⊗ Replacing design-principle docs under #1200 (complementary)
112
+ - ⊗ Shipping full “gate-diff-when-red” CI automation in this story