Skip to content

feat(orchestrator): single-writer auto shape for konductor - #144

Draft
knihit wants to merge 62 commits into
feat/house-rules-precedencefrom
feat/single-writer-auto
Draft

knihit wants to merge 62 commits into
feat/house-rules-precedencefrom
feat/single-writer-auto

Conversation

@knihit

@knihit knihit commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Description

Stack: 7 of 12 in the orchestration stack. Base: feat/house-rules-precedence (#136). Depends on everything below it; it reuses #135's Review ceilings item 6 unchanged and carries copies of #114, #123 and #136 rules into its new context file. The orchestration mode PRs build on this.

konductor moves from a dispatcher that never writes to a single writer: it does the work itself and spawns one fresh k-* reviewer at each phase gate. It spawns a specialist to do work only for a tool or access it lacks, a skill or SOP it cannot load, or independent parts on disjoint files. The mux and cmux orchestrators stay coordinators.

Context:

  • New context/k-direct-work.md, loaded by konductor instead of k-orchestrator-routing-rules.md. It holds the direct-work rules: the delegation exemption, which specialist skills to load (a skill is never a reason to delegate), reviewer identity, brief and output, the SOP check split by request type with an 8-row SOP table, the document-phase rule, denial handling, memory and Ruling: relay, and the secrets rule. In auto, a document-only phase gets a gate review only when the user asks, an SOP names one, or a later phase implements it; otherwise the checker-skill pass under Review ceilings closes it.
  • context/k-core-rules.md: one secrets rule for all agents (never read secret files unless the user names one; then report key names or redacted values only); whoever wrote the code runs the tests; a quoted user decision in a brief approves only the action it names.
  • context/k-orchestrator-routing-rules.md: one review-timing sentence for the coordinator shape.

Agents:

  • konductor: rule 1 drops the no-write sentence and the dispatcher label; the rest of the prompt is mode-neutral, so it holds whichever context file is loaded. Rule 4 adds a USER DECISIONS IN FORCE line inside CONTEXT. Edit tool on Claude Code; five specialist skills added to both skill lists. Item 6 is unchanged.
  • konductor-mux-orchestrator, konductor-cmux-orchestrator: a per-phase role line that defers to their Verification Protocol, the consent field in rule 4, and the exemption and triage sentences.

Skills:

  • constraints, delegation-protocol (Phase Review and the brief field) and claude-teams-behavior: matching wording; review timing defers to each orchestrator's Verification Protocol.

Docs:

  • README, user guide (agents, concepts, FAQ, glossary, quick start, reference, skills, troubleshooting, contributing, planning SOPs, plan and verify work) and both HTML bundles describe the single-writer shape and list konductor's 18 skills. html_sop_edits.py and sync-html-content.py carry the bundle edits.
  • CHANGELOG.md: three [Unreleased] bullets. No VERSION change.

Tests:

  • tests/test_konductor_prompt_mode_neutral.py: the konductor prompt holds no shape-bound phrase.
  • tests/test_direct_work_sop_table.py, tests/test_direct_work_brief_parity.py, tests/test_direct_work_memory_provenance.py: the SOP table and the copied brief and memory paragraphs stay in step with their sources.
  • tests/test_html_bundle_sync_edits.py: fails when an HTML sync edit no longer matches the bundles.

Type of Change

  • New or updated agent spec
  • Modify existing skill
  • Context / system prompt update
  • Documentation

Testing

  • npm test: not run (no JS changed).
  • cd cli && make test passes (no cli/ change)
  • Gate on this branch's head, and on the top of the stack (feat/strip-spawn-v2-specialists, which contains it): make build && make synth, cd cli && make test (1,873 Rust tests on the top, 0 failed), make test-skills-sh, uvx --with pyyaml pytest -q tests/ (281 passed, 1 skipped on the top), make claude-plugin-check. All pass.
  • npm run benchmark: not run on this branch. The design's evidence is an earlier A/B of the same shape as a prompt variant: the single-writer variant cost less than the dispatcher in 7 of 8 case pairs, with disjoint ranges, and was never clearly worse on quality. A re-measure of the shipped branch is planned.
  • New Python test files carry the SPDX header on line 1.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own changes
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added or updated tests that prove my change works

Agents Affected

  • konductor (single-writer shape)
  • konductor-mux-orchestrator (role line and rule 4 consent field)
  • konductor-cmux-orchestrator (role line and rule 4 consent field)
  • every specialist (core rules: shared secrets rule, tests rule, scoped user decisions)

Notes for Reviewers

  • Review: adversarial review in rounds until 0 CRITICAL and 0 IMPORTANT findings remained (5 rounds), plus four review rounds on the design. IMPORTANT findings fixed along the way: konductor on Kiro CLI could not load most specialist skills its rules told it to load (it now spawns the owner); the document-phase exemption contradicted "every phase gets a review" (now a checker-skill pass under Review ceilings); direct HTML bundle edits broke the guide build (now sync edits, with a test); and a fourth copy of the memory provenance paragraph was unpinned (now pinned). Every finding has a fix commit.
  • On Kiro CLI, konductor trusts only fs_read; every write and shell command prompts.
  • The coordinator shape for konductor comes from the next PRs (orchestration.mode and its session-start hook), not from a second agent.

Nihit Kasabwala added 30 commits October 30, 2026 00:37
konductor stops loading the routing rules and loads a new
context/k-direct-work.md: it does the work itself, loads the specialist
skills it needs (a skill is never a reason to delegate), and spawns one
fresh reviewer at each phase gate. It spawns a specialist to do work only
for a tool or access it lacks or for independent parts on disjoint files.
In auto, a document-only phase gets a gate review only when the user asks,
an SOP names one, or a later phase of the task implements it.

- konductor spec: rule 1 drops the no-write sentence and DISPATCHER label;
  rules 2, 4 and 5, Routing, the 2-Strike paragraph, the SDLC sentence and
  Verification Protocol items 1 to 5 are mode-neutral; item 6 unchanged.
  Rule 4 adds the USER DECISIONS IN FORCE line in CONTEXT. Self-Check
  drops the two stale lines. Edit tool on Claude; five specialist skills
  added to both skill lists; contextNames swaps to k-direct-work.md.
- k-direct-work.md: P4 block plus the delegation exemption, specialist
  skills, reviewer identity and output, reviewer brief, SOP check split by
  request type with an 8-row SOP table, document-phase rule, denial,
  memory/Ruling relay and secrets sentences.
- mux and cmux stay coordinators: per-phase role bullet, rule 4 consent
  field, exemption and triage sentences in items 1 and 2.
- Routing rules: one review-timing sentence for the coordinator shape.
- constraints rule 3 and quality gate, delegation-protocol Phase Review
  (threat-modeling, triage, CRITICAL only) and brief field,
  claude-teams-behavior pointer.
- README, concepts, faq and troubleshooting paragraphs; one CHANGELOG
  bullet. VERSION unchanged per the recorded user decision in the
  approved design (releases come from a separate version PR).

Verified:
- JSON parses for all three specs; konductor prompt has no DISPATCHER,
  "You do NOT write", "routing rules" or Orchestrator Direct Work; mux and
  cmux Verification Protocol identical; item 6 and rule 4 identical across
  all three; SOP table names and counts match the trigger table (8 rows).
- grep: no k-orchestrator-routing-rules in konductor spec; no
  `threat-model` backtick name in skills/, agents/, context/; no em or en
  dashes in added text (the welcome message's unchanged workflow list
  keeps its existing ones).
- make build && make synth: pass, 11 agents, 82 skills, 19 SOPs, 3
  context files; dist/claude/agents/konductor.md has
  <Context: k-direct-work.md> and not the routing rules;
  dist/kiro-v3/agents/konductor.json loads file://context/k-direct-work.md.
- cargo test (cli/konductor-rs): 1787 passed, 0 failed, 12 binaries.
- make test-skills-sh: 10 passed, 0 failed.
- make test-py (pytest via uv, none installed locally): 224 passed.
- make kiro-power-check (via uv): pass, shellcheck skipped.
- make claude-plugin-check: pass.
…-only text

Address the S1 review:
- Triage sentence (konductor item 3, mux/cmux item 2, delegation-protocol
  Phase Review step 3) now reworks CRITICAL and IMPORTANT findings that
  survive triage, and lists only rejected findings and SUGGESTIONs.
- claude-teams-behavior: the read-only Bash clause applies under
  k-orchestrator-routing-rules.md; under k-direct-work.md konductor writes
  and commits itself. State-changing commands stay with a write agent only
  once a write is handed to it.
- k-direct-work.md document-phase rule: apply the checker skill, fix what
  it finds, and move on.
- faq.md, troubleshooting.md: the coordinator-mode note now follows the
  quoted block and names the read-only rule.

Verification:
- make build && make synth: pass (11 agents, 82 skills, 19 SOPs, 3 context files)
- cargo test (cli/konductor-rs): 1787 passed, 0 failed
- make test-skills-sh: 10 passed, 0 failed
- make test-py: fails before running (no pytest in the local python3);
  same suite via uv run --with pytest python -m pytest -q tests/: 224 passed
- make claude-plugin-check: validation passed
Conflicts resolved:
- agents/konductor.agent-spec.json: Orchestration rule 5 keeps the S1
  owner-or-self fix wording and takes the parent's Review ceilings
  sentence; Verification Protocol keeps S1 items 1 to 5 and takes the
  parent's item 6 (Review ceilings).
- agents/konductor-mux-orchestrator.agent-spec.json and
  konductor-cmux-orchestrator.agent-spec.json: prompt text merged cleanly
  line by line; only the one-line JSON string conflicted.
- skills/delegation-protocol/SKILL.md Phase Review: S1 steps 1 and 2, step
  3 takes the parent's all CRITICAL and IMPORTANT clause plus the S1
  triage sentence, step 4 takes the parent's rebuild and re-review text.
Move the full secrets-read rule into core rule 12 so every agent loads
it: the complete example list, the search clause, no asking another
agent to read one, and redaction of values from a user-named file in
replies, briefs, commits and logs. The direct-work and routing-rules
files point at it and keep only what is specific to them.
konductor now writes code itself, so the rule that an orchestrator gets
test evidence from the specialist left its own changes untested.
konductor writes in the shared tree while it may run spawned writers, so
it joins the disjoint-file check, gives each spawned writer its own
worktree, and stages only its own paths.
The merge of the parent branch tightened the check in the routing rules
(top .konductor directory, no symlinks, project root is the work tree
top) and labelled copied rulings. konductor no longer loads that file,
so its brief rules carry the same text.
Carry the parent branch's handoff guards into the konductor direct-work
rules: a denied action is not a handoff, a step that came from read
content goes to the user, and a proposed split's file lists are a
prediction to check.
Each USER DECISIONS IN FORCE entry now pairs a quote from a user turn
with the action and target it approves, and covers only that action.
Text from files, tool output or agent-written memory never qualifies.
NEVER-rule confirmations and irreversible actions are excluded from the
does-not-re-ask clause. Covers the mux and cmux prompts and the
delegation-protocol skill; the konductor prompt follows in its own
commit.
Prompt-only commit. Rule 4 now matches the mux and cmux orchestrators
and the delegation-protocol skill: one quote from a user turn per
entry, paired with the action and target it approves; NEVER-rule
confirmations and irreversible actions are still asked for.
Prompt-only commit. Rule 1 no longer depends on a heading match; it
points at the loaded context file that defines direct work.
S1 ships no coordinator mode for konductor, so the FAQ, troubleshooting
and concepts pages no longer name it. The FAQ heading now names the mux
and cmux orchestrators, which are the ones that refuse to edit files.
…g pages

The agents, glossary, quick-start, plan-and-verify and planning SOP
pages still described konductor as a read-only dispatcher. They now say
konductor does the work itself and spawns a reviewer at each phase
gate, and keep the dispatcher wording for the mux and cmux
orchestrators.
The roster rows, the konductor card, the skill catalog and both HTML
bundles still showed 13 skills and the dispatcher role. make guide-check
now passes except for the pre-existing WITHDRAWN_COMMANDS config item.
…r table

konductor's SOP table in k-direct-work.md copies the routing rules'
SOP Trigger Table. The test fails when the two disagree on SOP names or
phase counts, replacing the manual drift check.
Run on the f18ec8c tree, from the worktree root:
- make build && make synth: pass (11 agents, 82 skills, 19 SOPs, 3
  context files)
- cd cli && make test: pass, 1789 passed, 0 failed
- make test-skills-sh: pass, 10 passed, 0 failed
- uvx --with pyyaml pytest -q tests/: 227 passed (adds
  test_direct_work_sop_table.py)
- make claude-plugin-check: validation passed
- make guide-check: one failure, the WITHDRAWN_COMMANDS config item
  that also fails on the parent branches
The quick-start said konductor runs each k-full-sdlc phase itself. Once
the user types the command the SOP governs, and it runs every phase in
a specialist subagent, as sop-workflows/orchestration.md already says.
The page is not in either HTML bundle.
reference.md and contributing.md said all three orchestrators load the
routing rules, and the concepts diagram fed routing rules into a
read-only konductor. Scope the routing rules to mux and cmux, add the
k-direct-work.md row, and relabel the diagram. The same passages are
patched in both HTML bundles. make guide-check passes except for the
pre-existing WITHDRAWN_COMMANDS config item.
Run on the b4aaa3e tree (fixes for review blockers B1 and B2):
- make build && make synth: pass (11 agents, 82 skills, 19 SOPs, 3 context files)
- cd cli && make test: 1789 passed, 0 failed
- make test-skills-sh: 10 passed, 0 failed
- uvx --with pyyaml pytest -q tests/: 227 passed
- make claude-plugin-check: validation passed
- make guide-check: 1 failure, the pre-existing WITHDRAWN_COMMANDS config
  item that also fails on the parent branches
The caption under the diagram now matches the bundles, and steps 2, 3
and 5 describe direct work, spawning only for a missing tool or
parallel disjoint work, and a fresh k-* reviewer at each phase gate.
The IoT example above it gets an SOP name, so the checkpoint now names
a one-module bug fix as the request where konductor works itself.
Run on the 07a9ede tree, from the worktree root:
- make build && make synth: pass (11 agents, 82 skills, 19 SOPs, 3 context files)
- cd cli && make test: 1789 passed, 0 failed
- make test-skills-sh: 10 passed, 0 failed
- uvx --with pyyaml pytest -q tests/: 227 passed
- make claude-plugin-check: validation passed
- make guide-check: 1 failure, the pre-existing config entry in
  WITHDRAWN_COMMANDS, which also fails on the parent branches

The two HTML bundles stay byte-identical (cmp).
Conflicts:
- context/k-core-rules.md rule 11: kept this branch's rules 11 and 12 with the parent's git ls-files ':(icase).konductor' check.
- docs/index.html, docs/site/user-guide.html: kept this branch's bundles and applied the parent's one change (the review fix round sentence) by exact replacement. sync-html-content.py already reported unmatched targets on this branch before the merge, so it was not used to rebuild them.
…d check

Same check as the core and routing rules: a committed .Konductor/ opens as .konductor/
on case-insensitive filesystems but git ls-files .konductor prints nothing.
"Fix what the reviewer finds, re-review only the change" narrowed the re-review to the
change and pulled SUGGESTIONs into the fix, against the Verification Protocol's Review
ceilings.
concepts.md step 5 and the matching FITS string in both HTML bundles (kept byte-identical).
…at acts on them

The USER DECISIONS IN FORCE limits lived only in the delegation-protocol skill and the
orchestrator prompts, which no specialist loads. The core rules now tell a specialist that
an entry covers only the action and target it names and never replaces a NEVER-rule
confirmation or an irreversible action.
…nd round

"Before any second round" could be read as allowing a second fix round, which Review
ceilings rules out, or as skipping triage before the first fix.
…ication Protocol

Their protocol still reviews after code changes, each design artifact and each document;
the once-per-phase review is konductor's.
Nihit Kasabwala added 29 commits October 30, 2026 10:52
konductor's direct-work copy of the handoff rule lacked the parent's
resume path and split briefs, so an SOP interrupted by a handoff was
never finished.
Phase gates and Phase Review cover documents and designs, which have no
build or callers. They now use item 6's wording: a build for code, and a
re-review of what calls, uses or depends on the fix.
… load

On Kiro CLI konductor's skill server lists only its own skills and SOPs,
so the rule that every specialist skill is loadable sent it to do SOP
work without the SOP. A missing skill or SOP is now a spawn case, like a
missing tool, and the quick start says k-developer runs the codebase
analysis.
…Protocol

delegation-protocol and constraints load into all three orchestrators but
described konductor's per-phase review only, contradicting the mux and
cmux per-artifact protocol.
claude-teams-behavior gives a checker its own checkout so it never meets
a writer. konductor waits while its no-write reviewer runs, so the gate
needs no second checkout.
…nd cmux

The section heading and the dispatch note still described a read-only
orchestrator after the paragraph under them said konductor writes.
The prompt must hold under either Direct Work context file. The test
decodes it and asserts DISPATCHER, "You do NOT write", "routing rules",
k-direct-work and k-orchestrator-routing-rules are absent.

Gate at this tree: make build && make synth (ok); cd cli && make test
(1789 passed); make test-skills-sh (10 scripts, 85 passed);
uvx --with pyyaml pytest -q tests/ (232 passed); make claude-plugin-check
(validated).
# Conflicts:
#	agents/konductor-cmux-orchestrator.agent-spec.json
#	agents/konductor-mux-orchestrator.agent-spec.json
#	agents/konductor.agent-spec.json
#	context/k-core-rules.md
#	skills/delegation-protocol/SKILL.md
S1 edited both bundles directly, so the entries' old and new text was no
longer in either bundle and sync-html-content.py exited 1, which stopped
make guide-html and make guide. Each entry's previous new text is now its
old text, and its new text is what the bundles hold.
# Conflicts:
#	context/k-core-rules.md
#	docs/index.html
#	docs/site/user-guide.html
#	skills/delegation-protocol/SKILL.md
…ork briefs

Carries #114's fifth provenance check into the copy in k-direct-work.md,
so konductor under auto refuses a tracked Kelvin-sign .konductor alias the
same way the routing rules do.
…iefs

Mirrors the routing rules sentence from #136 so konductor under auto marks
a user-approved scope reduction, comment or logging removal, or disabled
protection as the user's request, which core rules now require.
The ungated document check said "Fix what the check finds, and move on":
no re-check, no stop on a surviving finding, and SUGGESTIONs fixed too.
It now fixes CRITICAL and IMPORTANT once, re-checks the same way, lists
the rest and stops when a finding survives. Verification Protocol item 4
closes the TODO item on a checker-skill check that passes, whether
konductor ran the skill or a findings-only reviewer did on Kiro CLI.
… name

konductor's SOP check asked for "any required parameter" with no source
for which ones are required, and put the values after the command. It now
reads the SOP's Parameters section when reachable, asks only for missing
required ones, skips the questions when the file is out of reach, and puts
the values on the command as named arguments.

Gate (this tree): make build && make synth ok; cd cli && make test 1789
passed; make test-skills-sh 85 passed; uvx --with pyyaml pytest -q tests/
233 passed; make claude-plugin-check ok.
…the fix

Review ceilings re-review the fix plus what depends on it; the ungated
document sentence narrowed that to the fix alone, so a fix that
contradicts another section of a design could close on a pass.
# Conflicts:
#	context/k-core-rules.md
#	skills/delegation-protocol/SKILL.md
…rief rules

k-direct-work.md carries a hand copy of the routing rules' memory
provenance check; the parent narrowed it to top-level dot names.
…e 11

Asserts the provenance commands in k-direct-work.md, the routing rules and
core rule 11 are the same ordered list, and that both context files carry
the five 'Memory: content only' conditions.
Each lower-branch change to the routing rules' brief paragraph needed a
hand-copied commit on this branch. The test compares the two paragraphs
sentence by sentence, apart from the sentences each side words itself.
Brings PR 1 (project memory is project content) up from #136.

Conflicts:
- context/k-core-rules.md: #136's rule 11 (PR 1 text plus the House rules
  clause), then this branch's rule 12.
