Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
6ffc655
docs(PTYCAP): add independent verification reports for phases 1 and 2
finedesignz Oct 7, 2026
5e907ee
docs(PTYCAP-03): add codebase research for phases 3 and 4
finedesignz Oct 7, 2026
083e174
docs(PTYCAP-03): discuss phase - 3-seat design-fork panel verdict + C…
finedesignz Oct 7, 2026
fe2b285
docs(PTYCAP-03): add validation architecture and VALIDATION.md seed
finedesignz Oct 7, 2026
193e55b
docs(PTYCAP-03): add pattern map for phase 3
finedesignz Oct 7, 2026
6f11e28
docs(PTYCAP-03): plan phase 3 - 4 plans, 12 tasks, sequential waves
finedesignz Oct 7, 2026
7051b6b
feat(PTYCAP-03): governed-pty module wired through telegram dispatch …
finedesignz Oct 7, 2026
6cf1236
feat(PTYCAP-03): rename ask and work dispatch gates to governedAutoma…
finedesignz Oct 7, 2026
d0968bc
feat(PTYCAP-03): delete the old human-only dispatch gate and pin gove…
finedesignz Oct 7, 2026
c4b96d7
docs(PTYCAP-03): complete governed-pty tracer plan 03-01
finedesignz Oct 7, 2026
11d18a8
feat(PTYCAP-03-02): flag-first governed automation branch in the PTY …
finedesignz Oct 7, 2026
a9dac91
test(PTYCAP-03-02): pin the human chain as governor-free and make the…
finedesignz Oct 7, 2026
627cbe9
docs(PTYCAP-03-02): complete governed automation preflight branch plan
finedesignz Oct 7, 2026
87d92c8
feat(PTYCAP-03-03): make Telegram dispatch source required, fail clos…
finedesignz Oct 13, 2026
8f5cfad
test(PTYCAP-03-03): prove /ws/client strips client-asserted actor key…
finedesignz Oct 13, 2026
9e7d93e
test(PTYCAP-03-03): pin the PTY door -- term.* emitters, supervisor r…
finedesignz Oct 13, 2026
a7c2e3a
docs(PTYCAP-03-03): complete telegram source + door pins plan summary
finedesignz Oct 13, 2026
5676b12
docs(PTYCAP-03-04): document governed-automation guard, correct Phase…
finedesignz Oct 13, 2026
da575ed
docs(PTYCAP-03-04): finish humanOnlyPtyGate -> governedAutomationPtyG…
finedesignz Oct 13, 2026
a7aa1d7
docs(PTYCAP-03-04): OpenAPI reason descriptions cite governedAutomati…
finedesignz Oct 13, 2026
bf56f4f
chore(PTYCAP-03-04): re-measure regression baseline (pass 2378 skip 2…
finedesignz Oct 13, 2026
af796db
docs(PTYCAP-03-04): complete docs close-out and phase gate plan summary
finedesignz Oct 13, 2026
d519ebf
fix(PTYCAP-03): inject_rate governor blocks invalid (garbage/NaN/Infi…
finedesignz Oct 13, 2026
6f2de32
fix(PTYCAP-03): make dispatchToSession caller pin alias-aware (telegr…
finedesignz Oct 13, 2026
5f9ad89
chore(PTYCAP-03): re-measure regression baseline after QC round 1 (+1…
finedesignz Oct 13, 2026
250a05c
docs(PTYCAP-03): phase verification
finedesignz Oct 13, 2026
9887e08
docs(PTYCAP-03): mark phase complete in ROADMAP and STATE (PR #505)
finedesignz Oct 13, 2026
048adf4
docs(PTYCAP-04): plan lifetime counter + kill switch phase
finedesignz Oct 13, 2026
126e6cb
docs(PTYCAP-04): revise plans per fork panel + plan-check
finedesignz Oct 13, 2026
0de6635
fix(PTYCAP-04-01): dedupe PTY usage on message.id with per-bucket max…
finedesignz Oct 13, 2026
eb4fa91
chore(PTYCAP-04-01): bump supervisor to 0.15.1
finedesignz Oct 13, 2026
289b377
docs(PTYCAP-04-01): add plan summary
finedesignz Oct 13, 2026
3fe2fbe
feat(PTYCAP-04-02): schema for lifetime inject ledger, kill switch an…
finedesignz Oct 13, 2026
7df43fe
feat(PTYCAP-04-02): neutral automation-controls module (kill switch, …
finedesignz Oct 13, 2026
596a36b
feat(PTYCAP-04-02): wire reserve/final-halt into dispatch() and the o…
finedesignz Oct 13, 2026
6876a9e
fix(PTYCAP-04-02): page exhaustion from the lifetime gate and scope-e…
finedesignz Oct 13, 2026
040bc2f
test(PTYCAP-04-02): tracer over real dispatch + controls + inject, an…
finedesignz Oct 13, 2026
1cf2bfd
docs(PTYCAP-04-02): add plan summary
finedesignz Oct 13, 2026
768e460
feat(PTYCAP-04-03): orchestrator inject autospawn path counted, repla…
finedesignz Oct 13, 2026
d9ab019
feat(PTYCAP-04-03): orchestrator run-log rows record the inject token…
finedesignz Oct 13, 2026
b5dcf37
feat(PTYCAP-04-03): scheduler agent and triage senders carry counter …
finedesignz Oct 13, 2026
a207a5b
feat(PTYCAP-04-03): pipeline reserve semantics tests and static pins …
finedesignz Oct 13, 2026
a679e23
docs(PTYCAP-04-03): add plan summary
finedesignz Oct 13, 2026
292787d
feat(PTYCAP-04-04): real kill_switch and lifetime_counter governors, …
finedesignz Oct 13, 2026
b5dff53
feat(PTYCAP-04-04): the PTY door counts the turn with an atomic reser…
finedesignz Oct 13, 2026
b62d8a4
docs(PTYCAP-04-04): add plan summary
finedesignz Oct 13, 2026
e824552
feat(PTYCAP-04-05): kill-switch and lifetime-reset routes with tenanc…
finedesignz Oct 13, 2026
d97add5
feat(PTYCAP-04-05): mount automation routes with step-up, wire boot a…
finedesignz Oct 13, 2026
b3ddd67
feat(PTYCAP-04-05): type the automation router env and registration t…
finedesignz Oct 13, 2026
e1737b3
feat(PTYCAP-04-05): event-driven daily-token-ceiling alarm with durab…
finedesignz Oct 13, 2026
05db067
feat(PTYCAP-04-05): allowlist the reset route in the counterKey assig…
finedesignz Oct 13, 2026
538dbbb
docs(PTYCAP-04-05): add plan summary
finedesignz Oct 13, 2026
f8dc796
feat(PTYCAP-04-06): kill-switch gate first in the error-capture, feed…
finedesignz Oct 13, 2026
779420a
feat(PTYCAP-04-06): kill-switch gate first in the ask and work lists …
finedesignz Oct 13, 2026
1a312ce
feat(PTYCAP-04-06): scheduler and orchestrator-tick entry-point kill-…
finedesignz Oct 13, 2026
87a8efb
docs(PTYCAP-04-06): add plan summary
finedesignz Oct 13, 2026
f4bd344
feat(PTYCAP-04-07): machine-origin option on the launch primitives; a…
finedesignz Oct 13, 2026
0e684b5
feat(PTYCAP-04-07): machine callers pass the launch option; enumerati…
finedesignz Oct 13, 2026
95b4fd3
feat(PTYCAP-04-07): self-heal route is a machine surface with halt ch…
finedesignz Oct 13, 2026
9640ad1
feat(PTYCAP-04-07): kill-switch release resumes deferred work in that…
finedesignz Oct 13, 2026
bbcecbf
feat(PTYCAP-04-07): hold the tsc baseline for the widened launch resu…
finedesignz Oct 13, 2026
c7b1723
docs(PTYCAP-04-07): add plan summary
finedesignz Oct 13, 2026
1f0f0d4
docs(PTYCAP-04-08): register POST /api/sessions/heal with its automat…
finedesignz Oct 13, 2026
4d724a7
docs(PTYCAP-04-08): document the kill switch, lifetime counter, emerg…
finedesignz Oct 13, 2026
386f031
feat(PTYCAP-04-08): lower the default daily token cap from 50M to 20M
finedesignz Oct 13, 2026
60085a2
docs(PTYCAP-04-08): summary with PR-body checklist
finedesignz Oct 13, 2026
e01a243
fix(PTYCAP-04): M1 reopen an orchestrator orphan when no replacement …
finedesignz Oct 13, 2026
04d48b3
fix(PTYCAP-04): B1 fresh kill-switch read immediately before every ma…
finedesignz Oct 13, 2026
119164b
fix(PTYCAP-04): M3 kill-switch governor first on the automation branc…
finedesignz Oct 13, 2026
5287e76
fix(PTYCAP-04): M4 register the token-cap alarm listener before Bun.s…
finedesignz Oct 13, 2026
993e027
fix(PTYCAP-04): m2 kill-switch-halted skips do not count toward max_runs
finedesignz Oct 13, 2026
803fadb
fix(PTYCAP-04): m1 non-admins see only {engaged:true} for the global …
finedesignz Oct 13, 2026
bf44989
fix(PTYCAP-04): R1 final machine-send halt read names the resolved or…
finedesignz Oct 13, 2026
d90e666
fix(PTYCAP-04): R2 reopen the orchestrator orphan when no replacement…
finedesignz Oct 13, 2026
d864570
fix(PTYCAP-04): R3 re-arm a claimed one-time task when the sender's l…
finedesignz Oct 13, 2026
8447cdf
docs(PTYCAP-04): phase verification
finedesignz Oct 13, 2026
bf3f51d
test(PTYCAP-04): fix e2e fixtures for real Postgres (unique project_d…
finedesignz Oct 13, 2026
d3c28a4
docs(PTYCAP-04): record phase state (executed, QC blocked on 2 races,…
finedesignz Oct 13, 2026
0d13b21
fix(ptycap-04): serialize orphan reopen with launch lock; re-arm halt…
finedesignz Oct 13, 2026
ec2237e
docs(PTYCAP-04): QC round 3 verification addendum
finedesignz Oct 13, 2026
1243619
docs(ptycap-05): discuss-phase context and forks for throwaway-repo d…
finedesignz Oct 13, 2026
b7bbe3b
docs(PTYCAP-05): lock fork panel verdict (2 sonnet seats + codex)
finedesignz Oct 13, 2026
018947d
docs(PTYCAP-05): plan throwaway-repo due->PR proof (9 plans, 4 waves)
finedesignz Oct 13, 2026
9c78e01
docs(ptycap-05): plan check PASS
finedesignz Oct 13, 2026
60457c5
feat(05-01): proof tracer - armed run to terminal outcome, flag OFF a…
finedesignz Oct 13, 2026
70acb3a
feat(05-01): proof state layer - arm/disarm/enable txs, counters, att…
finedesignz Oct 14, 2026
1273259
feat(05-01): publish read-only ProofGithub contract and deterministic…
finedesignz Oct 14, 2026
6a8ae21
docs(05-01): complete proof tracer, state layer and ProofGithub contr…
finedesignz Oct 14, 2026
32e802c
feat(PTYCAP-05-02): read-only ProofGithub adapter over the GitHub App…
finedesignz Oct 14, 2026
c31da8e
feat(PTYCAP-05-02): fail-closed protection assertion, freeze, drift, …
finedesignz Oct 14, 2026
07c5c8e
docs(PTYCAP-05-02): complete GitHub adapter and protection plan summary
finedesignz Oct 14, 2026
aec4c80
feat(PTYCAP-05-03): proof verifier default-branch advance and PR scop…
finedesignz Oct 14, 2026
31cf545
feat(PTYCAP-05-03): proof verifier CI evaluation and pr_open_green de…
finedesignz Oct 14, 2026
77786d8
docs(PTYCAP-05-03): complete proof verifier plan summary
finedesignz Oct 14, 2026
742adfc
feat(ptycap-05-04): read-only GET /api/orchestrator/proof status route
finedesignz Oct 14, 2026
62fc83d
docs(ptycap-05-04): register GET /api/orchestrator/proof in OpenAPI a…
finedesignz Oct 14, 2026
b31992c
docs(ptycap-05-04): complete proof status route plan summary
finedesignz Oct 14, 2026
aabfded
feat(PTYCAP-05-05): proof budget and protection dispatch gates
finedesignz Oct 14, 2026
bcc1cf0
feat(PTYCAP-05-05): wire proof gates into both orchestrator gate lists
finedesignz Oct 14, 2026
17309ac
fix(PTYCAP-05-05): keep counterKey assignment guard green (rename loo…
finedesignz Oct 14, 2026
0a70056
feat(PTYCAP-05-05): never-merge routing refusal for proof repos
finedesignz Oct 14, 2026
816d55a
docs(PTYCAP-05-05): complete dispatch gates plan summary
finedesignz Oct 14, 2026
42e6be7
feat(PTYCAP-05-06): ordered proof evaluators with tick-side budget te…
finedesignz Oct 14, 2026
12bd1af
feat(PTYCAP-05-06): inject-outcome mapping, real evaluator wiring, co…
finedesignz Oct 14, 2026
b404472
test(PTYCAP-05-06): multi-tick proof cycle scenarios, final-prompt gr…
finedesignz Oct 14, 2026
8bc140e
docs(PTYCAP-05-06): complete evaluators and inject-outcome mapping pl…
finedesignz Oct 14, 2026
83fb6b4
feat(PTYCAP-05-07): ordered fail-closed armProof core with read-only …
finedesignz Oct 14, 2026
aaae10d
feat(PTYCAP-05-07): disarm (tx then kill switch) and enable cores
finedesignz Oct 14, 2026
636a8d8
feat(PTYCAP-05-07): data-only operator CLI for arm/dry-run/enable/dis…
finedesignz Oct 14, 2026
629a669
docs(PTYCAP-05-07): complete arm/disarm/enable mechanism plan summary
finedesignz Oct 14, 2026
848d955
test(PTYCAP-05-08): flag-OFF differential matrix over the three-flag …
finedesignz Oct 14, 2026
e3fffcd
test(PTYCAP-05-08): real-Postgres proof helper wired into an existing…
finedesignz Oct 14, 2026
ac8def4
chore(PTYCAP-05-08): re-measure regression baseline (3090/259/0), zer…
finedesignz Oct 14, 2026
6888a23
docs(PTYCAP-05-08): plan 08 summary
finedesignz Oct 14, 2026
cfe7568
docs(PTYCAP-05-09): owner arming and rollback runbook for the throwaw…
finedesignz Oct 14, 2026
6ea2ec6
docs(PTYCAP-05-09): document proof flag, budget knobs, invariants and…
finedesignz Oct 14, 2026
1279179
test(PTYCAP-05-09): pin runbook statements; roadmap delivery notes fo…
finedesignz Oct 14, 2026
b9cb500
docs(PTYCAP-05-09): complete owner runbook and docs plan summary
finedesignz Oct 14, 2026
bfdb294
fix(PTYCAP-05-qc1): proof mode is hub-exclusive (codex #1, adversary …
finedesignz Oct 14, 2026
0d27ecf
fix(PTYCAP-05-qc1): proof dispatch requires an exact active-run match…
finedesignz Oct 14, 2026
6c6c43d
fix(PTYCAP-05-qc1): disarm engages the session kill switch before the…
finedesignz Oct 14, 2026
e3a3824
fix(PTYCAP-05-qc1): a proof-owned task never renders the dev macro un…
finedesignz Oct 14, 2026
4e1acab
fix(PTYCAP-05-qc1): a usage_event that fails to persist terminalizes …
finedesignz Oct 14, 2026
fed75fe
fix(PTYCAP-05-qc1): PR scope sees every PR and requires the success P…
finedesignz Oct 14, 2026
c95cdf9
fix(PTYCAP-05-qc1): GitHub repo identity is canonical (lowercase) for…
finedesignz Oct 14, 2026
92998ed
fix(PTYCAP-05-qc1): merge refusal fails closed when the session has n…
finedesignz Oct 14, 2026
e29a03c
fix(PTYCAP-05-qc1): arm refuses an unverified agent permission and bo…
finedesignz Oct 14, 2026
74781c0
fix(PTYCAP-05-qc2): one hub-global advisory lock for proof arm, disar…
finedesignz Oct 14, 2026
9c3d3a6
fix(PTYCAP-05-qc2): recheck proof identity and kill state at the wire…
finedesignz Oct 14, 2026
b22ad39
fix(PTYCAP-05-qc2): proof owns exactly one session halt row; disarm r…
finedesignz Oct 14, 2026
ec5dd85
fix(PTYCAP-05-qc2): listPulls paginates until every PR since arm is i…
finedesignz Oct 14, 2026
31e4eee
fix(PTYCAP-05-qc2): derive budget attribution loss from the database,…
finedesignz Oct 14, 2026
783dcf1
docs(PTYCAP-05): QC rounds 1-3 record + verdict (BLOCKED, 2 open MAJOR)
finedesignz Oct 14, 2026
4c1300c
docs(PTYCAP-05): phase verification report (SC-1 PASS, SC-2/3 BLOCKED…
finedesignz Oct 14, 2026
932c71b
fix(PTYCAP-05-repair): per-turn usage correlation (turn_id) + owner-t…
finedesignz Oct 14, 2026
ce67058
docs(PTYCAP-05): repair round record (2 MAJOR fixed, 1 new false-posi…
finedesignz Oct 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions .planning/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

- [ ] **Phase 1: PTY Token Accounting** — live, mid-turn token accounting for a PTY turn (post-hoc is too late; a TUI turn can run for many minutes).
- [x] **Phase 2: PTY Pre-Flight Gate** — a programmatic turn cannot be written to the PTY without passing the full gate chain.
- [ ] **Phase 3: Governed-Automation Guard** — `humanOnlyPtyGate` → `governedAutomationPtyGate`, new flag, default OFF.
- [x] **Phase 3: Governed-Automation Guard** — `humanOnlyPtyGate` → `governedAutomationPtyGate`, new flag, default OFF.
- [ ] **Phase 4: Lifetime Inject Counter + Kill Switch** — rate ceilings don't stop a slow grind; add a lifetime per-task counter and a real kill switch.
- [ ] **Phase 5: Throwaway-Repo Due→PR Proof** — prove the thing actually works, once, on a repo nobody cares about.
- [ ] **Phase 6: Hardening + Docs + Release** — real-Postgres e2e, docs, version bump, ship, smoke-verify.
Expand Down Expand Up @@ -114,6 +114,12 @@ ceiling (and the programmatic-credit halt).
3. Alarm emails the owner at 60% of the daily token ceiling.
4. Default daily token cap lowered from 50M to a survivable figure (~20M).

**Hand-off from Phase 3**: DELIVERED in Phase 4. The fail-closed `kill_switch` and `lifetime_counter` governor bodies in `hub/src/dispatch/governed-pty.ts` are now real; an admitted automation PTY turn is COUNTED in a durable append-only ledger (`automation_inject_ledger`) by an atomic reserve-before-send. See [docs/usage-cost.md](../docs/usage-cost.md) "PTYCAP Phase 4".

**Delivery notes (Phase 4)**: the lifetime cap is LITERAL (default 1000 per counter key, env-raisable, owner reset, one-shot warning page at 80 percent and an exhaustion page); `POST /api/sessions/heal` is classified a machine surface; with `REMO_GOVERNED_AUTOMATION_PTY` ON the ask, work and telegram governed lists carry no counter key, so the `lifetime_counter` governor refuses `lifetime_counter_key_missing` until Phase 5/7 supply keys (fail closed, flag default OFF). The 20M default token cap applies only where `REMO_ORCHESTRATOR_DAILY_TOKEN_CAP` is unset.

**Deferred to Milestone GOV (from Phase 4)**: a Telegram or UI kill-switch trigger; opt-in `stop_running` cancellation of active runs once automation ownership is tracked; a counter policy for QC keys (Phases 7/8) beyond the heal key; the cap-hit QC kind (Phase 9).

### Phase 5: Throwaway-Repo Due→PR Proof

**Goal**: The orchestrator produces one reviewable PR, unattended, on a repo nobody cares about.
Expand All @@ -124,6 +130,21 @@ ceiling (and the programmatic-credit halt).
2. It produces a reviewable PR with a green CI check, or it cleanly does nothing and says why.
3. This has **never once happened**. Until it does, the orchestrator is unproven and unsellable.

**Plans:** 9 plans (the live proof is OWNER-GATED; these plans build, test and document the machinery and the arming runbook, they arm nothing)

Plans:
- [x] 05-01-PLAN.md -- tracer (armed run to terminal outcome through every layer, flag OFF a true no-op) + orchestrator_proof_runs state layer + ProofGithub contract and fake (wave 1)
- [x] 05-02-PLAN.md -- read-only GitHub adapter + protection assertion/freeze/drift (ruleset shape, zero bypass, permission probe) (wave 2)
- [x] 05-03-PLAN.md -- hub verifier: default-branch advance via compare, PR scope, CI/green decision (wave 2)
- [x] 05-04-PLAN.md -- read-only GET /api/orchestrator/proof + OpenAPI + docs:sync (wave 2)
- [x] 05-05-PLAN.md -- proofBudgetGate + proofProtectionGate in both orchestrator gate lists, coverage scans, merge-routing refusal (wave 3)
- [x] 05-06-PLAN.md -- ordered evaluators, tick-side budget termination, inject-outcome mapping, counter-key pin (wave 3)
- [x] 05-07-PLAN.md -- arm/disarm/enable cores + operator CLI (exactly-one allowlist, frozen budget and protection) (wave 3)
- [x] 05-08-PLAN.md -- flag-OFF differential matrix, real-Postgres proof helper (CI only), baseline (wave 4)
- [x] 05-09-PLAN.md -- owner runbook (permissions, repo + ruleset, ordered rollback), CLAUDE.md/docs, runbook pin test (wave 4)

**Delivery notes (Phase 5)**: the machinery is built and tested against a fake GitHub client and, in CI, against real Postgres; nothing was armed and no flag, GitHub or prod system was touched. The live run is OWNER-GATED (`docs/ptycap-05-proof-runbook.md`); Phase 5 stays unchecked until SC-3 closes live, so SC-2/SC-3 are "armed-ready, live proof pending owner GO", never PASS. Deferred: the automation `term.input` PTY producer (D-01, drives the stream-json macro path instead). Recorded dependency: arming refuses `proof_protection_unverifiable` (`bypass_actors_not_visible`) unless the GitHub App token can see ruleset bypass actors (GitHub shows them only to a caller with write access); that is an owner decision about the App's permission level, with no override path.

### Phase 6: Hardening + Docs + Release

**Goal**: Shipped, documented, verified live.
Expand Down Expand Up @@ -190,9 +211,9 @@ fix the CAUSE, and escalates to the human when it cannot.
|-------|--------|
| 1. PTY Token Accounting | In Progress|
| 2. PTY Pre-Flight Gate | Done |
| 3. Governed-Automation Guard | Not started |
| 4. Lifetime Counter + Kill Switch | Not started |
| 5. Throwaway-Repo Due→PR Proof | Not started |
| 3. Governed-Automation Guard | Complete (4/4 plans) - PR #505 open |
| 4. Lifetime Counter + Kill Switch | Executed (8/8 plans) - QC BLOCKED (2 open races), draft PR #506 |
| 5. Throwaway-Repo Due→PR Proof | Executed (9/9 plans) - QC BLOCKED (2 open MAJOR), draft PR - live proof pending owner GO |
| 6. Hardening + Docs + Release | Not started |
| 7. Unified Self-Heal Routing | Specced, not started (blocked on #346 + Phase 4) |
| 8. Periodic Task QC + Optimization | Specced, not started (blocked on Phase 4) |
Expand Down
42 changes: 30 additions & 12 deletions .planning/STATE.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
---
gsd_state_version: 1.0
gsd_state_version: "1.0"
milestone: PTYCAP
milestone_name: Milestone PTYCAP (Token-Gate the Interactive PTY Path)
current_phase: 02
current_phase_name: pty-preflight-gate
current_phase: 04
current_phase_name: lifetime-inject-counter-kill-switch
status: executing
last_updated: "2026-09-28T00:00:00.000Z"
stopped_at: PTYCAP-04 executed 8/8 plans; QC BLOCKED after 2 fix rounds (2 open HIGH races); draft PR #506
last_updated: "2026-10-13T18:00:00.000Z"
last_activity: 2026-09-28
last_activity_desc: BLEED milestone reconciled CLOSED (all four fixers verified shipped on main); milestone pointer advanced to PTYCAP; Phase 1 confirmed shipped (#395); Phase 2 execution started
last_activity_desc: "BLEED milestone reconciled CLOSED (all four fixers verified shipped on main); milestone pointer advanced to PTYCAP; Phase 1 confirmed shipped (#395); Phase 2 execution started"
state_head: a745ab9efb8e26c340e87a1f56cc55d3b2f35497
progress:
total_phases: 9
completed_phases: 1
total_plans: 4
completed_plans: 4
percent: 11
completed_phases: 3
total_plans: 17
completed_plans: 16
percent: 33
---

> **BLEED milestone reconciled CLOSED 2026-09-28.** This file and `.planning/PROJECT.md` had
Expand Down Expand Up @@ -89,9 +91,9 @@ connection is the Tauri Supervisor MSI.

## Current position

Phase: PTYCAP-02 (pty-preflight-gate) — EXECUTING
Status: Executing Phase PTYCAP-02 (Phase 1, pty-token-accounting, shipped complete via #395)
Last activity: 2026-09-28 — BLEED reconciled closed; PTYCAP-02 execution started
Phase: PTYCAP-04 (lifetime-inject-counter-kill-switch) - EXECUTED, QC BLOCKED (stacked on PTYCAP-03 / PR #505)
Status: 8/8 plans executed (branch phase-ptycap-04-lifetime-counter-kill-switch, draft PR #506 base main for Woodpecker postgres). /qc: 2 fix rounds done (B1+5 MAJOR+4 minor, then R1-R3); Codex still OPEN on 2 HIGH races: (a) orphan-resume reopen UPDATE...NOT EXISTS needs the per-user advisory lock launchOrchestrator holds; (b) supervisor/teab/work senders rearm once tasks on schedule_kind alone, must gate on onceClaimed. Verifier NO-SHIP at 8447cdf (CI red: 2 e2e fixture defects, fixed in bf3f51d, CI re-run pending).
Last activity: 2026-10-13 - PTYCAP-04 executed + QC'd; BLOCKED on findings (a)(b) per the 2-round QC cap

### OBSRV phase ledger (`.planning/phases/`)

Expand Down Expand Up @@ -144,3 +146,19 @@ reset 2026-05-29 to unblock owner login. `jamie@theleadingpractice.com` is NOT a
| Date | Slug | Summary | Commits |
|---|---|---|---|
| 2026-09-27 | cloud-sessions | Chat with claude.ai cloud sessions: `claude -p --cloud` send + Stop-hook reply webhook | 4f9b35b..83abd55 |

## Performance Metrics

| Plan | Duration | Tasks | Files |
|------|----------|-------|-------|
| Phase PTYCAP-03 P01 | 25min | 3 tasks | 10 files |

## Decisions

- [Phase PTYCAP-03]: 03-01: governedAutomationPtyGate hard-renamed (no alias); flag REMO_GOVERNED_AUTOMATION_PTY default OFF is a proven no-op; kill_switch and lifetime_counter are fail-closed Phase-4 slots — Differential vs frozen legacy oracle; D-02/D-04/D-05/D-06

## Session

**Last session:** 2026-10-07T23:32:22.340Z
**Stopped at:** Completed PTYCAP-03-01-PLAN.md
**Resume file:** None
12 changes: 6 additions & 6 deletions .planning/architecture/SESSION-ASK-API-SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Two independent walls, both live in prod (`REMO_PTY_INTERACTIVE=1` since the 202
**Wall A — the gate.** `sessions.runner_type` is `'stream-json' | 'pty-interactive'`
(`hub/src/db/schema.sql:615–621`). The human web/phone surface runs `pty-interactive`.
`humanOnlyRejectsActor(actor, runnerType)` (`hub/src/dispatch/gates.ts:371–374`) returns true
for **any** actor ≠ `'human'` when `runnerType === 'pty-interactive'`, and `humanOnlyPtyGate`
for **any** actor ≠ `'human'` when `runnerType === 'pty-interactive'`, and `governedAutomationPtyGate`
(gates.ts:388–401) turns that into `automation_blocked_on_pty:<actor>`. An external ask is
by definition non-human (server-inferred from an api_key), so it is rejected before send.

Expand All @@ -71,7 +71,7 @@ prod (#247) and Telegram outbound falls back to the host-agnostic stream-json ev
`~/.claude/projects/.../memory/project_direction_pty_orchestrator_monetize.md` (2026-07-12):
the owner has **deliberately** decided automation will eventually drive the interactive PTY,
with a **mandatory ordering**: (1) caps proven on all dispatch paths, (2) **cap the PTY path
FIRST** (it has no token gate today; usage is post-hoc), (3) *then* relax `humanOnlyPtyGate`
FIRST** (it has no token gate today; usage is post-hoc), (3) *then* relax `humanOnlyPtyGate` (renamed governedAutomationPtyGate in PTYCAP Phase 3)
into a governed-automation gate (new flag, default OFF, server-inferred actor), (4) prove
due→PR, (5) 30-night receipts.

Expand Down Expand Up @@ -164,12 +164,12 @@ Desktop doesn't have to memorize UUIDs.

- `token: 'ask:<ask_id>'` (queue token + finalize key).
- **Gates, in order — all non-bypassable:**
`thresholdGate` → `dailyCostCapGate` → **`dailyTokenCapGate`** → `humanOnlyPtyGate` →
`thresholdGate` → `dailyCostCapGate` → **`dailyTokenCapGate`** → `governedAutomationPtyGate` →
`askRateGate` (new: N asks/hour/session, default 10) → `concurrencyGate(supervisorId)` when
autospawning.
`dailyTokenCapGate` is mandatory on every gate list and is scanned by
`hub/test/token-cap-coverage.test.ts` — a new `gates: [...]` array missing it **fails CI**.
`humanOnlyPtyGate` stays in the list: if the resolved target is a `pty-interactive` row, the
`governedAutomationPtyGate` stays in the list: if the resolved target is a `pty-interactive` row, the
ask is **rejected** (`automation_blocked_on_pty:external-ask`) rather than silently
redirected — the redirect to a stream-json ask-session is an explicit resolution step
(§2.1), decided *before* dispatch, not a gate bypass.
Expand Down Expand Up @@ -229,7 +229,7 @@ guard test (`hub/test/automation-routing-guard.test.ts`) still passes.
2. Supervisor→hub **transcript streaming** over `/ws/agent` (new `transcript_delta` /
`turn_complete` frames) so the hub can extract a reply from a PTY without reading the
supervisor's disk. Requires a new signed MSI.
3. `humanOnlyPtyGate` → `governedAutomationGate` (new flag, default OFF, server-inferred
3. `humanOnlyPtyGate` → `governedAutomationPtyGate` (new flag, default OFF, server-inferred
actor, + lifetime per-ask counter + kill switch).
Until all three exist, **a PTY-native ask is not implementable and must not be attempted.**

Expand Down Expand Up @@ -292,7 +292,7 @@ only escalate to `remo_ask` when the free reads are inconclusive.
| **1. Read surface (do this first)** | External api-key-authed READ of a session's transcript tail + memory + state. Zero tokens, zero PTY writes, works for PTY *and* stream-json sessions. | supervisor: new allowlisted `session_transcript_tail` / `session_memory` commands (registry alongside `teab_run`); reuse `hub/src/telegram/transcript/{claude,codex}-adapter.ts` for parsing. hub: `hub/src/api/ext.ts` (`/sessions`, `/:id/transcript`, `/:id/memory`, `/:id/state`), mount in `hub/src/index.ts` after L248, `api_keys.scopes` DDL in `schema.sql`, `hub/test/mount-order.test.ts` case. | **Needs a new signed supervisor MSI.** |
| **2. Ask** | `POST /api/ext/sessions/:id/ask` + poll/long-poll, answered by a stream-json ask-session bound to the target's `project_dir`. | `hub/src/ask/{dispatch,result-schema,prompt,reaper}.ts` (mirroring `hub/src/revanote/*`), `session_asks` DDL, ask-session resolution/autospawn reusing `launchSessionForUser`, gates list incl. `dailyTokenCapGate` + new `askRateGate` in `hub/src/dispatch/gates.ts`, finalize hook wired via existing `onSessionReply` (no change to `hub/src/ws/agent.ts:729`). | Hub-only. No supervisor change, no PTY change, no gate relaxation. |
| **3. MCP server** | `mcp-servers/apps/remo-code/` (5 tools above) + gateway registration + `docs/api.md` regen (`bun run docs:sync`). | `mcp-servers/apps/remo-code/*`, remo-code `hub/src/api/_openapi.ts` + `docs/api.md`. | — |
| **4. PTY-native ask (OWNER-GATED — do not start early)** | Ask the *live* human PTY session and read its reply. | (a) token gate on the PTY path; (b) supervisor `transcript_delta`/`turn_complete` frames on `/ws/agent` + hub-side consumer replacing the disk tail; (c) `humanOnlyPtyGate` → `governedAutomationGate` (new flag, default OFF, lifetime ask counter, kill switch). | Blocked on the owner's mandatory ordering in `project_direction_pty_orchestrator_monetize`. |
| **4. PTY-native ask (OWNER-GATED — do not start early)** | Ask the *live* human PTY session and read its reply. | (a) token gate on the PTY path; (b) supervisor `transcript_delta`/`turn_complete` frames on `/ws/agent` + hub-side consumer replacing the disk tail; (c) `humanOnlyPtyGate` → `governedAutomationPtyGate` (new flag, default OFF, lifetime ask counter, kill switch). | Blocked on the owner's mandatory ordering in `project_direction_pty_orchestrator_monetize`. |

### Test strategy

Expand Down
Loading