ytdb-slate 0.1.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # ytdb-slate
2
+
3
+ Slate is a thread-weaving orchestration extension for the [pi coding agent](https://github.com/earendil-works/pi-coding-agent).
4
+
5
+ The orchestrator (your main pi session) dispatches **bounded actions** to persistent **worker threads**. Each completed action is compressed by an LLM into an **episode** — a durable, structured record (intent, actions, findings, artifacts, open issues, handoff notes) that the orchestrator composes into further dispatches instead of re-reading raw transcripts. On top of that, Slate injects a mandatory workflow doctrine: research before design, design review, adversarial review, and track review — with optional umbrella **draft-PR publishing** for tracks.
6
+
7
+ ## Install
8
+
9
+ Install into a project (pinned, project-scoped — recorded in `.pi/settings.json`):
10
+
11
+ ```bash
12
+ pi install -l npm:ytdb-slate@<version>
13
+ ```
14
+
15
+ > **Note on pinning:** pinned specs (`@<version>`) are deliberately skipped by `pi update --extensions` / `pi update --all`. Bumping the pin is a conscious project change — review Slate's shipped workflow docs for changes when you do.
16
+
17
+ ## Configuration
18
+
19
+ Optional config file: `slate.json` in the project's pi config dir (`.pi/slate.json`). It is honored **only in trusted projects** (see [Trust](#trust)).
20
+
21
+ | Key | Type | Default | Semantics |
22
+ | --- | --- | --- | --- |
23
+ | `orchestratorModeDefault` | boolean | `false` | Start fresh interactive sessions with orchestrator mode ON. |
24
+ | `episodeModel` | string | newest available Anthropic Sonnet, else the worker's own model | Model (`provider/id`) used to compress a finished action into an episode. |
25
+ | `workerTools` | string[] | `["read", "bash", "edit", "write", "grep", "find", "ls"]` | Tools available to worker threads (an empty list also falls back to the default). |
26
+ | `maxConcurrent` | number | `4` | Maximum number of worker actions running concurrently. |
27
+ | `pauseThresholdPercent` | number | `40` | Orchestrator context budget (percent, in `(0, 100]`) at which Slate auto-pauses and prepares a fresh-session handoff. |
28
+ | `orchestratorPromptDocs` | string[] | `[]` | Project markdown files (paths relative to the project root) whose **contents** are appended to the orchestrator system prompt. |
29
+ | `workerPromptDocs` | string[] | `[]` | Project markdown files whose **contents** are appended to every worker-thread system prompt. |
30
+ | `workflow.draftPRs` | boolean | `false` | Enable umbrella draft-PR publishing for tracks. |
31
+ | `doctrineExtraPath` | string | — | Project markdown whose **content** is appended to the orchestrator doctrine (project-specific workflow additions). |
32
+ | `reviewPerspectivesPath` | string | — | Project review charters, each declaring its own finding-ID prefix. The doctrine references this **path**; the orchestrator reads the file alongside the shipped review rules. |
33
+
34
+ Example `.pi/slate.json` (the `docs/agents/...` paths are placeholders — point them at markdown files that actually exist in **your** project):
35
+
36
+ ```json
37
+ {
38
+ "orchestratorModeDefault": true,
39
+ "episodeModel": "anthropic/claude-sonnet-5",
40
+ "maxConcurrent": 4,
41
+ "pauseThresholdPercent": 40,
42
+ "orchestratorPromptDocs": ["docs/agents/orchestrator-guidelines.md"],
43
+ "workerPromptDocs": ["docs/agents/thread-guidelines.md"],
44
+ "workflow": { "draftPRs": true },
45
+ "doctrineExtraPath": "docs/agents/workflow-additions.md",
46
+ "reviewPerspectivesPath": "docs/agents/review-perspectives.md"
47
+ }
48
+ ```
49
+
50
+ > **Silent skip:** the project-file keys fail silently — no error is shown. For the content-injected keys (`orchestratorPromptDocs`, `workerPromptDocs`, `doctrineExtraPath`) a missing, unreadable, or empty file is skipped and nothing is injected. For `reviewPerspectivesPath` the pointer is omitted only when the file is missing — the file is not read at injection time, so an unreadable or empty file is still cited. Verify your paths after copying the example.
51
+
52
+ ## Trust
53
+
54
+ Slate reads project configuration (`.pi/slate.json`) and injects project files (`orchestratorPromptDocs`, `workerPromptDocs`, `doctrineExtraPath`, `reviewPerspectivesPath`) **only in trusted projects**. In untrusted projects Slate runs with built-in defaults and injects nothing from the working tree.
55
+
56
+ ## Shipped docs
57
+
58
+ In orchestrator mode, Slate appends a short **doctrine** (a block of numbered rules) to the orchestrator's system prompt each turn. The doctrine does not embed the workflow docs — it cites them by **absolute path**, resolved inside the installed package (not your project), and the orchestrator reads them on demand:
59
+
60
+ - `docs/track-workflow.md` — the track-based workflow (research → design review → adversarial review → track review)
61
+ - `docs/pr-publishing.md` — umbrella draft-PR publishing (cited only when `workflow.draftPRs` is `true`)
62
+ - `docs/review-rules.md` — review discipline and finding rules
63
+ - `docs/design-principles.md` — Slate's own design rationale
64
+
65
+ Project-specific additions layer on top — they extend, not replace, the shipped doctrine — via two distinct mechanisms:
66
+
67
+ - **Content injection**: `doctrineExtraPath` (appended to the doctrine itself, re-read at each prompt assembly) and `orchestratorPromptDocs` / `workerPromptDocs` (appended to the respective system prompts).
68
+ - **Pointer**: `reviewPerspectivesPath` is cited by path from the doctrine's review rule and read on demand, like the shipped docs.
69
+
70
+ ## License
71
+
72
+ Apache-2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,183 @@
1
+ # Slate design principles
2
+
3
+ Distilled from the Random Labs technical report introducing the Slate
4
+ architecture ("thread weaving") — the open-beta release write-up of the
5
+ Slate agent (published as the npm package `@randomlabs/slate`); no stable
6
+ URL is recorded, so the distillation here is the in-repo source of truth
7
+ for its content. This document records the reasoning behind the
8
+ extension's design so maintainers — and the orchestrator itself, on
9
+ demand — can check changes and behavior against the original intent.
10
+
11
+ Note: module headers cite ExecPlan decision ids (D3–D9, M1–M3) from the
12
+ original implementation plan, which is not part of this repository. This
13
+ document is the in-repo source for the architecture rationale.
14
+
15
+ ## 1. The problems Slate is built to solve
16
+
17
+ Three compounding problems in LLM agents — each tractable in isolation; the
18
+ difficulty is that they interact:
19
+
20
+ 1. **Long-horizon tasks** — path-dependent tasks whose minimum successful
21
+ step count exceeds what a minimal tool-calling loop can do. Solving them
22
+ requires adequate working memory, a strategy/tactics balance, and the
23
+ ability to integrate information discovered mid-task without losing the
24
+ overall goal.
25
+ 2. **Working memory and the "Dumb Zone"** — models cannot attend uniformly
26
+ across the context window; retrieval quality degrades non-uniformly as
27
+ context grows ("context rot"). The usable prefix is working memory; the
28
+ degraded tail is the Dumb Zone. Context must be managed like scarce RAM.
29
+ 3. **Strategy vs tactics** — strategy is open-ended planning toward the
30
+ goal; tactics are learned local action sequences (run a command, extract
31
+ X from file Y). The AlphaGo/AlphaZero lineage architected this split
32
+ explicitly (value network = positional strategy, policy network = move
33
+ tactics), and probing shows tactical concepts are learned before
34
+ strategic ones. Software engineering spans the whole spectrum — a good
35
+ harness lets the model strategize without drowning in tactical detail.
36
+
37
+ Supporting concepts:
38
+
39
+ - **Knowledge overhang** — knowledge a model holds latently but cannot
40
+ access tactically without scaffolding (plans, chain-of-thought, harness
41
+ structure). Corollary: the bottleneck in long-horizon agentic work is
42
+ context management, not model intelligence.
43
+ - **Expressivity** — a harness is expressive when few output operations can
44
+ reach many end states (a `sed`-only harness can read, write, and search;
45
+ a `file_read`-only harness can never edit). Rigid task graphs lower
46
+ expressivity.
47
+ - **Inductive bias** — models default to interfaces they were trained on.
48
+ The harness builder's job is to make the desired behavior the natural
49
+ behavior.
50
+
51
+ ## 2. Why prior approaches fall short
52
+
53
+ No prior approach solves all of the above simultaneously; each trades one
54
+ or two problems for the others:
55
+
56
+ - **Compaction** (sliding windows, Claude Code compaction, Amp handoffs) —
57
+ non-deterministically lossy: important information can vanish
58
+ unpredictably.
59
+ - **Naive subagents** (Codex/Claude Code) — isolate context well, but
60
+ synchronize by message passing: the parent only gets a response string,
61
+ so information fails to cross the context boundary. Works mainly for
62
+ exploratory search over immutable data.
63
+ - **Markdown plans** — force the model to strategize (tapping the knowledge
64
+ overhang) but go stale. Three failure modes: underspecified plans,
65
+ incomplete execution ("declaring victory early"), and forgetting to
66
+ update the plan when new information arrives.
67
+ - **Direct task decomposition (task trees, gated steps)** — thorough and
68
+ resistant to early stopping, but rigid: adapting to new information means
69
+ rewriting the tree, and unintegrated subtask results get orphaned. Low
70
+ expressivity.
71
+ - **RLM / recursive decomposition** — the right primitives (context by
72
+ reference, natural decomposition through a familiar interface), but
73
+ unbounded recursion needs a guard against over-decomposition, and REPL
74
+ execution yields no intermediate feedback: the model commits to N steps
75
+ blind and only learns the outcome at the end — no course correction in a
76
+ mutating environment.
77
+ - **Strategize–delegate–compress stacks (Devin, Manus, Altera/PIANO)** —
78
+ every compress-and-return boundary risks dropping critical state, and the
79
+ strict planner/executor split adds inertia and reduces reactivity.
80
+ - **ReAct** — maximally reactive and expressive but has no context
81
+ isolation, no compaction story, and no parallelism: the single context
82
+ fills until quality degrades.
83
+
84
+ ## 3. Slate's answer: threads, episodes, thread weaving
85
+
86
+ - **Thread** — a persistent worker that executes ONE bounded action at a
87
+ time, then pauses and hands control back. Threads are general workers
88
+ serving the system's current intent, not purpose-specific personas. A
89
+ thread accumulates context across its actions, acting as a reusable store
90
+ for one work stream.
91
+ - **Episode** — the compressed, structured record of the steps a thread
92
+ took to complete one action: important results retained, tactical trace
93
+ dropped. Episodes — not message passing — are the synchronization
94
+ primitive. Because a bounded action has a natural completion boundary,
95
+ compaction happens at meaningful moments instead of arbitrarily
96
+ mid-stream. This is a tractable form of episodic memory.
97
+ - **Composability** — episodes are inputs: any thread can be initialized
98
+ with prior episodes (from any thread), inheriting conclusions without
99
+ inheriting full context. Context-by-reference routing is what
100
+ distinguishes threads from subagents that return a single string.
101
+ - **Thread weaving** — the orchestrator dispatches, threads execute,
102
+ episodes compose. Decomposition is implicit and adaptive: the
103
+ orchestrator never commits to a static plan, but is forced to externalize
104
+ work as bounded, compressible units. Frequent bounded synchronization
105
+ gives per-episode feedback, so strategy updates mid-task instead of
106
+ failing at the end.
107
+ - **OS framing** — the orchestrator is the kernel; threads are processes;
108
+ episodes are process return values committed into the kernel's working
109
+ memory; the context window is RAM — scarce and actively managed. Each
110
+ thread return is a scheduled opportunity to decide what is retained,
111
+ compressed, or discarded.
112
+
113
+ ## 4. Operating principles
114
+
115
+ - **P1 — One dispatch, one bounded action.** An action is a tactic-sized
116
+ unit: clear, completable, verifiable.
117
+ - **P2 — Episodes are the synchronization primitive.** No back-and-forth
118
+ message passing between orchestrator and workers.
119
+ - **P3 — Compress at completion boundaries.** Compaction is built into the
120
+ action lifecycle, not applied as emergency lossy surgery.
121
+ - **P4 — Compose context by reference.** Pass episode ids, not restated
122
+ content; the episode store stays the source of truth.
123
+ - **P5 — Decompose implicitly and adaptively.** No upfront static plan;
124
+ update strategy after every episode; failed episodes demand adaptation,
125
+ not blind retry.
126
+ - **P6 — Make desired behavior the natural behavior.** In orchestrator
127
+ mode, tactical tools are removed, so delegation is the only way to act.
128
+ - **P7 — Guard against over-decomposition.** Workers cannot spawn threads
129
+ (depth-1); recursion is structurally impossible.
130
+ - **P8 — Per-episode feedback beats blind N-step execution.** Bounded
131
+ actions return before the next decision, so course correction is always
132
+ possible.
133
+ - **P9 — Parallelize independent actions.** Independent work streams run as
134
+ concurrent threads whose episodes are synthesized afterward.
135
+ - **P10 — Treat context as RAM.** Budget it; when the budget is exceeded,
136
+ pause dispatching and hand off to a fresh session rather than degrading
137
+ in the Dumb Zone.
138
+
139
+ ## 5. Where each principle lives in the code
140
+
141
+ | Principle | Implementation |
142
+ |---|---|
143
+ | P1 bounded actions | `tools.ts` `thread` tool contract; doctrine rule 1 in `mode.ts` |
144
+ | P2 episodes as sync | `threads.ts` dispatch lifecycle returns an episode per action |
145
+ | P3 boundary compression | `episodes.ts` episode compression on action completion |
146
+ | P4 context by reference | `tools.ts` `context` parameter injects prior episodes by id |
147
+ | P5 adaptive decomposition | doctrine rule 6 in `mode.ts`; no plan structure imposed anywhere |
148
+ | P6 natural behavior | `mode.ts` `ORCHESTRATOR_TOOLS` restriction (read-only + slate tools) |
149
+ | P7 over-decomposition guard | `worker.ts` recursion guard — workers load no extensions, so the `thread` tool never exists for them |
150
+ | P8 per-episode feedback | `threads.ts` synchronous dispatch; episode returned to orchestrator |
151
+ | P9 parallelism | `threads.ts` `maxConcurrent` queueing; doctrine rule 2 in `mode.ts` |
152
+ | P10 context as RAM | `handoff.ts` context-budget auto-pause + fresh-session handoff |
153
+
154
+ ## 6. Runtime knowledge: what the orchestrator knows, and when
155
+
156
+ The orchestrator's knowledge of these principles is two-tier, following
157
+ the load-on-demand discipline the extension itself prescribes:
158
+
159
+ - **Tier 1 — always loaded.** The doctrine in `mode.ts` is the operational
160
+ distillation of P1–P10, the review discipline defined in
161
+ `review-rules.md`, and a pointer to the track-based workflow protocol
162
+ that ships with this package (`track-workflow.md` in this directory),
163
+ appended to the system prompt every turn while orchestrator mode is
164
+ on. It costs a few hundred tokens and covers everything routine
165
+ dispatching needs.
166
+ - **Tier 2 — on demand.** This document. The doctrine carries a short
167
+ pointer to it (doctrine rule 10); the orchestrator reads it only when
168
+ reasoning about the architecture itself — explaining slate, modifying
169
+ the extension, or making a non-obvious routing/compaction decision.
170
+
171
+ The same discipline applies to consuming-project role guidance:
172
+ `prompt-docs.ts` injects per-role guideline docs (orchestrator via
173
+ `before_agent_start`, workers via `appendSystemPrompt`). Defaults are
174
+ compiled into `prompt-docs.ts`; a consuming project supplies its own
175
+ documents through the optional `slate.json` keys `orchestratorPromptDocs`
176
+ / `workerPromptDocs`. Each role's always-loaded surface carries only its
177
+ own rules; the rest stays on demand.
178
+
179
+ Injecting this full document every turn would be self-defeating: it would
180
+ spend the working memory the architecture exists to protect, and most of
181
+ its content (prior-approach analysis, background concepts) is rationale,
182
+ not operational instruction. Keeping rationale on demand and rules always
183
+ loaded is itself an application of P10.
@@ -0,0 +1,123 @@
1
+ # Draft-PR publishing
2
+
3
+ Umbrella draft PR mechanics for the track-based workflow (see
4
+ track-workflow.md in this directory). This document applies ONLY when
5
+ `workflow.draftPRs` is enabled in the project's `slate.json` (default:
6
+ false). When it is disabled, the workflow creates no PR; the
7
+ workflow-log lifecycle in that mode is owned by track-workflow.md
8
+ § Research log.
9
+
10
+ ## Creation
11
+
12
+ The umbrella draft PR is created once the design has passed the user
13
+ design review and the adversarial review, BEFORE implementation:
14
+
15
+ - Created as a DRAFT, based on the repository's default development
16
+ branch.
17
+ - If the working branch has no diff against the base yet, land a
18
+ bootstrap empty commit so the PR can be created.
19
+ - At creation, the research log's content folds into the PR
20
+ description — Key decisions, Risks, and Open questions feed the
21
+ corresponding Planned-changes subsections, and the design review and
22
+ adversarial review verdict lines land in Risks & accepted
23
+ trade-offs — and the log file is deleted. Decisions made after PR
24
+ creation are appended to the PR description directly.
25
+ - The user approves the description (and the track split — see
26
+ track-workflow.md) before implementation starts.
27
+
28
+ ## Description rules
29
+
30
+ The description follows the repository's PR template, if any, and
31
+ carries three parts: Motivation (why), "Planned changes" (detailed but
32
+ high-level), and "Tracks" (a display table, multi-track changes only).
33
+
34
+ Write Planned changes at a high design level using the MAIN DOMAIN
35
+ ENTITIES from the code — real class and component names. Hard guards:
36
+ no file paths, no method signatures. If a sentence would change when a
37
+ method is renamed, it is too deep.
38
+
39
+ Subsections activate when their content exists:
40
+
41
+ - **Current state** — the before-picture per affected area.
42
+ - **What changes** — the externally observable contract/behavior: API
43
+ surface, semantics, defaults, persisted formats, compatibility,
44
+ concurrency guarantees.
45
+ - **How** — design-level description.
46
+ - **Key decisions** — chosen vs rejected; preempts "why not X?" review
47
+ comments.
48
+ - **Out of scope** — explicit non-goals.
49
+ - **Risks & accepted trade-offs** — including the design review and
50
+ adversarial review verdict lines.
51
+ - **Verification approach** — 1–2 lines.
52
+
53
+ "Deep enough" test: a reviewer who knows the codebase but not this
54
+ change can (1) predict which subsystems the diff touches, (2) evaluate
55
+ each track's diff against a stated intent, and (3) answer "why not
56
+ alternative X" without asking.
57
+
58
+ The description becomes the squash-commit body on the default
59
+ development branch — it is the permanent git-archaeology record for
60
+ the change. Write it accordingly.
61
+
62
+ ## Tracks table
63
+
64
+ The description's Tracks section holds the track table; its
65
+ constraints (display-only, no SHAs, never the source of truth for
66
+ track boundaries) are owned by track-workflow.md § Track table.
67
+ Single-track changes carry an "N/A (single-track)" placeholder instead
68
+ of a table.
69
+
70
+ ## Keeping the PR in sync
71
+
72
+ Keep the title and description synchronized with what is actually
73
+ pushed: update a track's table row when its marker commit lands,
74
+ append post-design decisions as they are made, and revise Planned
75
+ changes whenever reality diverges from it. A stale description fails
76
+ the "deep enough" test.
77
+
78
+ ## Ready-for-review flip
79
+
80
+ The umbrella PR is the ONLY PR this workflow ever merges (squash), and
81
+ the merge is performed BY THE USER — the agent never merges it.
82
+ Flipping the PR to ready-for-review is the agent's last act before
83
+ handing the PR to the user; post-flip fix work and post-merge cleanup
84
+ stay agent duties (below). The flip is gated by this checklist,
85
+ executed in order:
86
+
87
+ - Any layered peer-review process (see track-workflow.md § Peer
88
+ review) is completed or explicitly user-waived — flipping never
89
+ discards a pending review.
90
+ - All commits landed since the last user-approved gate are presented
91
+ to the user.
92
+ - Strip the whole Tracks section from the description, whatever its
93
+ form — the table for multi-track changes or the "N/A (single-track)"
94
+ placeholder — plus any notes under it. Track numbers are ephemeral
95
+ branch-life identifiers: after the squash-merge the marker commits
96
+ are gone, so track references would dangle in the default branch's
97
+ history. The rest of the description — Motivation, Planned changes —
98
+ stays: it becomes the squash-commit body.
99
+ - Update the PR title and description to the final state of the
100
+ change: the title names what was actually delivered — preserving any
101
+ prefixes or markers the project's conventions require — and the
102
+ description, including the Planned changes section, describes the
103
+ change as implemented, folding in everything added, dropped, or
104
+ reshaped since the draft PR was opened.
105
+ - Last, re-read the whole PR description end-to-end to confirm the
106
+ as-flipped text tells one consistent story.
107
+
108
+ ## After the flip
109
+
110
+ The user may wait for CI green and/or peer-review completion and ask
111
+ the agent to fix test failures or review observations. The agent lands
112
+ fixes as normal commits, keeps the description in sync, and presents
113
+ agent-landed commits to the user as they land. Commits pushed directly
114
+ by reviewers are visible in the PR UI; the agent reconciles the
115
+ description with them on its next task. The user's merge act is the
116
+ final approval.
117
+
118
+ ## After the merge
119
+
120
+ Any cleanup a layered peer-review process requires (closing its review
121
+ PRs, deleting its pinned branches) is an agent duty, executed when the
122
+ user reports the merge or a later session detects it, per that
123
+ process's own rules.