- docs/index.html, docs/site/user-guide.html (single-line bundles): this
  branch's bundles plus PR 1's one FAQ insertion.

Merge-up edits (intentional removal of the fourth copy of the check):
- context/k-direct-work.md Briefs paragraph drops the memory provenance
  check and memory line, and takes the routing rules' wording: "Copy each
  Ruling: entry from the project's memory into the brief ...".
- tests/test_direct_work_memory_provenance.py removed: it pinned the check
  text that is gone. tests/test_memory_rule_text.py now covers
  k-direct-work.md having none of it.
- tests/test_direct_work_brief_parity.py pins the new paragraph against the
  routing rules.

Gate: make build && make synth ok; cli make test 1789 passed, 0 failed;
make test-skills-sh 10 passed; pytest 260 passed, 1 skipped;
make claude-plugin-check ok.
A document-only phase can produce more than one document, so a fix to the
requirements can contradict the design written in the same phase. The
re-check now reads the parts of every document in the phase that depend on
the fix, as the gate re-review already does.

Doc-only; the gate runs on this branch's head.
Brings #124's and #136's round 5 fixes up. No conflicts.

Merge-up edit: context/k-direct-work.md Briefs paragraph takes #136's
HR5-1 wording from the routing rules (keep the silent-scope line when the
user approved a reduction), so the hand copy still matches; the parity
test pins it.

Gate: make build && make synth ok; cli make test 1789 passed, 0 failed;
make test-skills-sh 10 passed; pytest 260 passed, 1 skipped;
make claude-plugin-check ok.
# Conflicts:
#	docs/index.html
#	docs/site/user-guide.html
@knihit
knihit added this pull request to stack #150 October 31, 2026 23:37

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant