@evoclock/pi-agentic-driver 0.9.2 → 0.9.4

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.
Files changed (37) hide show
  1. package/PROVENANCE.md +9 -0
  2. package/README.md +178 -73
  3. package/extensions/tasks.ts +570 -0
  4. package/janus/README.md +196 -0
  5. package/janus/janus/audit.ts +213 -0
  6. package/janus/janus/budget.ts +101 -0
  7. package/janus/janus/budget_breaker.ts +105 -0
  8. package/janus/janus/config.ts +332 -0
  9. package/janus/janus/errors.ts +90 -0
  10. package/janus/janus/evaluate.ts +230 -0
  11. package/janus/janus/keychain.ts +119 -0
  12. package/janus/janus/providers.ts +544 -0
  13. package/janus/janus/schema.ts +344 -0
  14. package/janus/janus/server.ts +267 -0
  15. package/janus/janus/single_flight.ts +99 -0
  16. package/janus/janus/verdict.ts +192 -0
  17. package/janus/package-lock.json +616 -0
  18. package/janus/package.json +29 -0
  19. package/janus/tests/accounting.test.ts +229 -0
  20. package/janus/tests/allowlist.test.ts +97 -0
  21. package/janus/tests/config.test.ts +151 -0
  22. package/janus/tests/errors.test.ts +147 -0
  23. package/janus/tests/evaluate_pipeline.test.ts +358 -0
  24. package/janus/tests/helpers.ts +217 -0
  25. package/janus/tests/providers.test.ts +292 -0
  26. package/janus/tests/redaction_budget.test.ts +227 -0
  27. package/janus/tests/schema.test.ts +356 -0
  28. package/janus/tests/server.test.ts +288 -0
  29. package/janus/tests/single_flight.test.ts +84 -0
  30. package/janus/tsconfig.json +19 -0
  31. package/janus/user.janus.plist +51 -0
  32. package/package.json +7 -2
  33. package/scripts/enforcement/router_schemas_pi.js +63 -13
  34. package/scripts/enforcement/session_tasks_core_pi.js +605 -0
  35. package/scripts/enforcement/session_tasks_validate_pi.js +235 -0
  36. package/skills/tasks/SKILL.md +110 -0
  37. package/templates/AGENTS.md +11 -0
package/PROVENANCE.md CHANGED
@@ -72,3 +72,12 @@ This repository is the public package source for `@evoclock/pi-agentic-driver`.
72
72
  change it, the switch is not persisted, and each microVM run still requires
73
73
  native confirmation. Headless sessions fail closed. The existing trusted
74
74
  facts, fixed argv, receipt validation, and cleanup checks remain unchanged.
75
+ - The unified tasks skill (session task tools + owner-initiated TaskPromote)
76
+ reimplements the documented behavior of @ladbabynpm/picc-tasks v0.2.0 (MIT,
77
+ Copyright (c) 2026 Ladbaby) as prior art: the same tool names, the same
78
+ storage model (session JSONL snapshot entries plus a disk mirror at
79
+ ~/.pi/tasks/{taskListId}/tasks.json), and the same result text. No code is
80
+ copied; this is a clean AGPL-3.0-only reimplementation to the same behavior
81
+ spec, so no MIT license text is vendored. picc-tasks is an independent
82
+ project by its author, used as reference; it is not affiliated with, nor
83
+ does it endorse, pi-agentic-driver.
package/README.md CHANGED
@@ -43,6 +43,7 @@ proofs for agentic workflows.
43
43
  | Tool | What it does | Status |
44
44
  |------|--------------|--------|
45
45
  | `code_phage` | Reviews a plan against a stated goal before code is written and advises your agent. | shipped |
46
+ | `tasks` | Keeps a session plan close to the work, then lets the owner make selected items durable in `TASKS.md`. | shipped |
46
47
  | `agentic_herdr_communication` | Exchanges marked reports with worker agents; never grants authority. | shipped |
47
48
  | `agentic_herdr_spawn_worker` | Starts one Pi worker in a pane or tab, with native confirmation. | shipped |
48
49
  | `agentic_aidr` | A remedy for AI;DR. Reviews writing for clarity, simplicity, brevity, and humanity. | shipped |
@@ -53,6 +54,8 @@ proofs for agentic workflows.
53
54
  | `agentic_kanban_board_update` | Moves, closes, flags, edits, or removes cards on the board, always recording who authorized the change. | shipped |
54
55
  | `agentic_kanban_board_dispatch` | Claims an eligible board card for automated contained work and creates its assignment envelope. | shipped |
