@evoclock/pi-agentic-driver 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +736 -0
- package/PROVENANCE.md +69 -0
- package/README.md +325 -0
- package/config/herdr-worker-repositories.v1.json +9 -0
- package/extensions/aidr.ts +5 -0
- package/extensions/code-phage.js +144 -0
- package/extensions/herdr-communication.ts +7 -0
- package/extensions/herdr-lifecycle.ts +7 -0
- package/extensions/linux-microvm.ts +10 -0
- package/lib/adapters/diff-scope.mjs +148 -0
- package/lib/adapters/evidence.mjs +151 -0
- package/lib/adapters/narrative.mjs +171 -0
- package/lib/adapters/review-feedback.mjs +77 -0
- package/lib/adapters/visualization.mjs +176 -0
- package/lib/code-phage-core.mjs +882 -0
- package/lib/python_ast_metrics.py +378 -0
- package/lib/typescript_ast_metrics.mjs +441 -0
- package/package.json +50 -0
- package/scripts/aidr_writing_review.js +468 -0
- package/scripts/enforcement/herdr_communication_pi.js +1198 -0
- package/scripts/enforcement/herdr_lifecycle_pi.js +902 -0
- package/scripts/enforcement/linux_microvm_cutover_pi.js +328 -0
- package/scripts/enforcement/linux_microvm_remote_fixture.sh +366 -0
- package/scripts/enforcement/native_tui_context.js +11 -0
- package/templates/AGENTS.md +72 -0
package/PROVENANCE.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Provenance
|
|
2
|
+
|
|
3
|
+
This repository is the public package source for `@evoclock/pi-agentic-driver`.
|
|
4
|
+
|
|
5
|
+
- Release 0.1.1 content originates from the reviewed private development
|
|
6
|
+
repository, qualified through the acceptance environment (fixtures,
|
|
7
|
+
native tests, live-session checks, and independent model review) before
|
|
8
|
+
publication. Tarball sha256 for the qualified 0.1.1 artifact:
|
|
9
|
+
`5ac35b7873d7fa8cd45e718d900d562302f9fbe0fd4bdcbe067718a637f9c946`.
|
|
10
|
+
- This initial public commit adds SPDX headers, the project README, this
|
|
11
|
+
provenance note, and the package licence metadata; behaviour is unchanged
|
|
12
|
+
from the qualified artifact. Future releases are built from this
|
|
13
|
+
repository so each tag matches its tarball exactly.
|
|
14
|
+
- No third-party code is bundled. Concept credit for the cognitive-
|
|
15
|
+
complexity signals is recorded in the README and the extension
|
|
16
|
+
description; no code was copied from credited sources.
|
|
17
|
+
- Release 0.2.0 adds the existing reviewed Linux microVM closure. Native
|
|
18
|
+
qualification on 5 September 2026 used fixture
|
|
19
|
+
`microvm-220fc33307638cda1d9fd4c6` on `ubuntu-backend` and returned
|
|
20
|
+
`VERIFIED`. The retained probe marker hash is
|
|
21
|
+
`043d2846707b67eb4a1e4e577ff070346da881d713b91d0f905da96ea68b4844`;
|
|
22
|
+
the fixture script hash is
|
|
23
|
+
`05e9071c027a128c7cd2e20d126fbdd7915d093c9f91047d6fe67d26e01849b1`;
|
|
24
|
+
and the initramfs hash is
|
|
25
|
+
`721de3392f8d975cd0c1f46190ee266c7e0cb3c50e93c4af3bc5d411bc8ab523`.
|
|
26
|
+
The transient domain was checked absent, the initramfs entry was removed,
|
|
27
|
+
and ACL before/after hashes were equal
|
|
28
|
+
(`31de5110ae73bbece4c86ea49b0338c2f933ed372a409abc9d8108b3d0f61ebd`).
|
|
29
|
+
No disk, host share, credentials, GPU, network, authority, or persistent
|
|
30
|
+
runtime was created. The native macOS Container runtime was separately
|
|
31
|
+
qualified with local image digest
|
|
32
|
+
`sha256:0019eef4a42554b1ad94d7c42203a1c58f964714eac60e7d9559742ee3ad494f`;
|
|
33
|
+
its fixed read-only `/workspace`, no-network `/bin/pwd` probe returned
|
|
34
|
+
`/workspace` and `--rm` removal was verified. A native macOS Pi adapter is
|
|
35
|
+
not claimed by this release yet.
|
|
36
|
+
- Release 0.2.1 corrects the isolation mode boundary: microVM/container
|
|
37
|
+
runtime activation is reserved for planned or automated execution paths and
|
|
38
|
+
is not ordinary ad-hoc work. The shipped microVM closure remains qualified
|
|
39
|
+
but activation is deferred until the planned isolation execution path is
|
|
40
|
+
enabled; the adapter now fails closed when that activation flag is absent.
|
|
41
|
+
- Release 0.3.0 adds AI;DR, a read-only writing-review extension. Its profile
|
|
42
|
+
is based on the four stated principles of clarity, simplicity, brevity, and
|
|
43
|
+
humanity, with optional plain-language, analogy, and bullet-structure
|
|
44
|
+
guidance. It captures the last assistant response for review, preserves
|
|
45
|
+
code/frontmatter by excluding fenced prose from analysis, and never edits a
|
|
46
|
+
file automatically; normal confirmed Pi editing remains the write boundary.
|
|
47
|
+
- Release 0.4.0 adds an explicit AI;DR file-apply action and an
|
|
48
|
+
ASD-STE100-informed advisory profile. The profile checks a bounded set of
|
|
49
|
+
controlled-English risks; it does not reproduce the licensed approved-word
|
|
50
|
+
dictionary or certify conformance. ASD-STE100 remains the external
|
|
51
|
+
controlled-language source; no licensed dictionary text is bundled. For file edits, a caller supplies the
|
|
52
|
+
proposed replacement; AI;DR shows a bounded diff preview, requires native
|
|
53
|
+
confirmation, revalidates that the file has not drifted, writes only the
|
|
54
|
+
exact confirmed replacement, and returns before/after hashes. Last-response
|
|
55
|
+
and supplied-text reviews remain read-only.
|
|
56
|
+
- Release 0.4.1 hardens Herdr communication for independent concurrent
|
|
57
|
+
exchanges and repeated terminal history. The transport keeps fixed argv,
|
|
58
|
+
`shell: false`, trusted repository and role checks, exact-once exchange
|
|
59
|
+
semantics, bounded process diagnostics, non-authorizing receipts, and
|
|
60
|
+
strict role-specific report extraction around echoed prompt markers.
|
|
61
|
+
- Release 0.4.2 hardens AI;DR file replacement. Reviews and replacements stay
|
|
62
|
+
bounded. The write path uses a same-directory temporary file, an atomic
|
|
63
|
+
rename, drift revalidation, exact byte verification, and cleanup. Apply is
|
|
64
|
+
available only for files and remains behind native confirmation.
|
|
65
|
+
- Release 0.4.3 removes legacy lifecycle-mode files from the shipped public
|
|
66
|
+
package. The Linux isolation and Herdr lifecycle interfaces share a small
|
|
67
|
+
native-TUI predicate and remain fail-closed. This release also adds the
|
|
68
|
+
portable `templates/AGENTS.md` repository contract. The release artifact is
|
|
69
|
+
built from this repository revision.
|
package/README.md
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# pi-agentic-driver v0.4.3
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="assets/Yamagane-origami.png" alt="pi-agentic-driver — Yamagane origami mark" width="140"/>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-AGPL%20v3-blue?style=flat" alt="License: AGPL v3"/></a>
|
|
9
|
+
<img src="https://img.shields.io/badge/version-0.4.3-blue?style=flat" alt="Version 0.4.3"/>
|
|
10
|
+
<img src="https://img.shields.io/badge/status-active%20development%20%26%20testing-orange?style=flat" alt="Status"/>
|
|
11
|
+
<img src="https://img.shields.io/badge/JavaScript-F7DF1E?style=flat&logo=javascript&logoColor=black" alt="JavaScript"/>
|
|
12
|
+
<img src="https://img.shields.io/badge/TypeScript-3178C6?style=flat&logo=typescript&logoColor=white" alt="TypeScript"/>
|
|
13
|
+
<img src="https://img.shields.io/badge/Python-3776AB?style=flat&logo=python&logoColor=white" alt="Python"/>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
Without guardrails, an agent can rewrite code that an existing abstraction
|
|
17
|
+
already covers. It can ship to the wrong remote, lose context, or report
|
|
18
|
+
success without evidence. Pi is an excellent agent harness. I need these
|
|
19
|
+
guardrails for the way I work.
|
|
20
|
+
|
|
21
|
+
**pi-agentic-driver adds these guardrails as Pi extensions. The agent does the
|
|
22
|
+
work. Each extension makes the work verifiable and bounded.** Review happens
|
|
23
|
+
before the agent writes code. Communication carries reports, not authority.
|
|
24
|
+
Isolation proofs verify their own cleanup. Sessions survive compaction and
|
|
25
|
+
handover. Git operations stay exact, confirmed, and protected.
|
|
26
|
+
|
|
27
|
+
Each capability passes fixture-based acceptance, native tests, live-session
|
|
28
|
+
checks, and independent model review before release. We document each
|
|
29
|
+
extension's restrictions before release.
|
|
30
|
+
|
|
31
|
+
Extensions for [Pi](https://github.com/earendil-works/pi-coding-agent):
|
|
32
|
+
advisory code review, bounded role communication, and governed isolation
|
|
33
|
+
proofs for agentic workflows.
|
|
34
|
+
|
|
35
|
+
**Status: active development and testing.** Each extension ships only after
|
|
36
|
+
it passes fixture-based acceptance, native tests, live-session checks, and
|
|
37
|
+
independent model review. You can install released components. This README
|
|
38
|
+
lists pending components for transparency; pending components are not packaged.
|
|
39
|
+
|
|
40
|
+
## Keeping work bounded
|
|
41
|
+
|
|
42
|
+
*Extensions that review, route, and bound what an agent does.*
|
|
43
|
+
|
|
44
|
+
<details>
|
|
45
|
+
<summary><strong>code-phage — advisory code review</strong> <em>(released, 0.1.1)</em></summary>
|
|
46
|
+
|
|
47
|
+
`code_phage` reviews a proposed change against a stated goal before the agent
|
|
48
|
+
writes or commits code. Given a goal, candidate files, accepted requirements,
|
|
49
|
+
and test paths, it:
|
|
50
|
+
|
|
51
|
+
- **Finds prior art structurally** — matches exported symbols, function
|
|
52
|
+
signatures, and dependency imports against a repository inventory, so an
|
|
53
|
+
agent reuses an existing abstraction instead of writing a parallel version.
|
|
54
|
+
Word overlap alone never counts. The implementation requires credit (source,
|
|
55
|
+
version, license) whenever prior art informs it.
|
|
56
|
+
- **Binds an implementation budget** — goal, accepted requirements, write
|
|
57
|
+
set, and tests become one reviewable budget, with coverage checks that
|
|
58
|
+
flag unbound requirements and uncovered tests.
|
|
59
|
+
- **Measures diagnostic signals** — per-function cognitive and cyclomatic
|
|
60
|
+
complexity, line counts, duplication, module-level mutable state,
|
|
61
|
+
dependency lists, test burden, and a rollback proxy. These are signals
|
|
62
|
+
for human judgment, never rejection thresholds.
|
|
63
|
+
- **Redirects scope drift** — it names and excludes files that support no
|
|
64
|
+
accepted requirement, then recommends the smallest coherent write set. The
|
|
65
|
+
deletion test ("what fails if we remove this?") guards justified complexity
|
|
66
|
+
from false-positive flagging.
|
|
67
|
+
- **Stays advisory** — it never mutates files, creates tasks, grants
|
|
68
|
+
authority, or blocks work; every result states `advisoryOnly: true`.
|
|
69
|
+
|
|
70
|
+
Concept credit: Matty Stratton, "Cognitive Complexity" (2024-09-20, concept
|
|
71
|
+
only, no code copied); `flake8-cognitive-complexity` 0.1.0, MIT (concept
|
|
72
|
+
only, not a runtime dependency).
|
|
73
|
+
|
|
74
|
+
</details>
|
|
75
|
+
|
|
76
|
+
**Under development in this theme:**
|
|
77
|
+
|
|
78
|
+
- **prompted planning lifecycle** — natural-language goals derived into
|
|
79
|
+
complete semantic proposals with parent/scope choices at native
|
|
80
|
+
boundaries; no retry loops, no model-supplied identifiers.
|
|
81
|
+
- **native assignment selection** — planned assignments chosen through a
|
|
82
|
+
native UI over derived candidates, never by model-supplied targets.
|
|
83
|
+
- **inventory refresh** — Git-aware codebase inventory regeneration with
|
|
84
|
+
verification receipts, so prior-art matching stays honest.
|
|
85
|
+
|
|
86
|
+
## Communicating without granting authority
|
|
87
|
+
|
|
88
|
+
*Extensions for bounded coordination between agents and boards.*
|
|
89
|
+
|
|
90
|
+
<details>
|
|
91
|
+
<summary><strong>herdr-communication — bounded role communication</strong> <em>(released, 0.2.1)</em></summary>
|
|
92
|
+
|
|
93
|
+
`agentic_herdr_communication` exchanges bounded, marked reports with
|
|
94
|
+
configured Pi worker roles running under [Herdr](https://herdr.dev/)
|
|
95
|
+
0.8.2. Each operation:
|
|
96
|
+
|
|
97
|
+
- **Lists and observes** worker roles (`list`, `get`) filtered to trusted
|
|
98
|
+
repositories only — a checked-in registry plus canonical-path validation;
|
|
99
|
+
the extension denies unlisted or symlink-escaped repositories.
|
|
100
|
+
- **Prompts exactly once** (`prompt`): re-observes the role, sends one
|
|
101
|
+
bounded prompt with a role-specific report contract, waits for terminal
|
|
102
|
+
settlement (`idle`/`done`/`blocked`), and reads exactly one latest
|
|
103
|
+
complete marked report. No retry, no target substitution, no resend on
|
|
104
|
+
timeout.
|
|
105
|
+
- **Waits and reads** (`wait`, `read`) with the same trust checks for
|
|
106
|
+
partial journeys.
|
|
107
|
+
- **Grants nothing** — fixed argv with `shell: false`, a pinned executable,
|
|
108
|
+
the coordinator role class denied, and returns results as untrusted
|
|
109
|
+
evidence (`nonAuthorizing: true`). It cannot control panes, start agents,
|
|
110
|
+
run shells, or create authority.
|
|
111
|
+
|
|
112
|
+
- **Scales to many workers** — the trusted registry accepts up to 32
|
|
113
|
+
worker repositories, and any dynamic non-coordinator role within them
|
|
114
|
+
is eligible; `list` observes every live agent in one call. Fan-out is
|
|
115
|
+
sequential by design: one role per prompt, one complete exchange, no
|
|
116
|
+
broadcast primitive.
|
|
117
|
+
|
|
118
|
+
</details>
|
|
119
|
+
|
|
120
|
+
<details>
|
|
121
|
+
<summary><strong>herdr-lifecycle — role-labelled worker dispatch</strong> <em>(released, 0.2.1)</em></summary>
|
|
122
|
+
|
|
123
|
+
`agentic_herdr_spawn_worker` turns one natural-language request into Herdr's
|
|
124
|
+
native documented lifecycle. Select `right`, `below`, or `tab`; give the
|
|
125
|
+
worker a safe role label; choose a model from the active Pi model roster; and
|
|
126
|
+
name a trusted repository. The extension:
|
|
127
|
+
|
|
128
|
+
- creates a right/down split pane or an individual labelled tab;
|
|
129
|
+
- starts exactly one Pi agent in the returned shell pane;
|
|
130
|
+
- verifies the role, model arguments, pane identity and canonical repository;
|
|
131
|
+
- requires native confirmation before changing layout or starting a process;
|
|
132
|
+
- uses fixed argv with `shell: false`, with no arbitrary Herdr or shell surface;
|
|
133
|
+
- returns explicit `pane_created`, `tab_created`, or `agent_started` partial
|
|
134
|
+
states when only part of the operation succeeds; and
|
|
135
|
+
- never retries, moves, closes, or deletes created state automatically.
|
|
136
|
+
|
|
137
|
+

|
|
138
|
+
|
|
139
|
+
The same request can place a worker below the coordinator or retain it in an
|
|
140
|
+
individual tab:
|
|
141
|
+
|
|
142
|
+
<p>
|
|
143
|
+
<img src="assets/spawn-below-pane.png" alt="A role-labelled worker spawned below the coordinator" width="49%">
|
|
144
|
+
<img src="assets/spawn-worker-tab.png" alt="A role-labelled worker spawned in an individual tab" width="49%">
|
|
145
|
+
</p>
|
|
146
|
+
|
|
147
|
+
See [Dispatching a Multi-Model Workforce from Anywhere](https://evoclock.github.io/fieldnotes/articles/herdr-natural-language-agent-automation.html)
|
|
148
|
+
for the wider task/model-routing and remote-session workflow.
|
|
149
|
+
|
|
150
|
+
</details>
|
|
151
|
+
|
|
152
|
+
**Under development in this theme:**
|
|
153
|
+
|
|
154
|
+
- **project status and state review** — read-only projections of workspace
|
|
155
|
+
Git state, formal records, and task-state health (`/agentic-status`
|
|
156
|
+
family).
|
|
157
|
+
- **role-lane routing and warm sessions** — smart model routing sends work
|
|
158
|
+
to the right model for the job. Separate lanes handle implementation,
|
|
159
|
+
planning, and review. The router prefers a warm session when a lane already
|
|
160
|
+
has an established agent, so context and cache survive across tasks. Route
|
|
161
|
+
affinity is an optimisation, never authority: an incompatible or
|
|
162
|
+
unavailable lane yields an explicit review-required result, never silent
|
|
163
|
+
model substitution. Routing grants no dispatch or shell authority.
|
|
164
|
+
- **worker pulse** — liveness observation and dispatch-eligibility
|
|
165
|
+
observation across role lanes: which agents are alive, what state they
|
|
166
|
+
are in, and what is ready for work. This observation grants no authority;
|
|
167
|
+
the system cannot dispatch planned work without it.
|
|
168
|
+
- **task-ledger integration for planned work** — agents read and act
|
|
169
|
+
within the task ledger's card states (what is dispatchable, in progress,
|
|
170
|
+
blocked) without owning board authority: no admission, completion,
|
|
171
|
+
reconciliation, or migration by the agent itself.
|
|
172
|
+
|
|
173
|
+
## Writing clearly
|
|
174
|
+
|
|
175
|
+
*AI;DR (AI; Didn't Read) keeps technical writing clear without flattening the writer's voice.*
|
|
176
|
+
|
|
177
|
+
<details>
|
|
178
|
+
<summary><strong>AI;DR — writing review</strong> <em>(released, 0.4.2)</em></summary>
|
|
179
|
+
|
|
180
|
+
`agentic_aidr` reviews the last assistant response, supplied prose, or a
|
|
181
|
+
Markdown/documentation file. It checks four principles:
|
|
182
|
+
|
|
183
|
+
- **Clarity:** keep each sentence focused on one useful idea.
|
|
184
|
+
- **Simplicity:** remove clutter, pompous phrases, and needless jargon.
|
|
185
|
+
- **Brevity:** use fewer words when they carry the same meaning.
|
|
186
|
+
- **Humanity:** keep an authentic human voice.
|
|
187
|
+
|
|
188
|
+
The `simple` and `ste` modes also run an ASD-STE100-informed profile. The
|
|
189
|
+
profile checks sentence length, direct word choice, precise verbs, and clear
|
|
190
|
+
requirements, permissions, abilities, and conditions. It uses a 20-word target
|
|
191
|
+
for procedural text and a 25-word target for descriptive text. It returns the
|
|
192
|
+
rule and an example for each finding.
|
|
193
|
+
|
|
194
|
+
Use `simple` for the four principles plus the profile. Use `ste` for a
|
|
195
|
+
profile-focused report. The profile is advisory. It does not include the
|
|
196
|
+
licensed ASD-STE100 approved-word dictionary. It does not certify conformance.
|
|
197
|
+
Check final text against the licensed specification and your project
|
|
198
|
+
terminology list.
|
|
199
|
+
|
|
200
|
+
AI;DR also flags dense paragraphs, suggests bullets when they reduce working
|
|
201
|
+
memory load, and supports plain-language and analogy modes. Review is
|
|
202
|
+
read-only. An explicit file apply action shows a bounded diff and writes the
|
|
203
|
+
exact proposed replacement only after native confirmation. Release 0.4.2 adds
|
|
204
|
+
bounded inputs, atomic replacement, drift checks, and exact write verification.
|
|
205
|
+
|
|
206
|
+
</details>
|
|
207
|
+
|
|
208
|
+
## Executing in isolation
|
|
209
|
+
|
|
210
|
+
*Extensions that prove automation ran — and stopped — exactly as declared.*
|
|
211
|
+
|
|
212
|
+
**In development:**
|
|
213
|
+
|
|
214
|
+
<details>
|
|
215
|
+
<summary><strong>microVM-isolation proof</strong> <em>(qualified, activation deferred)</em></summary>
|
|
216
|
+
|
|
217
|
+
`agentic_linux_microvm_cutover` is the reviewed native proof for a transient
|
|
218
|
+
QEMU/KVM guest on `linux-backend`. It returns a non-authorizing receipt with
|
|
219
|
+
the marker, hashes, isolation context, checked domain teardown, and ACL
|
|
220
|
+
restoration. The live qualification returned `VERIFIED`.
|
|
221
|
+
|
|
222
|
+
The system reserves runtime isolation for planned and automated execution
|
|
223
|
+
paths. It excludes runtime isolation from ordinary ad-hoc work. Public
|
|
224
|
+
activation remains deferred until the system enables those paths.
|
|
225
|
+
|
|
226
|
+
</details>
|
|
227
|
+
|
|
228
|
+
**Under development in this theme:**
|
|
229
|
+
|
|
230
|
+
- **native macOS container proof** — the native Apple Container runtime has
|
|
231
|
+
passed a fixed local `/bin/pwd` isolation qualification. The probe used a
|
|
232
|
+
read-only repository mount, no network, and automatic removal. The native Pi
|
|
233
|
+
adapter remains under development and is not yet part of the released
|
|
234
|
+
package.
|
|
235
|
+
|
|
236
|
+
- **attended-authority guard** — the safety net between an agent and your
|
|
237
|
+
shell: when a model tries to delete, overwrite, or push, the guard
|
|
238
|
+
stops it before execution and asks you. Safe commands (reads, builds,
|
|
239
|
+
tests) pass through untouched. If you deny, you get a clear reason and
|
|
240
|
+
the session continues, and the agent does not retry behind your back. In
|
|
241
|
+
headless runs where no human can confirm, the system refuses destructive
|
|
242
|
+
commands rather than silently allowing them.
|
|
243
|
+
|
|
244
|
+
## Managing context pressure, compaction, and avoiding lossy handover
|
|
245
|
+
|
|
246
|
+
*Extensions for session continuity when context runs out or a session ends.*
|
|
247
|
+
|
|
248
|
+
**In development:**
|
|
249
|
+
|
|
250
|
+
- **context-pressure handling** — pressure detection, non-lossy handover,
|
|
251
|
+
compaction completion without cancellation loops, and continuation of
|
|
252
|
+
the latest user goal. Development-only until the full live journey
|
|
253
|
+
passes.
|
|
254
|
+
- **lossless session-reference compaction** — selective, lossless retrieval
|
|
255
|
+
of exact pre-compaction content, addressing factual degradation across
|
|
256
|
+
repeated compactions; designed as an optional add-on, not yet
|
|
257
|
+
implemented.
|
|
258
|
+
|
|
259
|
+
**Planned in this theme:**
|
|
260
|
+
|
|
261
|
+
- **handover, checkpoint, and recovery** — durable repository-local
|
|
262
|
+
handover notes, governed checkpoint mutation, watchdog handoff, and
|
|
263
|
+
fresh-session resumption that identifies goal, changed files, checks,
|
|
264
|
+
and next step without executing anything.
|
|
265
|
+
- **evidence ledger** — deterministic evidence indexing, lossless source
|
|
266
|
+
projection, universal checkpoint produce/store/recover, and run-ledger
|
|
267
|
+
records with crash and corruption vectors tested.
|
|
268
|
+
- **offline multihost evidence** — record run evidence on each host while
|
|
269
|
+
disconnected and reconcile it deterministically on reconnection, with no
|
|
270
|
+
host as sole authority.
|
|
271
|
+
|
|
272
|
+
## Working with Git safely
|
|
273
|
+
|
|
274
|
+
*Extensions that keep routine Git low-friction and consequential Git guarded.*
|
|
275
|
+
|
|
276
|
+
**In development:**
|
|
277
|
+
|
|
278
|
+
- **git workflow safeguards** — design only. The package contains no Git
|
|
279
|
+
extension yet. The planned capability covers exact-file staging, native
|
|
280
|
+
confirmation, post-confirmation drift checks, and protected-operation
|
|
281
|
+
boundaries.
|
|
282
|
+
- **assignment-aware Git journeys** — merge and protected-push flows bound
|
|
283
|
+
to a verified assignment, so consequential Git operations carry their
|
|
284
|
+
own recorded provenance.
|
|
285
|
+
|
|
286
|
+
## Trust in the extension set itself
|
|
287
|
+
|
|
288
|
+
*Extensions that keep the installed set honest and the record bounded.*
|
|
289
|
+
|
|
290
|
+
- **security and integrity scanning** — static scanning of MCP configs,
|
|
291
|
+
agent skills, and extension packages for hardcoded secrets, prompt and
|
|
292
|
+
shell injection, data-exfiltration endpoints, untrusted integrations,
|
|
293
|
+
PII leakage, and OWASP/MCP threat families, with accept/redact/reject
|
|
294
|
+
decisions. Built on the agent-scanner approach proven in
|
|
295
|
+
Hillstar Orchestrator and Testudo.
|
|
296
|
+
- **checkpoint storage lifecycle** — compression, deduplication, retention,
|
|
297
|
+
and purging rules for capsule/index stores once a product ships, so
|
|
298
|
+
session evidence has a managed lifetime instead of growing without
|
|
299
|
+
bound.
|
|
300
|
+
- **product knowledge graph** — semantic graph projection of a shipped
|
|
301
|
+
product's checkpoints, decisions, and artifacts, so the record of what
|
|
302
|
+
was built stays queryable after active development ends.
|
|
303
|
+
|
|
304
|
+
Each item lands here as its own extension when its scenario passes
|
|
305
|
+
acceptance with all prohibited effects absent.
|
|
306
|
+
|
|
307
|
+
### Portable repository contract
|
|
308
|
+
|
|
309
|
+
`templates/AGENTS.md` is a portable starting contract for repositories that
|
|
310
|
+
use Pi agents. It keeps routine work low-friction, requires bounded tasks and
|
|
311
|
+
realistic tests, and treats reports as non-authorizing evidence. It does not
|
|
312
|
+
overwrite repository-specific instructions or create a second authority store.
|
|
313
|
+
|
|
314
|
+
## Install
|
|
315
|
+
|
|
316
|
+
```sh
|
|
317
|
+
pi install <tarball-or-npm-package>
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Released extensions load standalone; neither requires the other.
|
|
321
|
+
|
|
322
|
+
## License
|
|
323
|
+
|
|
324
|
+
AGPL-3.0-or-later with author-attribution additional terms (Section 7(b));
|
|
325
|
+
see [LICENSE](LICENSE). A commercial licence is available on request.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Julen Gamboa <j.a.r.gamboa@gmail.com>
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
analyzeCodePhage,
|
|
6
|
+
assessScopeDrift,
|
|
7
|
+
compareCodePhagePlan,
|
|
8
|
+
} from "../lib/code-phage-core.mjs";
|
|
9
|
+
|
|
10
|
+
export const CODE_PHAGE_TOOL = "code_phage";
|
|
11
|
+
export const CODE_PHAGE_PARAMETERS = Object.freeze({
|
|
12
|
+
type: "object",
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
properties: {
|
|
15
|
+
goal: { type: "string", minLength: 1, maxLength: 4_000 },
|
|
16
|
+
candidatePaths: {
|
|
17
|
+
type: "array",
|
|
18
|
+
maxItems: 64,
|
|
19
|
+
items: { type: "string", minLength: 1, maxLength: 1_024 },
|
|
20
|
+
},
|
|
21
|
+
acceptedRequirements: {
|
|
22
|
+
type: "array",
|
|
23
|
+
maxItems: 64,
|
|
24
|
+
items: { type: "string", minLength: 1, maxLength: 4_000 },
|
|
25
|
+
},
|
|
26
|
+
testPaths: {
|
|
27
|
+
type: "array",
|
|
28
|
+
maxItems: 64,
|
|
29
|
+
items: { type: "string", minLength: 1, maxLength: 4_000 },
|
|
30
|
+
},
|
|
31
|
+
phase: { type: "string", enum: ["plan", "review"] },
|
|
32
|
+
credits: {
|
|
33
|
+
type: "array",
|
|
34
|
+
maxItems: 64,
|
|
35
|
+
items: {
|
|
36
|
+
type: "object",
|
|
37
|
+
additionalProperties: false,
|
|
38
|
+
properties: {
|
|
39
|
+
source: { type: "string" },
|
|
40
|
+
version: { type: "string" },
|
|
41
|
+
license: { type: "string" },
|
|
42
|
+
accessed: { type: "string" },
|
|
43
|
+
},
|
|
44
|
+
required: ["source", "version", "license", "accessed"],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: ["goal"],
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
function resultText(value) {
|
|
52
|
+
return JSON.stringify(value, null, 2);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function toolResult(value) {
|
|
56
|
+
return {
|
|
57
|
+
content: [{ type: "text", text: resultText(value) }],
|
|
58
|
+
details: value,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function pathFromToolCall(event) {
|
|
63
|
+
const input = event?.input;
|
|
64
|
+
if (!input || typeof input !== "object") return undefined;
|
|
65
|
+
const path = input.path ?? input.file_path;
|
|
66
|
+
return typeof path === "string" ? path : undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default function codePhage(pi) {
|
|
70
|
+
const active = {
|
|
71
|
+
goal: undefined,
|
|
72
|
+
candidatePaths: [],
|
|
73
|
+
plan: undefined,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
pi.on?.("session_start", () => {
|
|
77
|
+
active.goal = undefined;
|
|
78
|
+
active.candidatePaths = [];
|
|
79
|
+
active.plan = undefined;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
pi.on?.("tool_call", (event, ctx) => {
|
|
83
|
+
if (!active.goal) return undefined;
|
|
84
|
+
if (!["write", "edit", "apply_patch", "Write", "Edit"].includes(event?.toolName)) return undefined;
|
|
85
|
+
const path = pathFromToolCall(event);
|
|
86
|
+
if (!path) return undefined;
|
|
87
|
+
let warning;
|
|
88
|
+
try {
|
|
89
|
+
warning = assessScopeDrift(active.goal, active.candidatePaths, path);
|
|
90
|
+
} catch {
|
|
91
|
+
warning = { status: "possible-drift", path, reason: "the proposed path could not be safely classified" };
|
|
92
|
+
}
|
|
93
|
+
if (!warning) return undefined;
|
|
94
|
+
ctx?.ui?.notify?.(
|
|
95
|
+
`code-phage: possible scope drift for ${path}. ${warning.reason}. Recheck the accepted goal and deletion test; no action was blocked.`,
|
|
96
|
+
"warning",
|
|
97
|
+
);
|
|
98
|
+
return undefined;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
pi.registerTool({
|
|
102
|
+
name: CODE_PHAGE_TOOL,
|
|
103
|
+
label: "Code Phage",
|
|
104
|
+
description: "Advisory code-bloat and scope-alignment review. It checks prior art, measures diagnostic complexity signals, compares candidate scope with the stated goal, and never mutates or blocks work.",
|
|
105
|
+
promptSnippet: "Use before and after bounded implementation work to check prior art, complexity, deletion justification, and scope drift.",
|
|
106
|
+
promptGuidelines: [
|
|
107
|
+
"Provide the structural goal, not approval records, leases, hashes, commands, or authority mechanics.",
|
|
108
|
+
"Treat cognitive complexity, cyclomatic complexity, line count, and duplication as diagnostic signals, not universal rejection thresholds.",
|
|
109
|
+
"Use the possible scope-drift warning to return to the accepted goal; this tool never blocks or mutates work.",
|
|
110
|
+
],
|
|
111
|
+
parameters: CODE_PHAGE_PARAMETERS,
|
|
112
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
113
|
+
try {
|
|
114
|
+
const value = analyzeCodePhage({
|
|
115
|
+
root: ctx?.cwd || process.cwd(),
|
|
116
|
+
goal: params?.goal,
|
|
117
|
+
candidatePaths: params?.candidatePaths,
|
|
118
|
+
phase: params?.phase || "plan",
|
|
119
|
+
credits: params?.credits,
|
|
120
|
+
acceptedRequirements: params?.acceptedRequirements,
|
|
121
|
+
testPaths: params?.testPaths,
|
|
122
|
+
});
|
|
123
|
+
if (value.phase === "plan") {
|
|
124
|
+
active.plan = value;
|
|
125
|
+
} else {
|
|
126
|
+
value.comparison = compareCodePhagePlan(active.plan, value);
|
|
127
|
+
}
|
|
128
|
+
active.goal = value.goal;
|
|
129
|
+
active.candidatePaths = value.budget.candidateFiles;
|
|
130
|
+
return toolResult(value);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
return toolResult({
|
|
133
|
+
schema: "agentic-driver.code-phage.v1",
|
|
134
|
+
status: "advisory-error",
|
|
135
|
+
advisoryOnly: true,
|
|
136
|
+
authorityCreated: false,
|
|
137
|
+
mutated: false,
|
|
138
|
+
error: error instanceof Error ? error.message : String(error),
|
|
139
|
+
nextAction: "Correct the structural goal or repository context; no source mutation was performed.",
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Julen Gamboa <j.a.r.gamboa@gmail.com>
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
export default async function herdrCommunicationPi(pi) {
|
|
5
|
+
const module = await import(new URL("../scripts/enforcement/herdr_communication_pi.js", import.meta.url).href);
|
|
6
|
+
return module.registerHerdrCommunicationInterface(pi);
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Julen Gamboa <j.a.r.gamboa@gmail.com>
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
export default async function herdrLifecyclePi(pi) {
|
|
5
|
+
const module = await import(new URL("../scripts/enforcement/herdr_lifecycle_pi.js", import.meta.url).href);
|
|
6
|
+
return module.registerHerdrLifecycleInterface(pi);
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { registerLinuxMicroVMCutoverInterface } from "../scripts/enforcement/linux_microvm_cutover_pi.js";
|
|
2
|
+
|
|
3
|
+
export default function registerLinuxMicroVMCutover(pi: any) {
|
|
4
|
+
// Registration is limited to the activation-deferred cutover interface:
|
|
5
|
+
// native confirmation, trusted facts, and fixed boundaries are preserved by
|
|
6
|
+
// the interface itself; the transient runtime is local to this
|
|
7
|
+
// registration and only carries adapter state it observes at cutover time.
|
|
8
|
+
const runtime: { workMode?: string; workContext?: unknown; isolationEnabled?: boolean } = {};
|
|
9
|
+
return registerLinuxMicroVMCutoverInterface(pi, { runtime });
|
|
10
|
+
}
|