thoth-agents 0.1.11 → 0.1.16

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.
@@ -1,6 +1,6 @@
1
1
  import type { AgentRoleName } from './agent-pack';
2
2
  export type SddPipelineType = 'direct' | 'accelerated' | 'full';
3
- export type SddPhaseId = 'requirements-interview' | 'proposal' | 'spec' | 'design' | 'tasks' | 'plan-review' | 'implementation-confirmation' | 'apply' | 'verify' | 'archive';
3
+ export type SddPhaseId = 'requirements-interview' | 'init' | 'explore' | 'proposal' | 'spec' | 'design' | 'tasks' | 'plan-review' | 'implementation-confirmation' | 'apply' | 'verify' | 'archive';
4
4
  export interface SddPhaseContract {
5
5
  id: SddPhaseId;
6
6
  order: number;
@@ -8,11 +8,15 @@ export interface SddPhaseContract {
8
8
  prerequisites: SddPhaseId[];
9
9
  producesArtifact: boolean;
10
10
  gate?: 'oracle-review' | 'user-confirmation';
11
- owner: 'orchestrator' | 'write-capable-agent' | 'oracle' | 'user';
11
+ owner: 'orchestrator' | 'read-only-agent' | 'write-capable-agent' | 'oracle' | 'user';
12
12
  artifactSkill?: string;
13
13
  artifactMeaning?: string;
14
+ condition?: string;
14
15
  defaultAgentRole?: AgentRoleName;
15
16
  alternateAgentRoles?: AgentRoleName[];
17
+ supportingAgentRoles?: AgentRoleName[];
18
+ persistenceAgentRole?: AgentRoleName;
19
+ delegationReason?: string;
16
20
  }
17
21
  export interface SddWorkflowContract {
18
22
  phases: SddPhaseContract[];
@@ -20,7 +24,7 @@ export interface SddWorkflowContract {
20
24
  artifactRules: string[];
21
25
  verificationRules: string[];
22
26
  }
23
- export declare const FULL_SDD_PHASE_ORDER: readonly ["requirements-interview", "proposal", "spec", "design", "tasks", "plan-review", "implementation-confirmation", "apply", "verify", "archive"];
27
+ export declare const FULL_SDD_PHASE_ORDER: readonly ["requirements-interview", "explore", "proposal", "spec", "design", "tasks", "plan-review", "implementation-confirmation", "apply", "verify", "archive"];
24
28
  export declare const SDD_PHASES: readonly [{
25
29
  readonly id: "requirements-interview";
26
30
  readonly order: 0;
@@ -28,27 +32,54 @@ export declare const SDD_PHASES: readonly [{
28
32
  readonly prerequisites: [];
29
33
  readonly producesArtifact: false;
30
34
  readonly owner: "orchestrator";
35
+ readonly delegationReason: "Root-owned requirements discovery, scope calibration, and route approval.";
31
36
  }, {
32
- readonly id: "proposal";
37
+ readonly id: "init";
33
38
  readonly order: 1;
39
+ readonly requiredFor: [];
40
+ readonly prerequisites: ["requirements-interview"];
41
+ readonly producesArtifact: true;
42
+ readonly owner: "write-capable-agent";
43
+ readonly artifactSkill: "sdd-init";
44
+ readonly condition: "Only when OpenSpec persistence is selected and openspec/ is missing.";
45
+ readonly defaultAgentRole: "quick";
46
+ readonly supportingAgentRoles: ["explorer"];
47
+ readonly delegationReason: "Fast mechanical bootstrap, with explorer supplying repository facts when needed.";
48
+ }, {
49
+ readonly id: "explore";
50
+ readonly order: 2;
34
51
  readonly requiredFor: ["accelerated", "full"];
35
52
  readonly prerequisites: ["requirements-interview"];
53
+ readonly producesArtifact: false;
54
+ readonly owner: "read-only-agent";
55
+ readonly defaultAgentRole: "explorer";
56
+ readonly supportingAgentRoles: ["librarian"];
57
+ readonly delegationReason: "Read-only repository discovery before artifact-producing SDD phases.";
58
+ }, {
59
+ readonly id: "proposal";
60
+ readonly order: 3;
61
+ readonly requiredFor: ["accelerated", "full"];
62
+ readonly prerequisites: ["requirements-interview", "explore"];
36
63
  readonly producesArtifact: true;
37
64
  readonly owner: "write-capable-agent";
38
65
  readonly artifactSkill: "sdd-propose";
39
66
  readonly defaultAgentRole: "deep";
67
+ readonly supportingAgentRoles: ["oracle"];
68
+ readonly delegationReason: "Structured technical reasoning and trade-off synthesis before implementation.";
40
69
  }, {
41
70
  readonly id: "spec";
42
- readonly order: 2;
71
+ readonly order: 4;
43
72
  readonly requiredFor: ["full"];
44
73
  readonly prerequisites: ["proposal"];
45
74
  readonly producesArtifact: true;
46
75
  readonly owner: "write-capable-agent";
47
76
  readonly artifactSkill: "sdd-spec";
48
77
  readonly defaultAgentRole: "deep";
78
+ readonly supportingAgentRoles: ["oracle"];
79
+ readonly delegationReason: "High-quality requirement contract work where ambiguity propagates downstream.";
49
80
  }, {
50
81
  readonly id: "design";
51
- readonly order: 3;
82
+ readonly order: 5;
52
83
  readonly requiredFor: ["full"];
53
84
  readonly prerequisites: ["proposal", "spec"];
54
85
  readonly producesArtifact: true;
@@ -56,58 +87,69 @@ export declare const SDD_PHASES: readonly [{
56
87
  readonly artifactSkill: "sdd-design";
57
88
  readonly artifactMeaning: "technical-solution-design";
58
89
  readonly defaultAgentRole: "deep";
90
+ readonly supportingAgentRoles: ["designer"];
91
+ readonly delegationReason: "Technical architecture and file-change design; designer only supports UI/UX concerns.";
59
92
  }, {
60
93
  readonly id: "tasks";
61
- readonly order: 4;
94
+ readonly order: 6;
62
95
  readonly requiredFor: ["accelerated", "full"];
63
96
  readonly prerequisites: ["proposal", "spec", "design"];
64
97
  readonly producesArtifact: true;
65
98
  readonly owner: "write-capable-agent";
66
99
  readonly artifactSkill: "sdd-tasks";
67
- readonly defaultAgentRole: "deep";
100
+ readonly defaultAgentRole: "quick";
101
+ readonly alternateAgentRoles: ["deep"];
102
+ readonly delegationReason: "Mechanical conversion of settled design into dependency-ordered execution tasks.";
68
103
  }, {
69
104
  readonly id: "plan-review";
70
- readonly order: 5;
105
+ readonly order: 7;
71
106
  readonly requiredFor: ["accelerated", "full"];
72
107
  readonly prerequisites: ["tasks"];
73
108
  readonly producesArtifact: false;
74
109
  readonly gate: "oracle-review";
75
110
  readonly owner: "oracle";
111
+ readonly defaultAgentRole: "oracle";
112
+ readonly delegationReason: "Independent read-only executability review of tasks before implementation.";
76
113
  }, {
77
114
  readonly id: "implementation-confirmation";
78
- readonly order: 6;
115
+ readonly order: 8;
79
116
  readonly requiredFor: ["accelerated", "full"];
80
117
  readonly prerequisites: ["plan-review"];
81
118
  readonly producesArtifact: false;
82
119
  readonly gate: "user-confirmation";
83
120
  readonly owner: "user";
121
+ readonly delegationReason: "Human approval gate after reviewed tasks and before workspace implementation.";
84
122
  }, {
85
123
  readonly id: "apply";
86
- readonly order: 7;
124
+ readonly order: 9;
87
125
  readonly requiredFor: ["direct", "accelerated", "full"];
88
126
  readonly prerequisites: ["implementation-confirmation"];
89
127
  readonly producesArtifact: false;
90
128
  readonly owner: "write-capable-agent";
91
129
  readonly defaultAgentRole: "deep";
92
130
  readonly alternateAgentRoles: ["quick", "designer"];
131
+ readonly delegationReason: "Correctness-heavy implementation by default; quick handles mechanical batches and designer owns UI/visual work.";
93
132
  }, {
94
133
  readonly id: "verify";
95
- readonly order: 8;
134
+ readonly order: 10;
96
135
  readonly requiredFor: ["accelerated", "full"];
97
136
  readonly prerequisites: ["apply"];
98
137
  readonly producesArtifact: true;
99
- readonly owner: "write-capable-agent";
138
+ readonly owner: "oracle";
100
139
  readonly artifactSkill: "sdd-verify";
101
- readonly defaultAgentRole: "deep";
140
+ readonly defaultAgentRole: "oracle";
141
+ readonly persistenceAgentRole: "quick";
142
+ readonly delegationReason: "Independent verification review; quick persists the report when the selected store requires writes.";
102
143
  }, {
103
144
  readonly id: "archive";
104
- readonly order: 9;
145
+ readonly order: 11;
105
146
  readonly requiredFor: ["accelerated", "full"];
106
147
  readonly prerequisites: ["verify"];
107
148
  readonly producesArtifact: true;
108
149
  readonly owner: "write-capable-agent";
109
150
  readonly artifactSkill: "sdd-archive";
110
- readonly defaultAgentRole: "deep";
151
+ readonly defaultAgentRole: "quick";
152
+ readonly delegationReason: "Mechanical closeout, summary, and archive movement after verification passes.";
111
153
  }];
112
154
  export declare const SDD_WORKFLOW_CONTRACT: SddWorkflowContract;
113
155
  export declare function getSddWorkflowContract(): SddWorkflowContract;
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ import {
26
26
  loadPluginConfig,
27
27
  renderRolePrompt,
28
28
  stripJsonComments
29
- } from "./chunk-R2AP6O5Q.js";
29
+ } from "./chunk-XTLXC2CM.js";
30
30
 
31
31
  // src/index.ts
32
32
  import path4 from "path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thoth-agents",
3
- "version": "0.1.11",
3
+ "version": "0.1.16",
4
4
  "description": "Delegate-first OpenCode plugin with seven agents, thoth-mem persistence, and bundled SDD skills.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -75,6 +75,11 @@ for `openspec` and `hybrid` modes. thoth-mem topic keys are the memory
75
75
  representation when the mode includes thoth-mem; neither representation changes
76
76
  the harness-neutral artifact names or lifecycle.
77
77
 
78
+ Delegated handoff summaries are not OpenSpec artifacts. They are root-owned
79
+ session summary context when thoth-mem is available, while subagent prompts
80
+ carry recovery instructions and continue to use the canonical OpenSpec paths
81
+ above for filesystem artifact recovery.
82
+
78
83
  ## Writing Rules
79
84
 
80
85
  - Preserve canonical filenames and locations.
@@ -9,8 +9,7 @@
9
9
  | `hybrid` | thoth-mem, then filesystem fallback | thoth-mem and OpenSpec files | The change should survive compaction and exist in the repo |
10
10
  | `none` | orchestrator prompt context only | nowhere (inline response only) | Ephemeral exploration, privacy-sensitive work, or no persistence backend available |
11
11
 
12
- SDD skills MUST obey the selected artifact store mode. Do not reference or rely
13
- on engram.
12
+ SDD skills must obey the selected artifact store mode.
14
13
 
15
14
  ## Mode Rules
16
15
 
@@ -40,72 +39,75 @@ on engram.
40
39
  When running in `hybrid` mode:
41
40
 
42
41
  1. Write the canonical OpenSpec artifact to the filesystem.
43
- 2. Persist the same full artifact to thoth-mem with a deterministic `topic_key`.
42
+ 2. Persist the same full artifact to thoth-mem with deterministic `topic_key`.
44
43
  3. Treat the operation as complete only when both writes succeed.
45
- 4. If filesystem and memory diverge, repair them immediately by rewriting the
46
- stale copy from the freshest full artifact.
44
+ 4. If filesystem and memory diverge, repair immediately from the freshest full
45
+ artifact.
47
46
 
48
47
  ## Memory Ownership
49
48
 
50
- Memory responsibilities are split by semantic role between orchestrator and
51
- sub-agents:
49
+ Memory responsibilities are split by semantic role:
52
50
 
53
- **Orchestrator owns general memory:**
54
- - Decisions, discoveries, bug fixes, session summaries
55
- - Progress checkpoints (SDD task state updates)
56
- - User preferences and configuration notes
51
+ **Orchestrator owns general/root continuity memory:**
52
+ - decisions, discoveries, bug fixes, and user constraints
53
+ - root progress checkpoints and summaries (`mem_session(action="checkpoint"|"summary")`)
54
+ - prompt persistence (`mem_save(kind="prompt")`)
57
55
 
58
- **Sub-agents write deterministic SDD artifacts:**
59
- - Canonical SDD artifacts with topic_key matching `sdd/{change}/{artifact}`
60
- - Includes: proposal, spec, design, tasks, apply-progress, verify-report,
61
- archive-report, state
62
- - Sub-agents persist these directly when the active mode includes thoth-mem
63
- - Sub-agents do NOT write general memory observations
56
+ **Sub-agents write deterministic SDD artifacts when delegated:**
57
+ - canonical SDD artifacts using `sdd/{change}/{artifact}`
58
+ - includes proposal, spec, design, tasks, apply-progress, verify-report,
59
+ archive-report, and state
60
+ - sub-agents may also write delegated durable implementation observations only
61
+ when explicitly authorized under parent session/project
62
+ - sub-agents do not own session lifecycle operations and do not save prompts
64
63
 
65
- This split preserves artifact nuance (sub-agents have full context when writing)
66
- while keeping general memory centralized under orchestrator control. In
67
- harnesses that cannot hard-enforce the split, treat it as instruction-level
68
- governance and disclose any unsupported-capability that prevents compliance.
64
+ In harnesses without hard enforcement, keep this as instruction-level
65
+ governance and disclose unsupported-capability limitations.
66
+
67
+ ## Delegated Handoffs
68
+
69
+ Root/orchestrator handoffs are compaction boundaries. When root-owned summary or
70
+ checkpoint tools are available, root refreshes handoff continuity with
71
+ `mem_session(action="checkpoint"|"summary")` or root-owned
72
+ `mem_save(kind="session_summary")`.
73
+
74
+ Initial subagent prompts include task instructions, parent `session_id`,
75
+ project, persistence mode, memory permissions, and recovery instructions. They
76
+ must not include raw handoff bodies, transcripts, secrets, or generated prompts.
77
+ Subagents recover context through bounded recall before using memory as source
78
+ material.
79
+
80
+ If parent identity or root summary/checkpoint tooling is unavailable, report
81
+ that compaction could not be persisted and continue with explicit local context.
82
+ Subagents must not create fallback sessions.
69
83
 
70
84
  ## Retrieval Protocol
71
85
 
72
86
  ### 3-Layer Recall for thoth-mem and hybrid modes
73
87
 
74
- Always complete the full 3-layer recall before using content as source material:
75
-
76
- 1. **Layer 1 (Compact Index):** call the memory tool binding for `mem_search`
77
- with compact mode to scan observation IDs and titles. This is the most
78
- token-efficient entry point.
79
- 2. **Layer 2 (Timeline Context):** call the memory tool binding for
80
- `mem_timeline` to retrieve chronological context (before/after
81
- observations) to disambiguate or verify the correct artifact.
82
- 3. **Layer 3 (Full Body):** call the memory tool binding for
83
- `mem_get_observation` to retrieve the complete artifact body for use as
84
- source material.
88
+ Always complete the full three layers before using memory content as source
89
+ material:
85
90
 
86
- **Mode guidance:**
87
- - Use `mode: "compact"` (default) for most queries; it returns only IDs and
88
- titles.
89
- - Use `mode: "preview"` only when compact results are insufficient to
90
- disambiguate between multiple candidates.
91
+ 1. **Layer 1 (Compact):** `mem_recall(mode="compact")` to scan IDs/titles with
92
+ exact topic-key or focused query terms.
93
+ 2. **Layer 2 (Context):** `mem_recall(mode="context")` to expand the strongest
94
+ hits into retrieved text.
95
+ 3. **Layer 3 (Full):** `mem_get(id=...)` to fetch full content. Use
96
+ `include_timeline=true` when chronology matters.
91
97
 
92
- **Never treat `mem_search` output—compact or preview—as the artifact body.**
93
- Always complete the 3-layer recall before using content as source material.
98
+ Optional fused context: `mem_context(..., recall_query="...")` when one recent
99
+ context view is useful; it does not replace the three-layer recall.
94
100
 
95
101
  ### Mode-specific retrieval
96
102
 
97
- 1. If the mode is `thoth-mem`, apply the 3-layer recall with the exact SDD
98
- topic key.
99
- 2. If the mode is `openspec`, read the canonical OpenSpec path from the
100
- filesystem only.
101
- 3. If the mode is `hybrid`, apply the 3-layer recall with the exact SDD topic
102
- key.
103
- 4. In `hybrid`, if nothing is found in thoth-mem, read the canonical OpenSpec
104
- path from the filesystem.
105
- 5. In `hybrid`, if filesystem recovery succeeds, re-save the artifact to
106
- thoth-mem so the two stores converge again.
107
- 6. If the mode is `none`, read artifacts from the orchestrator prompt context
108
- only. Do not attempt to retrieve from thoth-mem or filesystem.
103
+ 1. If mode is `thoth-mem`, use three-layer recall with exact SDD topic key.
104
+ 2. If mode is `openspec`, read canonical OpenSpec files only.
105
+ 3. If mode is `hybrid`, use three-layer recall first.
106
+ 4. In `hybrid`, if nothing is found in thoth-mem, read canonical OpenSpec
107
+ files as fallback.
108
+ 5. In `hybrid`, if filesystem fallback succeeds, re-save the artifact to
109
+ thoth-mem to converge both stores.
110
+ 6. If mode is `none`, use orchestrator prompt context only.
109
111
 
110
112
  ## Artifact Ownership
111
113
 
@@ -121,42 +123,35 @@ Always complete the 3-layer recall before using content as source material.
121
123
 
122
124
  ## Governance Placement
123
125
 
124
- - The artifact governance validator is **report-only**.
125
- - It runs after `sdd-tasks` produces the canonical checklist and before any
126
- future `sdd-apply` entrypoint consumes the report.
127
- - It does **not** replace `plan-reviewer` or `executing-plans`.
128
- - It does **not** mark task state, enforce execution, or alter review gating.
129
- - Root-session memory and progress checkpoints remain orchestrator-owned;
130
- sub-agents may surface governance findings, but they must stay within the
131
- active artifact store mode and delegate-first boundaries.
126
+ - Artifact governance validator is report-only.
127
+ - It runs after `sdd-tasks` and before any `sdd-apply` entrypoint consumes the
128
+ report.
129
+ - It does not replace `plan-reviewer` or `executing-plans`.
130
+ - Root-session memory/progress ownership remains orchestrator-owned.
132
131
 
133
132
  ## Pipeline Type Impact on Prerequisites
134
133
 
135
- The orchestrator passes `pipeline-type` (`accelerated` or `full`) alongside the
136
- persistence mode. This affects which artifacts each skill requires:
134
+ The orchestrator passes `pipeline-type` (`accelerated` or `full`) alongside
135
+ persistence mode, affecting required artifacts:
137
136
 
138
137
  | Artifact | Full pipeline | Accelerated pipeline |
139
138
  | --- | --- | --- |
140
- | Proposal | Required by all phases | Required by all phases (serves as acceptance reference) |
139
+ | Proposal | Required by all phases | Required by all phases (acceptance reference) |
141
140
  | Spec | Required by design, tasks, apply, verify, archive | Not produced; not required |
142
141
  | Design | Required by tasks, apply, verify, archive | Not produced; not required |
143
142
  | Tasks | Required by apply, verify, archive | Required by apply, verify, archive |
144
143
  | Verify report | Required by archive | Required by archive |
145
144
 
146
- In accelerated pipeline, the proposal serves as the acceptance reference where
147
- specs would normally be used. Skills must adapt their retrieval, compliance
148
- checks, and archive behavior accordingly.
145
+ In accelerated mode, proposal is the acceptance reference and must preserve
146
+ original intent, accepted scope, deferred areas, and justified exclusions.
149
147
 
150
148
  ## Recovery Notes
151
149
 
152
- - Prefer exact topic-key queries over fuzzy natural-language search.
153
- - Always use the 3-layer recall (`mem_search` `mem_timeline`
154
- `mem_get_observation`) before treating an artifact as source material.
155
- - If multiple observations match in `mem_search`, use `mem_timeline` to inspect
156
- chronological context and disambiguate.
157
- - In `openspec` mode, repair missing or stale artifacts by rewriting the
158
- canonical OpenSpec file only.
159
- - In `thoth-mem` mode, repair missing or stale artifacts by re-saving the full
160
- artifact to thoth-mem only.
161
- - In `hybrid` mode, use the filesystem copy only as fallback or repair input,
162
- then converge both stores.
150
+ - Prefer exact topic-key queries over broad natural-language recall.
151
+ - Always apply the three-layer recall (`mem_recall compact` ->
152
+ `mem_recall context` -> `mem_get`) before treating memory as source material.
153
+ - In `openspec`, repair missing/stale artifacts by rewriting canonical OpenSpec
154
+ files.
155
+ - In `thoth-mem`, repair missing/stale artifacts by re-saving full artifacts via
156
+ `mem_save`.
157
+ - In `hybrid`, use filesystem fallback only for recovery, then converge stores.
@@ -3,18 +3,20 @@
3
3
  ## Harness Scope
4
4
 
5
5
  This convention defines harness-neutral thoth-mem semantics for SDD artifacts.
6
- Tool names are adapter bindings, not universal semantics. Use the thoth-mem
7
- operation names (`mem_search`, `mem_timeline`, `mem_get_observation`,
8
- `mem_save`, `mem_update`) as the portable vocabulary and map them to the
9
- callable tool names exposed by the active binding surface.
6
+ Use the thoth-mem MCP surface as the portable vocabulary:
7
+ `mem_recall`, `mem_save`, `mem_context`, `mem_get`, `mem_project`, and
8
+ `mem_session`.
10
9
 
11
- If a needed thoth-mem operation is not available, treat it as an
12
- unsupported-capability, disclose the limitation, and do not pretend
13
- persistence or recovery succeeded.
10
+ If a needed operation is unavailable in the active runtime, report the
11
+ unsupported capability and do not pretend persistence/recovery succeeded.
14
12
 
15
13
  Governance that a harness cannot hard-enforce remains instruction-level:
16
- semantic role ownership, parent session/project scoping, prompt-save
17
- prohibitions, and SDD topic-key namespace protection still apply.
14
+ role ownership, parent session/project scoping, prompt-save prohibitions, and
15
+ SDD namespace protection.
16
+
17
+ Root-owned delegation handoffs follow the same rule: handoff bodies stay in
18
+ root-owned summary/checkpoint memory when available; subagent prompts carry only
19
+ task instructions plus parent-scoped recovery instructions.
18
20
 
19
21
  ## Mode Scope
20
22
 
@@ -22,13 +24,12 @@ This convention applies only when the artifact store mode includes thoth-mem:
22
24
  `thoth-mem` and `hybrid`.
23
25
 
24
26
  - In `openspec` mode, skip thoth-mem saves.
25
- - In `openspec` mode, skip thoth-mem recovery and use filesystem artifacts
26
- instead.
27
+ - In `openspec` mode, skip thoth-mem recovery and use filesystem artifacts.
27
28
 
28
29
  ## Tool Names
29
30
 
30
- Use the thoth-mem operation names through the active binding surface. Prefer
31
- the callable names actually exposed by the runtime.
31
+ Use callable names exposed by the active runtime, mapped to the six-tool MCP
32
+ surface above.
32
33
 
33
34
  ## Topic Key Format
34
35
 
@@ -74,51 +75,47 @@ artifacts:
74
75
  last_updated: {ISO 8601 timestamp}
75
76
  ```
76
77
 
77
- Save with the memory tool binding for `mem_save`, using the canonical SDD
78
- topic key and the required metadata fields:
78
+ Persist with `mem_save` using canonical SDD topic keys and required metadata:
79
79
  `title`, `topic_key`, `type`, `project`, `scope`, and `content`.
80
80
 
81
- Recovery: `mem_search("sdd/{change-name}/state")` using the active binding
82
- surface → `mem_timeline(id)` when needed for chronology →
83
- `mem_get_observation(id)` parse YAML → restore phase state.
81
+ Recovery path for state artifacts:
82
+ `mem_recall(mode="compact", query="topic_key:sdd/{change-name}/state")` ->
83
+ `mem_recall(mode="context", query="topic_key:sdd/{change-name}/state")` when needed ->
84
+ `mem_get(id=...)` (or `include_timeline=true` when chronology matters) ->
85
+ parse YAML -> restore phase state.
84
86
 
85
87
  ## Three-Layer Recall Protocol
86
88
 
87
- 1. **Scan compact index** by exact topic key:
88
-
89
- Use the memory tool binding for `mem_search` with
90
- `query: "topic_key:sdd/{change-name}/{artifact}"`, `project`, and
91
- `mode: "compact"`.
89
+ For delegated handoffs, subagents may use recall only when dispatch includes
90
+ both parent `session_id` and `project`.
92
91
 
93
- Use `mode: "compact"` (the default) for token efficiency. Switch to `mode: "preview"`
94
- only when compact results are insufficient to disambiguate between multiple results.
92
+ 1. **Compact scan**
95
93
 
96
- 2. **Get chronological context** around the found observation:
94
+ `mem_recall(mode="compact")` with exact topic-key query for token-efficient IDs
95
+ and ranking.
97
96
 
98
- Use the memory tool binding for `mem_timeline` with `observation_id`,
99
- `before`, and `after`.
97
+ 2. **Context expansion**
100
98
 
101
- This shows related observations in the same session, helping you understand the
102
- artifact's evolution and dependencies.
99
+ `mem_recall(mode="context")` to expand strongest hits into retrieved text.
103
100
 
104
- 3. **Retrieve full artifact content**:
101
+ 3. **Full body fetch**
105
102
 
106
- Use the memory tool binding for `mem_get_observation` with the observation ID.
103
+ `mem_get(id=...)` to retrieve full artifact content. Use
104
+ `include_timeline=true` when chronology matters.
107
105
 
108
- Search returns compact results (IDs + titles) by default. Neither compact nor
109
- preview mode returns the full artifact body. Always complete the 3-layer recall
110
- to get the actual content.
106
+ Optional: `mem_context(..., recall_query="...")` can provide fused recent
107
+ context, but it does not replace the three-layer recall.
111
108
 
112
109
  ## Save Contract
113
110
 
114
- **CRITICAL:** The orchestrator MUST persist the state artifact after each SDD
115
- phase transition. This is the canonical checkpoint for resume/recovery.
116
-
117
- Persist SDD artifacts with a stable topic key so repeated saves upsert instead
118
- of creating duplicates:
111
+ **CRITICAL:** The orchestrator must persist the `state` artifact after each SDD
112
+ phase transition for recovery.
119
113
 
120
- Use the memory tool binding for `mem_save` with the canonical SDD topic key
121
- and the full artifact markdown in `content`.
114
+ Persist SDD artifacts with stable deterministic topic keys so repeated saves
115
+ upsert instead of duplicating. For `sdd-apply`, save `apply-progress` and
116
+ re-save updated `tasks` after checkbox changes.
122
117
 
123
- For `sdd-apply`, save the progress report under `apply-progress` and re-save the
124
- updated task list under `tasks` after checkboxes change.
118
+ Write-capable subagents may call `mem_save` only when dispatch explicitly
119
+ permits delegated durable implementation observations or deterministic SDD
120
+ artifact writes under parent session/project. General observations stay outside
121
+ `sdd/*`; deterministic SDD artifacts keep `sdd/{change-name}/{artifact}`.
@@ -72,8 +72,8 @@ The orchestrator owns task progress tracking.
72
72
  - `openspec`/`hybrid`: scan `openspec/changes/` for active changes and read
73
73
  `tasks.md`.
74
74
  - `thoth-mem`: recover tasks via 3-layer recall
75
- (`search` `timeline` → `get_observation`) using topic key
76
- `sdd/{change-name}/tasks`.
75
+ (`mem_recall(mode="compact")` -> `mem_recall(mode="context")` ->
76
+ `mem_get(id=...)`) using topic key `sdd/{change-name}/tasks`.
77
77
  3. Find the first unchecked task in state `- [ ]` or `- [~]`.
78
78
  4. Build a mental model of the plan: total tasks, remaining work,
79
79
  parallelizable work, and dependency order.
@@ -121,6 +121,9 @@ Every dispatch prompt MUST include these 6 parts:
121
121
  5. `VERIFICATION` — checks the sub-agent must run or report
122
122
  6. `RETURN ENVELOPE` — the exact structured response contract in this skill
123
123
 
124
+ `BOUNDARIES` must not contradict accepted proposal or spec scope. Use it to
125
+ limit the current assigned task, not to redefine the approved change scope.
126
+
124
127
  #### C. Receive and Verify
125
128
 
126
129
  Read the sub-agent return envelope and respond by status:
@@ -171,6 +174,8 @@ Between every task or same-agent batch:
171
174
  missing evidence called out.
172
175
  - Attempt 2: switch to a different agent or fix directly when appropriate.
173
176
  - Attempt 3: make one final targeted attempt with narrowed scope.
177
+ - "Narrowed scope" means a narrower recovery attempt for the assigned task
178
+ only. It must not redefine accepted proposal or spec scope for the change.
174
179
  - After 3 consecutive failures, mark the task `- [-]` with a clear reason and
175
180
  escalate to the user.
176
181
 
@@ -229,7 +234,8 @@ To resume safely:
229
234
  - `openspec`: read `openspec/changes/{change-name}/tasks.md`.
230
235
  - `thoth-mem`: recover `sdd/{change-name}/tasks` and
231
236
  `sdd/{change-name}/apply-progress` via 3-layer recall
232
- (`search` `timeline` → `get_observation`).
237
+ (`mem_recall(mode="compact")` -> `mem_recall(mode="context")` ->
238
+ `mem_get(id=...)`).
233
239
  - `hybrid`: do both recovery paths and prefer thoth-mem as the source of
234
240
  truth if state diverges.
235
241
  3. Resume from the first task marked `- [ ]` or `- [~]`.
@@ -67,6 +67,13 @@ Check only what affects executability:
67
67
  - `Expected:`
68
68
  6. Dependency order is valid.
69
69
  7. The sequence is workable without hidden prerequisite steps.
70
+ 8. In-scope success criteria from the accepted proposal/spec are represented by
71
+ executable tasks.
72
+ 9. Deferred or unresolved affected areas from the accepted proposal/spec have
73
+ required discovery, coordination, follow-up tasks, or an explicit execution
74
+ warning.
75
+ 10. Task boundaries or non-goals do not contradict accepted proposal/spec
76
+ scope.
70
77
 
71
78
  ## Decision Rules
72
79
 
@@ -106,6 +113,7 @@ For each rejected issue, include:
106
113
  - No nitpicking.
107
114
  - No style opinions.
108
115
  - No design questioning.
116
+ - No architecture redesign.
109
117
  - No expanding the scope of review beyond blockers.
110
118
  - Do not return more than 3 rejection issues.
111
119