55
56
  | `agentic_kanban_pulse` | Checks for ready work and available capacity, then starts assignments under the board policy. | shipped |
57
+ | Router | Capacity/policy routing for Board Pulse: seats with scope statements, tunable policy values, and a binding dispatch gate. | shipped |
58
+ | Janus (bundled service) | Local Jev evaluation service on loopback: semantic ranking, the dispatch-gate judgment, redaction before every external call. See `janus/README.md`. | shipped |
56
59
 
57
60
  **Status: active development and testing.** Each extension ships only after
58
61
  it passes fixture-based acceptance, native tests, live-session checks, and
@@ -93,14 +96,169 @@ only, not a runtime dependency).
93
96
 
94
97
  </details>
95
98
 
99
+ <details>
100
+ <summary><strong>tasks, from session plan to durable work</strong> <em>(shipped)</em></summary>
101
+
102
+ Plans stay close to the work. They do not become board work by accident. The tasks skill gives Pi a familiar session list. It adds an owner-approved way to keep selected tasks in the durable `TASKS.md` board.
103
+
104
+ - **Keep the working list simple.** Use `TaskCreate`, `TaskGet`, `TaskList`, and `TaskUpdate` as usual.
105
+ - **Make durable work deliberate.** `TaskPromote` never runs automatically. It previews the exact cards and destination before the owner confirms.
106
+ - **Keep authority clear.** The trusted board writer creates and updates `TASKS.md`. The skill does not bypass it.
107
+ - **Make migration gentle.** Existing task files remain readable. Moving to the driver-owned skill does not strand current plans.
108
+
109
+ The result is a clean handoff from a session plan to durable work. Selected tasks can survive the session, appear on the shared board, and become available for controlled dispatch when ready.
110
+
111
+ </details>
112
+
113
+ **Available now:**
114
+
115
+ - **task-ledger integration.** Agents can read and act within board card
116
+ states while the trusted writer retains authority over admission,
117
+ completion, reconciliation, and migration. The Tasks skill also bridges
118
+ session planning to the durable `TASKS.md` board.
119
+ - **role and phase routing.** The router separates planning, implementation,
120
+ review, and escalation phases. It reports endpoint warm state when
121
+ configured. Warm-session preference remains future work; route affinity
122
+ never overrides authority.
123
+
124
+ **Planned in this theme:**
125
+
126
+ - **prompted planning lifecycle.** Turn natural-language goals into complete
127
+ proposals with parent and scope choices at native boundaries. No retry
128
+ loops or model-supplied identifiers.
129
+ - **native assignment selection.** Choose planned assignments through a
130
+ native UI over derived candidates, never through model-supplied targets.
131
+ - **inventory refresh.** Regenerate the Git-aware codebase inventory with
132
+ verification receipts so prior-art matching stays honest.
133
+ - **project status and state review.** Add read-only views of workspace Git
134
+ state, formal records, and task-state health.
135
+
136
+ <details>
137
+ <summary><strong>router, capacity/policy routing with a binding dispatch gate</strong> <em>(released, 0.9.2)</em></summary>
138
+
139
+ Board Pulse selects a route seat through the capacity/policy router. The
140
+ router reads a closed configuration file and a local-first SQLite file for
141
+ operational state (reservations, observations, route-decision audit).
142
+
143
+ Two router features call **Janus** — a separate local service, bundled under
144
+ `janus/`, that is the only component allowed to talk to the TypeSafe Jev
145
+ models:
146
+
147
+ - **Semantic ranking** (optional): Janus ranks up to eight eligible seats;
148
+ on any Janus failure the router falls back to preference order.
149
+ - **The binding dispatch gate**: before a task is claimed, Janus judges
150
+ whether the task fits the selected seat. No verdict, no dispatch — the
151
+ gate fails closed when Janus is unreachable.
152
+
153
+ Janus binds loopback only (`127.0.0.1:8787`), reads its API key from the
154
+ macOS Keychain at runtime, redacts state before every external call, and
155
+ coalesces identical requests. See `janus/README.md` for the endpoint
156
+ contract, Keychain provisioning, and configuration.
157
+
158
+ - **Repository defaults** ship at `.agentic-driver/router.defaults.json`. The
159
+ template contains no accounts and one disabled placeholder seat, so it loads
160
+ out of the box and schedules nothing until you enable a real seat.
161
+ - **User profile (precedence over defaults):**
162
+ `~/.config/agentic-driver/router/profile.json`, or the path in the
163
+ `AGENTIC_DRIVER_ROUTER_PROFILE` environment variable. A profile section
164
+ replaces the matching defaults section wholesale; the merged config must
165
+ validate or the router refuses to produce decisions (fails closed).
166
+ - **Operational state:** `~/.local/share/agentic-driver/router/state.db`, or
167
+ `AGENTIC_DRIVER_ROUTER_DB`. This store is operational state only. The
168
+ authenticated claims file and the board writer remain the only dispatch
169
+ authority; the system repairs SQLite from them, never the reverse.
170
+ - **Runtime requirement:** the operational store uses the built-in
171
+ `node:sqlite` module. You need Node.js 22.5 or newer.
172
+
173
+ <details>
174
+ <summary><strong>Tunable configuration values</strong> <em>(all keys required, defaults are conservative starting values)</em></summary>
175
+
176
+ Every numeric policy in the router is a configuration key — never a
177
+ constant in code. All keys are **required**. The repository defaults below
178
+ are conservative starting values. Your profile overrides them. A missing key
179
+ is a configuration validation failure: the router fails closed rather than
180
+ guess. Changing a value participates in the configuration digest, so cached
181
+ routing decisions computed under the old values no longer apply.
182
+
183
+ | Section | Key | Default | What it controls |
184
+ |---|---|---|---|
185
+ | `eligibility.reserve` | `floorPercent` | 40 | Share of every quota window kept in reserve (per account, per window). Headroom for an unexpected burst and your next interactive session, without idling the account. |
186
+ | `eligibility.reserve` | `scope` | `account-window` | How widely the reserve floor applies (per account per window at launch). |
187
+ | `eligibility.reserve` | `coldStartFraction` | 0.25 | Consumption assumed for a seat with too little history: deliberately generous, so a mis-estimate fails eligibility instead of draining the account. |
188
+ | `eligibility.reserve` | `estimateSamples` | 20 | How many recent dispatches the consumption estimate averages: enough to smooth outliers, quick enough to track a model change. |
189
+ | `eligibility.reserve` | `estimateMinSamples` | 5 | Below this many observations, the estimator treats the average as noise and uses the cold-start value instead. |
190
+ | `eligibility.reserve` | `estimateOutlierSigma` | 3 | Outlier cut for the estimate: one unusually slow dispatch cannot inflate the average, real tail latency is kept. |
191
+ | `eligibility.reserve` | `ownerInteractiveOverride` | false | Whether your own interactive dispatches bypass the reserve rule (they do not, at launch). |
192
+ | `ranking` | `janusUrl` | `http://127.0.0.1:8787` | The local Janus evaluation service endpoint used for semantic ranking. |
193
+ | `ranking` | `maxCandidates` | 8 | The router ranks at most eight eligible seats per request; preference order trims the list first. |
194
+ | `ranking` | `fallback` | `preference-order` | What happens when ranking is unavailable: dispatch falls back to your preference order and never blocks. |
195
+ | `gate` | `threshold` | 0.9 | The dispatch gate's confidence threshold. A task is only dispatched when the evaluation clears it. Lower it only with evidence from your own audit log. |
196
+ | `gate` | `timeoutMs` | 8000 | How long the gate waits for an evaluation. On timeout there is no verdict, and the gate blocks dispatch (fail closed). |
197
+ | `gate` | `requestBudgetTokens` | 30000 | Maximum size of a gate evaluation request. Normal evaluations use under a thousand tokens. |
198
+ | seat record | `maxConcurrency` | 4 | How many workers one seat may run at once. The default suits a typical single machine or hosted seat. Tune it per seat: a cluster takes more, a constrained subscription endpoint may take less. |
199
+ | automation policy | `maxConcurrent` | 4 | How many workers may run at once across all seats. The default is a conservative start. Tune it to the capacity you actually have, and raise it when you add seats or hardware. |
200
+
201
+ Seats are named for infrastructure, not models: `dgx-spark`,
202
+ `dgx-spark-cluster`, `mac-studio`, `mac-studio-cluster`, `strix-halo`,
203
+ `strix-halo-cluster`, `merge-gateway-worker`. The model is a mutable field on
204
+ the seat, so changing models never renumbers your configuration. Each seat
205
+ also carries `scopeStatements`: plain-language descriptions of what the seat
206
+ is for. The dispatch gate reads them when judging whether a task fits.
207
+
208
+ </details>
96
209
 
