reasonweave 0.0.0-stage → 1.3.2
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/AGENTS.md +101 -0
- package/INSTALL.md +258 -0
- package/README.md +280 -2
- package/bin/lab.mjs +888 -0
- package/constitution.md +55 -0
- package/docs/CONSUMER-PROMPTS.md +474 -0
- package/docs/backlogs/01-forward-wait-self-detach.md +18 -0
- package/docs/backlogs/02-decouple-wait-and-daemon-for-agent-hosts.md +35 -0
- package/docs/backlogs/03-baton-wait-multi-id-lightweight-pubsub.md +34 -0
- package/docs/backlogs/04-adr-cross-repo-automated-dispatch-boundary.md +19 -0
- package/docs/backlogs/05-feat-units-worktree-isolation-engine.md +23 -0
- package/docs/backlogs/06-feat-blind-audit-automated-clean-runner.md +22 -0
- package/docs/backlogs/07-feat-attention-throttle-silent-pipe.md +23 -0
- package/docs/backlogs/08-future-units-shadow-ledger.md +22 -0
- package/docs/backlogs/09-feat-agent-baton-core-convergence-and-resilience.md +42 -0
- package/docs/backlogs/10-feat-anti-orphan-deterministic-wiring-governance.md +35 -0
- package/docs/backlogs/11-perf-orphan-index-fs-read.md +16 -0
- package/docs/backlogs/12-feat-vibe-security-anti-suppression-and-orphan-deps.md +43 -0
- package/docs/backlogs/13-feat-sdd-reppit-tiered-guardrails.md +40 -0
- package/docs/backlogs/14-feat-universal-cli-contract-and-hermetic-test-fixtures.md +48 -0
- package/docs/backlogs/15-feat-reasonweave-rebranding-and-doc-code-synchronization-invariant.md +44 -0
- package/docs/backlogs/16-feat-micro-engineering-skills-and-sdd-baton-fusion.md +52 -0
- package/docs/codegraph-readiness-check.md +49 -0
- package/group/architecture/adr/0001-handoff-async-wait-and-reactive-wakeup.md +87 -0
- package/group/architecture/adr/0002-de-ritualize-handoff-prompt-for-intra-repo.md +53 -0
- package/group/architecture/adr/0003-attention-throttle-and-workspace-driver.md +65 -0
- package/group/architecture/adr/0004-spec-guard-and-drift-prevention.md +90 -0
- package/group/architecture/adr/0005-global-orphan-scavenger-and-read-only-invariants.md +94 -0
- package/group/architecture/adr/0006-triad-engineering-defense-and-mutation-sensitivity.md +68 -0
- package/group/architecture/adr/0007-agent-baton-state-machine-defense-and-workspace-jail-spec.md +86 -0
- package/group/architecture/adr/0008-agent-baton-core-convergence-and-heterogeneous-session-resilience.md +133 -0
- package/group/architecture/adr/0009-anti-orphan-deterministic-wiring-governance-and-federated-guardrails.md +108 -0
- package/group/architecture/adr/0010-agent-baton-identity-security-cryptographic-credentials-and-prompt-anti-confusion.md +119 -0
- package/group/architecture/adr/0011-vibe-security-anti-suppression-and-dependency-reachability.md +161 -0
- package/group/architecture/adr/0012-spec-driven-development-reppit-and-tiered-guardrails.md +130 -0
- package/group/architecture/adr/0013-universal-cli-contract-hermetic-testing-and-defensive-probes.md +110 -0
- package/group/architecture/adr/0014-reasonweave-rebranding-and-doc-code-synchronization-invariant.md +108 -0
- package/group/architecture/adr/0015-micro-engineering-skills-and-dual-core-gate-invariant.md +127 -0
- package/group/architecture/adr/INDEX.md +29 -0
- package/group/architecture/adr/templates/adr-template.md +33 -0
- package/group/architecture/dependency-graph.md +60 -0
- package/group/contracts/npm-packaging.md +69 -0
- package/group/product/intent.md +24 -0
- package/package.json +93 -4
- package/scripts/sync-all-consumers.mjs +174 -0
- package/specs/RFC-20261110-SPEC-GUARD-UNIT.md +353 -0
- package/specs/templates/01-research.md.template +23 -0
- package/specs/templates/02-proposals.md.template +22 -0
- package/specs/templates/03-spec.md.template +33 -0
- package/specs/templates/04-tasks.md.template +29 -0
- package/specs/templates/05-evidence.md.template +29 -0
- package/specs/templates/README.md +26 -0
- package/units/adr/AGENTS.md +85 -0
- package/units/adr/CHANGELOG.md +20 -0
- package/units/adr/README.md +88 -0
- package/units/adr/VERSION.md +10 -0
- package/units/adr/docs/existing-project-prompt.md +24 -0
- package/units/adr/docs/new-project-prompt.md +36 -0
- package/units/adr/scripts/adr-init.sh +101 -0
- package/units/adr/templates/INDEX.md +19 -0
- package/units/adr/templates/adr-frozen.md +33 -0
- package/units/adr/templates/adr-light.md +56 -0
- package/units/adr/templates/adr-standard.md +61 -0
- package/units/backlog/AGENTS.md +53 -0
- package/units/backlog/AUTONOMOUS-GOVERNANCE.md +98 -0
- package/units/backlog/CHANGELOG.md +37 -0
- package/units/backlog/README.md +124 -0
- package/units/backlog/VERSION.md +11 -0
- package/units/backlog/docs/existing-project-ironrules-prompt.md +31 -0
- package/units/backlog/docs/existing-project-prompt.md +24 -0
- package/units/backlog/docs/new-project-prompt.md +19 -0
- package/units/backlog/templates/entry.md +39 -0
- package/units/backlog/templates/project-ironrules.md +36 -0
- package/units/handoffs/AGENT-GUIDE.md +118 -0
- package/units/handoffs/AGENTS.md +28 -0
- package/units/handoffs/CHANGELOG.md +498 -0
- package/units/handoffs/CLAUDE.md +28 -0
- package/units/handoffs/COMMANDS.md +187 -0
- package/units/handoffs/DESIGN.md +74 -0
- package/units/handoffs/README.md +456 -0
- package/units/handoffs/RESPONSE-TEMPLATE.md +138 -0
- package/units/handoffs/VERSION.md +1 -0
- package/units/handoffs/handoff-status.mjs +1017 -0
- package/units/handoffs/handoff.mjs +5675 -0
- package/units/orphan/CHANGELOG.md +118 -0
- package/units/orphan/DESIGN.md +484 -0
- package/units/orphan/README.md +143 -0
- package/units/orphan/VERSION.md +1 -0
- package/units/orphan/adapters/android/index.mjs +140 -0
- package/units/orphan/adapters/python/index.mjs +232 -0
- package/units/orphan/adapters/web/index.mjs +280 -0
- package/units/orphan/bin/lab-orphan.mjs +298 -0
- package/units/orphan/core/blob-reader.mjs +142 -0
- package/units/orphan/core/classifier.mjs +261 -0
- package/units/orphan/core/cleaner.mjs +166 -0
- package/units/orphan/core/diff-checker.mjs +341 -0
- package/units/orphan/core/inverted-index.mjs +124 -0
- package/units/orphan/core/orphan-deps.mjs +192 -0
- package/units/orphan/core/protocol-s1-s3.mjs +194 -0
- package/units/orphan/core/solver.mjs +217 -0
- package/units/orphan/index.mjs +105 -0
- package/units/orphan/templates/ci/orphan-guard.yml +36 -0
- package/units/orphan/templates/pre-commit.d/30-orphan-guard +34 -0
- package/units/orphan/templates/wiring/README.md +51 -0
- package/units/orphan/templates/wiring/miniprogram-route-guard.js.template +80 -0
- package/units/orphan/templates/wiring/pre-commit-node.sh.template +73 -0
- package/units/orphan/templates/wiring/project-agents-gemini-templates.md +60 -0
- package/units/orphan/templates/wiring/python-parity-test.py.template +100 -0
- package/units/orphan/templates/wiring/rust-exhaustive-match.md +65 -0
- package/units/orphan/templates/wiring/swift-periphery.md +56 -0
- package/units/orphan/tests/adapters.test.mjs +243 -0
- package/units/orphan/tests/orphan-deps.test.mjs +131 -0
- package/units/orphan/tests/phase3-gates.test.mjs +135 -0
- package/units/playbook/README.md +106 -0
- package/units/playbook/ZSPEC-AGENT-GUIDE.md +99 -0
- package/units/playbook/docs/01-architecture.md +99 -0
- package/units/playbook/docs/02-bootstrap.md +126 -0
- package/units/playbook/docs/03-units.md +91 -0
- package/units/playbook/docs/04-constitution.md +113 -0
- package/units/playbook/docs/05-adr.md +33 -0
- package/units/playbook/docs/06-spec-kit.md +76 -0
- package/units/playbook/docs/07-backlog.md +30 -0
- package/units/playbook/docs/08-codegraph.md +79 -0
- package/units/playbook/docs/09-skills.md +101 -0
- package/units/playbook/docs/10-handoff.md +72 -0
- package/units/playbook/docs/11-evidence.md +163 -0
- package/units/playbook/docs/12-gates.md +124 -0
- package/units/playbook/docs/13-parallel.md +115 -0
- package/units/playbook/docs/14-dependency-graph.md +86 -0
- package/units/playbook/docs/15-memory.md +153 -0
- package/units/playbook/docs/16-change-control.md +121 -0
- package/units/playbook/docs/17-prompts.md +121 -0
- package/units/playbook/docs/18-shift-left.md +97 -0
- package/units/playbook/docs/19-anti-orphan-vertical-slicing.md +102 -0
- package/units/playbook/docs/20-vibe-security-and-anti-suppression.md +88 -0
- package/units/playbook/docs/21-spec-driven-reppit-closed-loop.md +88 -0
- package/units/playbook/examples/owisel.md +80 -0
- package/units/playbook/references/Agent-Engineering-Framework-AEF-v1.0.md +2033 -0
- package/units/playbook/references/links.md +103 -0
- package/units/playbook/templates/AGENTS.root.md +44 -0
- package/units/playbook/templates/AGENTS.unit.md +52 -0
- package/units/playbook/templates/adr/INDEX.md +17 -0
- package/units/playbook/templates/adr/NNNN-template.md +56 -0
- package/units/playbook/templates/backlogs/entry.md +30 -0
- package/units/playbook/templates/constitution.md +93 -0
- package/units/playbook/templates/evidence/README.md +36 -0
- package/units/playbook/templates/group/architecture/dependency-graph.md +48 -0
- package/units/playbook/templates/group/architecture/system.md +59 -0
- package/units/playbook/templates/group/contracts/api.md +67 -0
- package/units/playbook/templates/group/product/intent.md +30 -0
- package/units/playbook/templates/group/product/requirements.md +48 -0
- package/units/playbook/templates/unit-skeleton/README.md +35 -0
- package/units/preflight/AGENTS.md +45 -0
- package/units/preflight/CHANGELOG.md +55 -0
- package/units/preflight/INSTALL.md +65 -0
- package/units/preflight/README.md +104 -0
- package/units/preflight/VERSION.md +3 -0
- package/units/preflight/docs/audit-requirements.md +114 -0
- package/units/preflight/docs/existing-project-prompt.md +25 -0
- package/units/preflight/docs/new-project-prompt.md +25 -0
- package/units/preflight/docs/transfers/CONSUMER-INSTALL.md +40 -0
- package/units/preflight/docs/transfers/CONSUMER-SELFCHECK.md +51 -0
- package/units/preflight/docs/transfers/README.md +39 -0
- package/units/preflight/docs/transfers/prospero.md +26 -0
- package/units/preflight/templates/check.sh +43 -0
- package/units/preflight/templates/pre-commit +55 -0
- package/units/preflight/templates/pre-commit.d/20-preflight +15 -0
- package/units/preflight/templates/preflight.conf.example +21 -0
- package/units/preflight/templates/preflight.sh +189 -0
- package/units/preflight/templates/wrap-up.md +9 -0
- package/units/review-gate/AGENTS.md +42 -0
- package/units/review-gate/CHANGELOG.md +58 -0
- package/units/review-gate/README.md +118 -0
- package/units/review-gate/VERSION.md +3 -0
- package/units/review-gate/clean-runner.mjs +350 -0
- package/units/review-gate/docs/existing-project-prompt.md +28 -0
- package/units/review-gate/docs/new-project-prompt.md +38 -0
- package/units/review-gate/docs/transfers/iggle.md +34 -0
- package/units/review-gate/docs/transfers/prospero.md +35 -0
- package/units/review-gate/docs/transfers/swoop.md +36 -0
- package/units/review-gate/docs/transfers/yiqiyihuihua.md +35 -0
- package/units/review-gate/templates/.semgrepignore +37 -0
- package/units/review-gate/templates/pre-commit +130 -0
- package/units/review-gate/templates/scan.sh +158 -0
- package/units/skills/AGENTS.md +17 -0
- package/units/skills/CHANGELOG.md +18 -0
- package/units/skills/README.md +63 -0
- package/units/skills/VERSION.md +1 -0
- package/units/skills/bin/review-package.mjs +99 -0
- package/units/skills/bin/task-brief.mjs +102 -0
- package/units/skills/catalog/brainstorming/SKILL.md +75 -0
- package/units/skills/catalog/brainstorming/references/design-doc-template.md +28 -0
- package/units/skills/catalog/systematic-debugging/SKILL.md +101 -0
- package/units/skills/catalog/systematic-debugging/references/root-cause-tracing.md +23 -0
- package/units/skills/catalog/test-driven-development/SKILL.md +88 -0
- package/units/skills/catalog/test-driven-development/references/writing-good-tests.md +13 -0
- package/units/skills/catalog/verification-before-completion/SKILL.md +73 -0
- package/units/skills/skills.mjs +181 -0
- package/units/skills/tests/pipeline.test.mjs +131 -0
- package/units/skills/tests/skill-contract.test.mjs +67 -0
- package/units/skills/tests/skills-cli.test.mjs +107 -0
- package/units/spec-guard/AGENTS.md +43 -0
- package/units/spec-guard/CHANGELOG.md +88 -0
- package/units/spec-guard/README.md +148 -0
- package/units/spec-guard/VERSION.md +1 -0
- package/units/spec-guard/bin/spec-guard.mjs +431 -0
- package/units/spec-guard/core/adr-parser.mjs +540 -0
- package/units/spec-guard/core/matrix-checker.mjs +587 -0
- package/units/spec-guard/core/mutation-runner.mjs +267 -0
- package/units/spec-guard/core/scanner.mjs +333 -0
- package/units/spec-guard/core/telemetry_authenticator.mjs +484 -0
- package/units/spec-guard/core/wiring_tracer.mjs +306 -0
- package/units/spec-guard/templates/annotations/ContractOnly.kt +19 -0
- package/units/spec-guard/templates/annotations/Invariant.kt +16 -0
- package/units/spec-guard/templates/annotations/invariant.go +19 -0
- package/units/spec-guard/templates/annotations/invariant.py +38 -0
- package/units/spec-guard/templates/annotations/invariant.ts +39 -0
- package/units/spec-guard/templates/ci/spec-guard-audit.yml +23 -0
- package/units/spec-guard/templates/pre-commit.d/15-spec-guard +72 -0
- package/units/spec-guard/templates/spec-matrix.overlay.yml +70 -0
- package/units/spec-guard/tests/spec-guard.test.mjs +716 -0
- package/units/spec-guard/tests/telemetry_authenticator.test.mjs +633 -0
- package/units/worktree/AGENTS.md +22 -0
- package/units/worktree/CHANGELOG.md +14 -0
- package/units/worktree/README.md +65 -0
- package/units/worktree/VERSION.md +1 -0
- package/units/worktree/worktree.mjs +352 -0
- package//344/275/277/347/224/250/350/257/264/346/230/216.md +322 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!-- handoff-stub:v2.1 begin -->
|
|
2
|
+
<!-- generated — do not edit -->
|
|
3
|
+
<!-- stub:sha256:1363bd6e -->
|
|
4
|
+
### Agent Baton (Handoff) 接入桩(轻量韧性版 · 细则以 $(lab path handoffs)/README.md 契约 v2.31.1 为准)
|
|
5
|
+
|
|
6
|
+
**核心守卫与身份(强制)**
|
|
7
|
+
- **物理工作区边界**:会话严格绑定当前宿主工作区,严禁跨仓 cd 操作外部代码;跨仓请输出交接提示词引导人类在目标仓 Agent 会话中派发。
|
|
8
|
+
- **命令形态与显式身份**:一律 `baton <op>` 或 `handoff <op>`。全面支持 `--as <lane>` 显式声明执行身份,同一会话内可无缝切换角色并发处理多工单。
|
|
9
|
+
- **确定性自愈**:校验细节(Nonce、证据路径、数据一致性)由 CLI 运行时精准拦截;若命令报错,末尾 100% 打印可直接复制的一键自愈命令,按提示执行即可恢复。
|
|
10
|
+
|
|
11
|
+
**入站工作流(接单 · 交付 · 退回)**
|
|
12
|
+
1. **查待办**:运行 `baton status --as <本方 lane|target>`(直取本方未闭环待办工单,或全量 `baton status`)。
|
|
13
|
+
2. **读工单**:运行 `baton show <id>`,根据验收判据改动本 lane 范围代码并实测。
|
|
14
|
+
3. **交付或退回(实测为唯一准绳)**:
|
|
15
|
+
- **实测通过**:照抄 `$(lab path handoffs)/RESPONSE-TEMPLATE.md` 骨架 → 运行 `baton receipt <id> -n "<正文>" --deliver --as <本方 lane> --evidence-paths "<真实文件路径>"`(审计工单附 `--audit-nonce "<nonce>"` 或同工作区授权下使用 `--auto-nonce` 自动绑定最新令牌;红队用例严格遵循 NO_DISPATCH / NO_COMPLETE / COMPLETE 三态标准)。
|
|
16
|
+
- **实测未过(NO-GO/受阻)**:享有【无条件安全下车通道】,直接运行 `baton reject <id> -n "<驳回理由/缺失条件>" --as <本方 lane>` 退回整改(中间受阻回执亦可直接无阻碍登记)。
|
|
17
|
+
4. **收尾自检**:运行 `baton check [id]`(若有数据漂移可加 `--fix` 自动修复)。
|
|
18
|
+
|
|
19
|
+
**出站工作流(派发 · 监听)**
|
|
20
|
+
1. **建单与转递**:`baton new <target|lane> <type> "<标题>"`,填写正文后执行 `baton forward <id> --wait`(多单并发可使用 `baton forward <id> --async` 解耦,派发后运行 `baton wait <id1> <id2> ... --all` 聚合监听;交付完成并平息后自动唤醒验收)。
|
|
21
|
+
2. **回复收尾(交接提示词规范)**:出站回复最末块必须固定为独立代码块,方便人类一键复制给接收方 Agent(其后无任何正文):
|
|
22
|
+
## 交接提示词
|
|
23
|
+
```text
|
|
24
|
+
请【<目标角色>】接单 [<ID>]:<交接路径>(<主题>)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
详见 `$(lab path handoffs)/AGENT-GUIDE.md` 获取完整版 Preflight。
|
|
28
|
+
<!-- handoff-stub:v2.1 end -->
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Agent Baton CLI Command Manual
|
|
2
|
+
|
|
3
|
+
> Complete command-line manual and lifecycle reference for `agent-baton` (`baton`).
|
|
4
|
+
> Backward-compatible alias: `handoff <command>`.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. Lifecycle Overview
|
|
9
|
+
|
|
10
|
+
The Baton lifecycle strictly advances through 5 deterministic states:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
[draft] ──(baton forward)──> [forwarded] ──(baton receipt)──> [received] ──(baton deliver)──> [delivered] ──(baton accept)──> [closed]
|
|
14
|
+
│ │
|
|
15
|
+
└──(0-token wait)──────────────────────────────────────────────────┴──(baton reject)──> [forwarded]
|
|
16
|
+
```
|
|
17
|
+
*(Tip: `baton receipt <id> --deliver` advances directly from `forwarded` to `delivered` in a single step).*
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 2. Core CLI Commands
|
|
22
|
+
|
|
23
|
+
### `baton init`
|
|
24
|
+
Initialize a Baton Hub.
|
|
25
|
+
```bash
|
|
26
|
+
# Intra-repo mode (inside an existing project; creates .handoffs/ and .handoff-hub.json)
|
|
27
|
+
baton init [--lanes <lane1,lane2>] [--root <dir>]
|
|
28
|
+
|
|
29
|
+
# Cross-repo mode (creates a standalone neutral coordination hub)
|
|
30
|
+
baton init --cross [--targets <target1,target2>] [--root <dir>]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### `baton status`
|
|
34
|
+
Inspect the central coordination state and discover pending tasks.
|
|
35
|
+
```bash
|
|
36
|
+
# Global overview of all pending/received tickets
|
|
37
|
+
baton status
|
|
38
|
+
|
|
39
|
+
# Focus view: only display active tickets within the last 7 days / 24 hours
|
|
40
|
+
baton status --active
|
|
41
|
+
|
|
42
|
+
# Display all tickets without collapsing dormant historical items
|
|
43
|
+
baton status --all
|
|
44
|
+
|
|
45
|
+
# Filter pending tasks assigned specifically to your lane or repository
|
|
46
|
+
baton status --for <lane|target>
|
|
47
|
+
|
|
48
|
+
# Render real-time multi-agent topology flowchart (Mermaid)
|
|
49
|
+
baton status --mermaid
|
|
50
|
+
|
|
51
|
+
# Machine-readable JSON output for automated agent loops
|
|
52
|
+
baton status --json
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### `baton new`
|
|
56
|
+
Create a new structured handoff ticket.
|
|
57
|
+
```bash
|
|
58
|
+
# Syntax: baton new <target|lane> <type> "<title>" [--profile readonly|full] [--workspace same|worktree|separate]
|
|
59
|
+
baton new audit task "Refactor User Authentication"
|
|
60
|
+
baton new api feature "Implement Rate Limiting Middleware"
|
|
61
|
+
|
|
62
|
+
# Read-only exploration profile (ADR-0012 §2.6 / ADR-0009 anti-fake wiring)
|
|
63
|
+
# Enforces production code write-protection: executor cannot modify production files
|
|
64
|
+
baton new audit task "Security Architecture Review" --profile readonly
|
|
65
|
+
```
|
|
66
|
+
*Types supported*: `task`, `bug`, `feature`, `question`, `continuation`.
|
|
67
|
+
*Profiles supported*: `full` (default), `readonly` (strictly forbids production code mutations in receipts).
|
|
68
|
+
|
|
69
|
+
### `baton forward`
|
|
70
|
+
Mark ticket(s) as forwarded to the receiving lane, optionally stripping cognitive biases, dispatching concurrently, or sleeping until receipt(s) arrive.
|
|
71
|
+
```bash
|
|
72
|
+
# Transfer ticket with double-blind cognitive sanitization & background sleep
|
|
73
|
+
baton forward <id> --blind --wait
|
|
74
|
+
|
|
75
|
+
# Batch forward multiple tickets and wait for all in aggregate
|
|
76
|
+
baton forward <id1> <id2> --wait
|
|
77
|
+
|
|
78
|
+
# Non-blocking concurrent dispatch (suppresses wait warnings, suggests baton wait <id1> <id2> ...)
|
|
79
|
+
baton forward <id> --async
|
|
80
|
+
|
|
81
|
+
# Options:
|
|
82
|
+
# --async Non-blocking concurrent dispatch mode without warning
|
|
83
|
+
# --daemon Detach daemon process instantly (<0.1s) using Node.js unref()
|
|
84
|
+
# --blind Physically sanitize <thinking> tags and subjective excuses
|
|
85
|
+
# --wait Sleep at 0-Token until delivery lands, waking automatically after settle window
|
|
86
|
+
# --timeout Timeout duration (e.g. 60m, 2h; default: 60m)
|
|
87
|
+
# --settle Settle window buffer before waking (default: 10s)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### `baton wait`
|
|
91
|
+
Standalone 0-Token event-driven watcher & lightweight pub/sub aggregator (powered by OS `fs.watch`).
|
|
92
|
+
```bash
|
|
93
|
+
# Single handoff wait
|
|
94
|
+
baton wait <id> [--timeout 60m] [--settle 10s] [--daemon]
|
|
95
|
+
|
|
96
|
+
# Multi-handoff lightweight pub/sub aggregation (Join mode, waits for all to be delivered)
|
|
97
|
+
baton wait <id1> <id2> [--all] [--timeout 60m] [--settle 10s]
|
|
98
|
+
|
|
99
|
+
# Multi-handoff race mode (wakes upon the first delivered handoff)
|
|
100
|
+
baton wait <id1> <id2> --any [--timeout 60m] [--settle 10s]
|
|
101
|
+
```
|
|
102
|
+
*Note*: Exits with code `0` when final delivery lands (`delivered`/`closed`) and the settle buffer has fully elapsed. Automatically wakes up your coding agent session. Exits with `124` on timeout with structured matrix diagnostic report.
|
|
103
|
+
|
|
104
|
+
### `baton prompt`
|
|
105
|
+
Generate the standard, copy-pasteable baton pass prompt for manual cross-session/window relay.
|
|
106
|
+
```bash
|
|
107
|
+
baton prompt <id>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### `baton receipt`
|
|
111
|
+
Register an execution receipt and transition ticket to `received` (or directly to `delivered` with `--deliver`).
|
|
112
|
+
```bash
|
|
113
|
+
baton receipt <id> \
|
|
114
|
+
[--deliver] \
|
|
115
|
+
--evidence-paths "<file1,file2>" \
|
|
116
|
+
--evidence-commits "<commit-sha>" \
|
|
117
|
+
[--audit-nonce "<nonce>" | --auto-nonce] \
|
|
118
|
+
[-n "<receipt-markdown-body>"]
|
|
119
|
+
```
|
|
120
|
+
*Guards*:
|
|
121
|
+
- `--evidence-paths`: Verified on disk via `fs.existsSync`.
|
|
122
|
+
- `--evidence-commits`: Verified in Git history via `git cat-file -e`.
|
|
123
|
+
- `--audit-nonce`: Mandatory when `to_lane=audit` to prevent self-signing.
|
|
124
|
+
- `--auto-nonce`: Automatically binds the ticket's active Audit Nonce (convenient for authorized intra-repo workflows).
|
|
125
|
+
- `--deliver`: Atomically executes final delivery (`delivered`), immediately notifying initiator.
|
|
126
|
+
|
|
127
|
+
### `baton deliver`
|
|
128
|
+
Explicitly finalize task completion and transition ticket from `received` to `delivered`.
|
|
129
|
+
```bash
|
|
130
|
+
baton deliver <id> [-n "<delivery note>"] [--auto-nonce]
|
|
131
|
+
```
|
|
132
|
+
*Guards*:
|
|
133
|
+
- Verifies receipt exists and passes all content/evidence gates.
|
|
134
|
+
- Anti-self-closing: Initiators are blocked from delivering on behalf of executors.
|
|
135
|
+
- `--auto-nonce`: Automatically binds the latest Audit Nonce into receipt before delivery.
|
|
136
|
+
- Stamps `delivered_at` timestamp and wakes up initiator's background probe for independent verification.
|
|
137
|
+
|
|
138
|
+
### `baton accept`
|
|
139
|
+
Accept the receipt, verify invariants, and formally close the handoff.
|
|
140
|
+
```bash
|
|
141
|
+
baton accept <id> -n "<acceptance summary>" [--legacy-exempt]
|
|
142
|
+
```
|
|
143
|
+
*Guards*:
|
|
144
|
+
- Requires ticket to be in `delivered` state (or historical ticket with `--legacy-exempt`).
|
|
145
|
+
- Hard-fails if executor has not explicitly marked final delivery.
|
|
146
|
+
|
|
147
|
+
### `baton reject`
|
|
148
|
+
Reject the receipt or audit findings due to failed tests or unmet criteria, returning the ticket to `forwarded` for remediation. Executable by the ticket initiator or by the auditor (`to_lane=audit`).
|
|
149
|
+
```bash
|
|
150
|
+
baton reject <id> -n "<rejection reason>" [--by <lane>]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### `baton nonce`
|
|
154
|
+
Inspect or rotate/reissue the one-time anti-spoofing challenge nonce for audit tickets (`to_lane=audit`).
|
|
155
|
+
```bash
|
|
156
|
+
baton nonce <id> [--reissue]
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### `baton check`
|
|
160
|
+
Preflight and integrity validation gate. Ensures no corrupted receipts or unauthorized states.
|
|
161
|
+
```bash
|
|
162
|
+
baton check
|
|
163
|
+
```
|
|
164
|
+
*Convention*: Must exit with code `0` before committing work.
|
|
165
|
+
|
|
166
|
+
### `baton install`
|
|
167
|
+
Idempotently inject or refresh Agent instruction stubs into project directive files.
|
|
168
|
+
```bash
|
|
169
|
+
baton install [--project] [--global]
|
|
170
|
+
```
|
|
171
|
+
*Targets*: `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `README.md`.
|
|
172
|
+
|
|
173
|
+
### `baton link`
|
|
174
|
+
Self-healing command to ensure `baton`, `agent-baton`, and `handoff` shims exist in your user PATH (`~/.local/bin/`).
|
|
175
|
+
```bash
|
|
176
|
+
baton link [--remove]
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### `baton throttle`
|
|
180
|
+
Run background execution tasks with a three-tier noise-filtering pipeline to protect agent and human attention.
|
|
181
|
+
```bash
|
|
182
|
+
baton throttle <id> [--quiet] [--timeout <ms>] -- <command>
|
|
183
|
+
```
|
|
184
|
+
*Tiers*:
|
|
185
|
+
- Green: Regular output stream quietly written to `.handoffs/logs/<id>.throttle.log`.
|
|
186
|
+
- Yellow: Warnings, rate limits and retries tracked with summary counters.
|
|
187
|
+
- Red: Fatal runtime crashes immediately breach the filter and alert the parent agent.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Agent Baton Architecture & Design Whitepaper
|
|
2
|
+
|
|
3
|
+
> **Why Multi-Agent Systems Fail in Production: A Post-Mortem of Real Accidents & The Six Invariants of Agent Baton.**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. The Multi-Agent Reality Check
|
|
8
|
+
|
|
9
|
+
When multiple AI coding agents operate across repositories or specialized lanes (e.g. Architecture, Implementation, Audit), they do not have a magical hive-mind. Instead, they operate as isolated LLM sessions.
|
|
10
|
+
|
|
11
|
+
Before establishing the Baton protocol, real production workflows suffered from the following catastrophic failures:
|
|
12
|
+
|
|
13
|
+
| Real Incident | Root Cause |
|
|
14
|
+
| :--- | :--- |
|
|
15
|
+
| **Hallucinated Receipts** | Agent claimed *"Fixed and tested"*, but touched zero files. Naive dispatchers blindly advanced workflow. |
|
|
16
|
+
| **Sycophancy in Code Review** | Reviewing agent read author's internal chain-of-thought and excused missing edge-case coverage. |
|
|
17
|
+
| **Self-Closing Loopholes** | Single rogue agent switched its role variable, approving its own unverified changes. |
|
|
18
|
+
| **Cognitive Drift & Overheating** | Polling files in infinite loops drained thousands of tokens and caused CPU throttling. |
|
|
19
|
+
| **Context Bloat** | Author dumped 200+ lines of justifications into tickets, consuming context windows before coding began. |
|
|
20
|
+
|
|
21
|
+
**The Core Realization**: Asynchronous AI collaboration cannot rely on natural language politeness. It requires **deterministic state machines, cryptographic gates, and verifiable evidence**.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 2. The Six Invariants of Agent Baton
|
|
26
|
+
|
|
27
|
+
Agent Baton enforces six strict invariants across all coordination layers:
|
|
28
|
+
|
|
29
|
+
### Invariant 1: Files as Database, Git as Proof (Zero External Services)
|
|
30
|
+
Baton requires no running PostgreSQL, Redis, or cloud daemon. The filesystem is the bus, Markdown is the state, and Git commit SHAs are the immutable cryptographic proof of work.
|
|
31
|
+
|
|
32
|
+
### Invariant 2: Separation of Powers (Anti-Self-Closing)
|
|
33
|
+
An author (`from_lane`) is **physically prohibited** from writing a receipt for its own ticket. Receipts must originate from the assigned receiver (`to_lane`).
|
|
34
|
+
|
|
35
|
+
### Invariant 3: Double-Blind Context Sanitization (`--blind`)
|
|
36
|
+
Reviewers must not be primed by authors. When forwarding to an auditor, Baton strips `<thinking>` blocks and prose excuses. The auditor receives only the objective specification and the Git diff.
|
|
37
|
+
|
|
38
|
+
### Invariant 4: Cryptographic Audit Challenges (Audit Nonce)
|
|
39
|
+
To prevent prompt-injection attacks where an agent temporarily exports `HANDOFF_LANE=audit`, the engine generates an ephemeral, high-entropy challenge nonce (`aud_xxxx`). The receipt is rejected unless this nonce is provided.
|
|
40
|
+
|
|
41
|
+
### Invariant 5: Mandatory Terminal Execution (No Static Review)
|
|
42
|
+
For audit lanes, reading code is not enough. The auditor is contractually obligated to execute test commands in an actual shell. Receipts without terminal verification are rejected.
|
|
43
|
+
|
|
44
|
+
### Invariant 6: 0-Token Reactive Wakeup
|
|
45
|
+
Baton rejects polling loops. By integrating with OS kernel events (`fs.watch`) and agent host wakeups, sessions sleep at **0 CPU and 0 Token cost**, resuming in milliseconds when state transitions occur.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 3. Threat Model & Security Considerations
|
|
50
|
+
|
|
51
|
+
```mermaid
|
|
52
|
+
flowchart TD
|
|
53
|
+
subgraph Untrusted["Untrusted Agent Environment"]
|
|
54
|
+
Agent["AI Coding Agent"]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
subgraph Gates["Baton Protocol Enforcement"]
|
|
58
|
+
G1["git cat-file -e verification"]
|
|
59
|
+
G2["Audit Nonce Challenge Validator"]
|
|
60
|
+
G3["Double-Blind Payload Sanitizer"]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
subgraph State["Verified Repository State"]
|
|
64
|
+
MainBranch["Protected Codebase"]
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
Agent -->|Tries to fake receipt| G1
|
|
68
|
+
G1 -->|Fail-closed on empty diff| Agent
|
|
69
|
+
Agent -->|Tries to self-sign audit| G2
|
|
70
|
+
G2 -->|Rejected without Nonce| Agent
|
|
71
|
+
Agent -->|Submits verified proofs| MainBranch
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
By decoupling trust from the LLM model and placing it entirely in the deterministic CLI validator, Baton guarantees production-grade reliability regardless of which frontier model is running.
|