97
- - **prompted planning lifecycle.** Natural-language goals become complete
98
- semantic proposals with parent and scope choices at native boundaries. No
99
- retry loops, no model-supplied identifiers.
100
- - **native assignment selection.** Planned assignments are chosen through a
101
- native UI over derived candidates, never by model-supplied targets.
102
- - **inventory refresh.** Git-aware codebase inventory regeneration with
103
- verification receipts, so prior-art matching stays honest.
210
+ </details>
211
+
212
+ <details>
213
+ <summary><strong>Janus, local Jev evaluation service</strong> <em>(shipped)</em></summary>
214
+
215
+ Janus is the local evaluation service bundled in this repository under
216
+ `janus/`. It is the only component allowed to talk to the TypeSafe Jev
217
+ model. It wraps the official TypeSafe SDK. It exposes one evaluation endpoint
218
+ and health probes on loopback. The router's semantic ranking and binding
219
+ dispatch gate call it. Nothing else in the harness talks to Jev directly.
220
+
221
+ **Guarantees:**
222
+
223
+ - **Loopback only.** Janus binds `127.0.0.1:8787` and nothing else. There is
224
+ deliberately no bind-address option: it is a local tool.
225
+ - **Key stays in the macOS Keychain.** Janus reads the TypeSafe API key at
226
+ runtime with a guarded `security` lookup. It never passes the key to
227
+ subprocesses. It never writes the key to logs or transcripts.
228
+ - **Redaction before every external call.** A secrets/PII pass runs over the
229
+ state before anything leaves the machine. No disable knob exists.
230
+ - **Single-flight.** Janus coalesces identical requests. It caps distinct
231
+ in-flight evaluations. It rejects overflow with `busy` instead of queuing
232
+ silently.
233
+ - **Controlled requests.** Janus enforces a 30k-token request budget. It
234
+ rejects oversized requests instead of truncating them.
235
+
236
+ **Running it:**
237
+
238
+ ```sh
239
+ cd janus
240
+ ```
241
+
242
+ ```sh
243
+ npm install
244
+ ```
245
+
246
+ ```sh
247
+ npx tsx janus/server.ts
248
+ ```
249
+
250
+ For a persistent setup, use the launchd template at
251
+ `janus/user.janus.plist`. Provision the TypeSafe Direct key once in the
252
+ Keychain. The command is in `janus/README.md`.
253
+
254
+ **When Janus is down:** semantic ranking falls back to preference order. The
255
+ binding dispatch gate blocks dispatch and fails closed. Janus never becomes a
256
+ silent dependency: its absence is loud.
257
+
258
+ See `janus/README.md` for the full endpoint contract, the error taxonomy, and
259
+ configuration.
260
+
261
+ </details>
104
262
 
105
263
  ## Multi-agent communication
106
264
 
@@ -504,20 +662,21 @@ silently allowed.
504
662
 
505
663
  *Extensions that keep routine Git low-friction and consequential Git guarded.*
506
664
 
507
- **In development:**
665
+ **Planned:**
508
666
 
509
- - **git workflow safeguards.** Design only; the package contains no Git
510
- extension yet. The planned capability covers exact-file staging, native
511
- confirmation, post-confirmation drift checks, and protected-operation
512
- boundaries.
513
- - **assignment-aware Git journeys.** Merge and protected-push flows bound to
514
- a verified assignment, so consequential Git operations carry their own
515
- recorded provenance.
667
+ - **git workflow safeguards.** Not packaged yet. The planned capability covers
668
+ exact-file staging, native confirmation, post-confirmation drift checks,
669
+ and protected-operation boundaries.
670
+ - **assignment-aware Git journeys.** Planned merge and protected-push flows
671
+ bound to a verified assignment, so consequential Git operations carry their
672
+ own recorded provenance.
516
673
 
517
674
  ## Package integrity
518
675
 
519
676
  *Extensions that keep the installed set honest and the record controlled.*
520
677
 
678
+ **Planned:**
679
+
521
680
  - **security and integrity scanning.** Static scanning of MCP configs, agent
522
681
  skills, and extension packages for hardcoded secrets, prompt and shell
523
682
  injection, data-exfiltration endpoints, untrusted integrations, PII
@@ -575,64 +734,10 @@ extensions you want with the object form in your Pi settings:
575
734
  }
576
735
  ```
577
736
 
578
- The package includes the `herdr-communication.ts`, `herdr-lifecycle.ts`, and
579
- `herdr-dispatch.ts` extensions. It also includes `linux-microvm.ts`. Use `pi config` to enable or
580
- disable individual resources from an installed package. You are not required
581
- to use every extension.
582
-
583
- ## Router configuration
584
-
585
- Board Pulse selects a route seat through the capacity/policy router. The
586
- router reads a closed configuration file and a local-first SQLite file for
587
- operational state (reservations, observations, route-decision audit).
588
-
589
- - **Repository defaults** ship at `.agentic-driver/router.defaults.json`. The
590
- template contains no accounts and one disabled placeholder seat, so it loads
591
- out of the box and schedules nothing until you enable a real seat.
592
- - **User profile (precedence over defaults):**
593
- `~/.config/agentic-driver/router/profile.json`, or the path in the
594
- `AGENTIC_DRIVER_ROUTER_PROFILE` environment variable. A profile section
595
- replaces the matching defaults section wholesale; the merged config must
596
- validate or the router refuses to produce decisions (fails closed).
597
- - **Operational state:** `~/.local/share/agentic-driver/router/state.db`, or
598
- `AGENTIC_DRIVER_ROUTER_DB`. This store is operational state only. The
599
- authenticated claims file and the board writer remain the only dispatch
600
- authority, and SQLite is repaired from them, never the reverse.
601
- - **Runtime requirement:** the operational store uses the built-in
602
- `node:sqlite` module. Node.js 22.5 or newer is required.
603
-
604
- ### Tunable configuration values
605
-
606
- Every numeric policy in the router is a configuration key — never a
607
- constant in code. All keys are **required**. The repository defaults below
608
- are conservative starting values. Your profile overrides them. A missing key
609
- is a configuration validation failure: the router fails closed rather than
610
- guess. Changing a value participates in the configuration digest, so cached
611
- routing decisions computed under the old values no longer apply.
612
-
613
- | Section | Key | Default | What it controls |
614
- |---|---|---|---|
615
- | `eligibility.reserve` | `floorPercent` | 40 | Share of every quota window kept in reserve (per account, per window). Headroom for an unexpected burst and your next interactive session, without idling the account. |
616
- | `eligibility.reserve` | `scope` | `account-window` | How widely the reserve floor applies (per account per window at launch). |
617
- | `eligibility.reserve` | `coldStartFraction` | 0.25 | Consumption assumed for a seat with too little history: deliberately generous, so a mis-estimate fails eligibility instead of draining the account. |
618
- | `eligibility.reserve` | `estimateSamples` | 20 | How many recent dispatches the consumption estimate averages: enough to smooth outliers, quick enough to track a model change. |
619
- | `eligibility.reserve` | `estimateMinSamples` | 5 | Below this many observations the average is treated as noise and the cold-start value is used instead. |
620
- | `eligibility.reserve` | `estimateOutlierSigma` | 3 | Outlier cut for the estimate: one unusually slow dispatch cannot inflate the average, real tail latency is kept. |
621
- | `eligibility.reserve` | `ownerInteractiveOverride` | false | Whether your own interactive dispatches bypass the reserve rule (they do not, at launch). |
622
- | `ranking` | `janusUrl` | `http://127.0.0.1:8787` | The local janus evaluation service endpoint used for semantic ranking. |
623
- | `ranking` | `maxCandidates` | 8 | At most eight eligible seats are ranked per request; preference order trims first. |
624
- | `ranking` | `fallback` | `preference-order` | What happens when ranking is unavailable: dispatch falls back to your preference order and never blocks. |
625
- | `gate` | `threshold` | 0.9 | The dispatch gate's confidence threshold. A task is only dispatched when the evaluation clears it. Lower it only with evidence from your own audit log. |
626
- | `gate` | `timeoutMs` | 8000 | How long the gate waits for an evaluation. On timeout there is no verdict and dispatch is blocked (fail closed). |
627
- | `gate` | `requestBudgetTokens` | 30000 | Maximum size of a gate evaluation request. Normal evaluations use under a thousand tokens. |
628
- | seat record | `maxConcurrency` | 4 | How many workers one seat may run at once. The default suits a typical single machine or hosted seat. Tune it per seat: a cluster takes more, a constrained subscription endpoint may take less. |
629
- | automation policy | `maxConcurrent` | 4 | How many workers may run at once across all seats. The default is a conservative start. Tune it to the capacity you actually have, and raise it when you add seats or hardware. |
630
-
631
- Seats are named for infrastructure, not models: `dgx-spark-cluster`,
632
- `mac-studio`, `merge-gateway-worker`. The model is a mutable field on the
633
- seat, so changing models never renumbers your configuration. Each seat also
634
- carries `scopeStatements`: plain-language descriptions of what the seat is
635
- for. The dispatch gate reads them when judging whether a task fits.
737
+ The package includes the Herdr communication, lifecycle, and dispatch
738
+ extensions, the board and Tasks extensions, and `linux-microvm.ts`. Use
739
+ `pi config` to enable or disable individual resources from an installed
740
+ package. You are not required to use every extension.
636
741
 
637
742
  ## License
638
743