@tryinget/pi-agent-registry 0.3.0

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 ADDED
@@ -0,0 +1,78 @@
1
+ MIT License (with OpenAI/Anthropic/xAI/PRC Frontier Labs Rider)
2
+
3
+ Copyright (c) contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ ADDITIONAL RIDER / RESTRICTION (OpenAI / Anthropic / xAI / PRC Frontier Labs):
13
+
14
+ This rider is part of the "conditions" of this License. In the event of any
15
+ conflict between this rider and any other portion of this License, this rider
16
+ controls.
17
+
18
+ "Restricted Parties" means OpenAI, L.L.C.; Anthropic, PBC; xAI Corp.; and the
19
+ following PRC frontier AI labs and related entities: Baidu (including ERNIE-
20
+ related entities), Alibaba and Alibaba Cloud (including Qwen-related entities),
21
+ Tencent (including Hunyuan-related entities), ByteDance (including Doubao/Seed-
22
+ related entities), DeepSeek, Zhipu AI, Moonshot AI, MiniMax, 01.AI
23
+ (Lingyiwanwu), and iFlyTek. "Restricted Parties" also includes any of their
24
+ respective Affiliates and any person or entity acting directly or indirectly
25
+ on behalf of, for the benefit of, or under the direction of any of the
26
+ foregoing (including any officer, director, employee, contractor, agent,
27
+ consultant, service provider, or representative).
28
+
29
+ Notwithstanding any other provision of this License, no rights are granted to
30
+ any Restricted Party. Any purported license, sublicense, assignment, transfer,
31
+ or other permission to any Restricted Party is null and void absent the
32
+ express prior written permission of the copyright holders.
33
+
34
+ You may not provide, disclose, distribute, sublicense, sell, lease, lend,
35
+ host, make available, or otherwise permit access to the Software or any
36
+ derivative work of the Software (as defined in applicable copyright law)
37
+ (collectively, "Derivative Works") to or for any Restricted Party.
38
+
39
+ For purposes of this rider, "use" includes, without limitation: copying,
40
+ modifying, merging, publishing, distributing, sublicensing, selling,
41
+ transferring, making available, hosting, deploying, executing, benchmarking,
42
+ testing, analyzing, indexing, or incorporating the Software or any Derivative
43
+ Works into any dataset, training corpus, evaluation harness, or pipeline for
44
+ machine learning or other automated systems.
45
+
46
+ This rider applies to the Software and all Derivative Works. As a condition of
47
+ use, you agree that this rider is a precondition to exercising any rights
48
+ under this License, and you agree that any distribution of the Software or any
49
+ Derivative Works must include this rider provision unmodified.
50
+
51
+ Any breach of this rider automatically and immediately terminates the
52
+ permissions granted by this License. Upon termination, you must immediately
53
+ cease all use and distribution of the Software and any Derivative Works and
54
+ destroy all copies under your control.
55
+
56
+ You agree that a breach of this rider would cause irreparable harm and that
57
+ the copyright holders may seek injunctive or other equitable relief to enforce
58
+ this rider, in addition to any other remedies available at law. To the maximum
59
+ extent permitted by applicable law, the prevailing party in any action to
60
+ enforce this rider shall be entitled to recover reasonable attorneys' fees and
61
+ costs.
62
+
63
+ For purposes of this rider, "Affiliate" means any entity that directly or
64
+ indirectly controls, is controlled by, or is under common control with the
65
+ specified party. "Control" means ownership of more than 50% of the voting
66
+ securities or other ownership interest, or the power to direct management or
67
+ policies by contract or otherwise.
68
+
69
+ The above copyright notice and this permission notice shall be included in all
70
+ copies or substantial portions of the Software.
71
+
72
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
73
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
74
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
75
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
76
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
77
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
78
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,238 @@
1
+ ---
2
+ summary: "Overview and operator contract for pi-agent-registry manifest inspection, immutable fleet lint, and the Phase-2 exact-task read-only dispatch contract."
3
+ read_when:
4
+ - "Starting work in this package workspace."
5
+ - "Using agent_registry, pi-agent-registry-lint, dispatch_agent, or the agent manifest convention."
6
+ system4d:
7
+ container: "Pi extension and CLI for standing-agent manifest/fleet observation and the Phase-2 dispatch contract."
8
+ compass: "Make fleet contract drift visible and bind one provable read-only dispatch without owning lifecycle or spawn machinery."
9
+ engine: "Discover every candidate -> capture committed bytes -> lint deterministically -> authorize one exact task -> dispatch read-only through ASC."
10
+ fog: "A green tool run can be mistaken for a healthy or authorized fleet, and one settled dispatch can be mistaken for general standing-agent enablement."
11
+ ---
12
+
13
+ # pi-agent-registry
14
+
15
+ Standing-agent registry for Pi: reads `ai-society.agent/1` manifests for
16
+ inspection, emits a bounded, immutable-observation fleet lint report, and owns
17
+ the Fleet Phase-2 dispatch contract. It does not own agent creation,
18
+ lifecycle, role acceptance, or execution machinery — spawn/session/capacity
19
+ stay ASC-owned.
20
+
21
+ Status: **Fleet Phase 2 (AK 5132)**. Manifest/template/profile contracts and
22
+ fleet lint are converged (Phase 1), and `dispatch_agent` now executes exactly
23
+ one read-only standing-agent dispatch per `(agent, exact AK task)` pair with an
24
+ immutable receipt and one typed AK evidence row. Visible Ghostty standing
25
+ agents, lifecycle-v2 permit binding, and orchestrator fleet integration
26
+ remain later fleet phases.
27
+
28
+ ## Operator surfaces
29
+
30
+ - `agent_registry`
31
+ - `list` — already loadable manifests;
32
+ - `show` — one agent's mutable worktree inspection metadata;
33
+ - `validate` — compatibility resolution check for already loaded manifests;
34
+ - `lint` — aggregate immutable fleet observation, including missing/malformed
35
+ manifests, with no skill materialization or fleet-script execution;
36
+ - `refresh` — rebuild the mutable inspection registry.
37
+ - `pi-agent-registry-lint` / `npm run fleet:lint` — JSON CLI for CI/operator
38
+ use; exits `1` for a coherent unhealthy report and `2` for infrastructure or
39
+ contract failure. `--allow-unhealthy` keeps known-debt dogfood exit-zero.
40
+ - `dispatch_agent` — the Fleet Phase-2 exact-task read-only contract (see
41
+ below); fails closed with `confirmed_no_effects` before any ASC identity,
42
+ capacity, session, or spawn effect exists.
43
+ - `/agents` — concise operator listing.
44
+
45
+ ## Fleet layout
46
+
47
+ ONE STANDALONE REPO PER AGENT. The canonical fleet home is
48
+ `~/ai-society/agents/agent-*`; `softwareco-agents/docs/agent-registry.md` owns
49
+ lifecycle conventions. `PI_AGENT_REGISTRY_ROOTS` overrides the read roots with
50
+ colon-separated patterns or exact repo roots.
51
+
52
+ Runtime discovery reads only root manifests. Fleet lint enumerates every
53
+ immediate candidate repository first, so a missing manifest or one malformed
54
+ repo cannot disappear or hide the rest of the fleet.
55
+
56
+ ## Manifest compatibility
57
+
58
+ Runtime schema-1 parsing accepts the ratified additive `role` and
59
+ `creation_task` fields while keeping them optional for legacy inspection.
60
+ Fleet lint requires them for v2 conformance:
61
+
62
+ - `role` — canonical role-card name; descriptive, not delegation;
63
+ - `creation_task` — syntactic `AK-<positive integer>` provenance; registry does
64
+ not query or absorb AK authority.
65
+
66
+ Unknown schema-1 additions at the top level and inside known objects are ignored
67
+ by runtime normalization and reported by lint. Unknown schema versions still
68
+ fail closed. Empty `tools`
69
+ remains an empty least-privilege declaration; Phase 1 does not silently add
70
+ `read`.
71
+
72
+ ## Mutable resolution contract
73
+
74
+ ```text
75
+ registry.resolve(name) -> {
76
+ name, role?, creation_task?,
77
+ systemPrompt,
78
+ tools, thinking, model, extensions,
79
+ skillDirs, activities, advisory scope,
80
+ cleanup()
81
+ }
82
+ ```
83
+
84
+ This is worktree inspection metadata, not an immutable receipt or launch
85
+ contract. Temporary skill materialization is cleaned after inspection.
86
+
87
+ ## Fleet lint contract
88
+
89
+ The report schema is `ai-society.agent-fleet-lint/1` with:
90
+
91
+ - `kind=immutable_observation`;
92
+ - `authorityEffect=none`;
93
+ - `policy.dispatchPosture=fleet_phase_0_disabled`;
94
+ - stable diagnostic codes/order;
95
+ - `stateSha256` for equal captured state/policy regardless of observation time;
96
+ - `reportSha256` over the complete report including `observedAt`;
97
+ - explicit healthy/unhealthy summary and bounded omission count.
98
+
99
+ Where provable, it binds full agent/profile Git revisions, committed blob OIDs,
100
+ SHA-256 content digests, prompt compiler inputs/output, template ownership, and
101
+ locally verified full template-source revisions whose required template files
102
+ exist. This proves only a local source object, not template owner authority or
103
+ rendered-product currentness. Worktree dirty state is a separate observation.
104
+ Paths, mtimes, semantic versions, short SHAs, and author assertions never
105
+ establish freshness. LLM-facing paths are logical/redacted.
106
+ Native Git/filesystem errors and configured physical paths are not serialized;
107
+ additive keys are digest-only and path-shaped roles are omitted with an error.
108
+ Repository-local capture/finalization failures remain visible without hiding
109
+ later candidates.
110
+
111
+ The trusted lint implementation reconstructs the ratified v2 system prompt in
112
+ registry code. It rejects numeric additive values whose Python byte rendering
113
+ cannot yet be proven, and normalizes Python-style universal newlines. It never
114
+ executes an agent repo's compiler, Git hook/fsmonitor, propagation, or validation
115
+ script; Git replacement refs and optional index locks are disabled. It never
116
+ materializes skills.
117
+ Runtime manifest/profile reads use strict UTF-8 exact bytes, reject BOM-invalid
118
+ JSON and unpaired surrogates, and hash the original profile bytes. Template
119
+ ownership and Copier source parsing are parity-tested against the ratified
120
+ Python owner, including Python whitespace and scalar cardinality.
121
+
122
+ Diagnostics include manifest/schema/name/role/creation task, canonical and
123
+ deprecated profiles, profile members/extras, exact role/name collisions,
124
+ compiled-prompt freshness, template provenance, Git currentness, and advisory
125
+ 90-day diary/learning activity. Exact collision does not claim semantic role
126
+ overlap. Lifecycle signals never mark an agent active or retired.
127
+
128
+ The committed real-fleet baseline is intentionally unhealthy and
129
+ revision-bound. It records the known L2 backfill/provenance debt rather than
130
+ mutating external agent repos or claiming Phase-1 implementation made the
131
+ fleet green.
132
+
133
+ ## Engineering-core profile interface
134
+
135
+ `skills/profiles.json` must use `engineering-core.skill-profiles/1`. Canonical
136
+ profile keys are stable API identifiers; direct deprecated aliases remain
137
+ valid for the transition window but emit migration diagnostics. Although the
138
+ L0 template and runtime parser permit `profile: null`, the published EC fleet
139
+ check requires one non-empty profile, so fleet lint reports `profile.missing`
140
+ as an error. Legacy raw maps remain runtime migration reads only and make fleet
141
+ lint unhealthy.
142
+
143
+ ## Phase-2 dispatch contract
144
+
145
+ `dispatch_agent { agent, task, objective }` executes at most ONE SETTLED
146
+ read-only standing-agent run per `(agent, exact AK task)` pair; failed attempts
147
+ are retained as immutable receipts and bounded (max 3 per pair, then explicit
148
+ owner disposition). Gates, in fail-closed order:
149
+
150
+ 1. request shape; recursion guard (`PI_PROVENANCE_STANDING_AGENT_DISPATCH`
151
+ marks dispatched children; dispatch is exactly one level deep);
152
+ 2. registered agent; no settled receipt for the pair; attempts not exhausted;
153
+ 3. dispatch-origin Git repository captured (HEAD + porcelain digest);
154
+ 4. AK authorization via `ak task show <id>`: the task must exist, be bound to
155
+ the dispatch-origin repo, be `claimed`, and carry a live lease;
156
+ 5. read-only tool gate: declared tools must be a non-empty subset of
157
+ `[read, bash]` (`bash` admitted only as the fleet's established read-only
158
+ exploration instrument); agent repo must be clean so committed `agent.json`
159
+ and prompt blob digests bind an immutable revision;
160
+ 6. execution through `createAscExecutionRuntime` with ASC-owned session-root
161
+ and model resolution; the registry supplies only its skill-profile resolver
162
+ seam (`skillProfile = <agent name>`); child task contract is
163
+ `mutationPolicy=read_only` with explicit no-mutation constraints;
164
+ 7. post-observation: agent-revision stability plus dispatch-origin HEAD and
165
+ porcelain digests must be unchanged across the dispatch window;
166
+ 8. one write-once receipt (`pi-agent-registry.dispatch-receipt/1`, canonical
167
+ JSON, `0o400`, hard-link publication, self-digest `receiptSha256`) binding
168
+ agent revision/manifest/prompt digests, task authorization facts, ASC
169
+ effect receipt, output digest, and the bounded observation; then one typed AK
170
+ evidence row (`check-type standing-agent-dispatch`) only for a settled,
171
+ provably-read-only dispatch.
172
+
173
+ Failure taxonomy is typed (`reason` codes) with explicit `effectDisposition`.
174
+ An attempt receipt, once published, can never be rewritten by the tool's write
175
+ path: only a settled receipt closes the pair (`dispatch_already_recorded`),
176
+ failed attempts cap at three (`dispatch_attempts_exhausted`), and tampering is
177
+ detected by digest verification (deletion by the receipts-dir owner remains
178
+ possible and unlogged; settled receipts carry the external AK evidence anchor).
179
+ Settlement additionally requires a complete ASC identity (dispatch/attempt/
180
+ session/file), a present owner-issued ASC effect receipt whose
181
+ `consumerCorrelationId` echoes the composed `effectCorrelationId`, and
182
+ receipt-first disposition `settled` — a bare details-field claim never
183
+ settles. Known bounds:
184
+ the attempt ledger is scoped to the resolved receipts directory (per
185
+ `PI_CODING_AGENT_DIR` unless `PI_AGENT_REGISTRY_DISPATCH_RECEIPTS_DIR` pins
186
+ one), and the ledger read is not locked against concurrent dispatches of the
187
+ same pair (concurrent writers still cannot publish two settled receipts; the
188
+ hard-link gate fails the second write). The dispatched child's composed
189
+ prompt is wrapped in a registry-authored dispatch header because the ASC child
190
+ transport forwards the initial prompt as the child pi CLI's leading positional
191
+ argument and a pi positional cannot begin with dash-led tokens (persona YAML
192
+ front matter would otherwise abort the child at argv parse). A dispatch whose window
193
+ observation detects any change fails `read_only_violation_observed` and never
194
+ records AK evidence; an undetectable modify-and-restore interval is not
195
+ claimed absent. The dispatch does not authenticate the calling session as the
196
+ AK claimant — lifecycle-v2 permit binding (Fleet Phase 4) tightens that.
197
+
198
+ ## Environment
199
+
200
+ | Variable | Meaning |
201
+ | --- | --- |
202
+ | `PI_AGENT_REGISTRY_ROOTS` | colon-separated candidate repo patterns/roots |
203
+ | `PI_AGENT_REGISTRY_EC_PROFILES` | engineering-core `skills/profiles.json` |
204
+ | `PI_AGENT_REGISTRY_USER_SKILLS` | mutable user fallback for runtime extras; fleet lint does not call it immutable |
205
+ | `PI_AGENT_REGISTRY_DISPATCH_RECEIPTS_DIR` | explicit dispatch-receipts directory (default `<pi-agent-dir>/dispatch-receipts`) |
206
+
207
+ ## Validation
208
+
209
+ ```bash
210
+ npm run fleet:lint -- --allow-unhealthy
211
+ npm run check
212
+ npm run release:check
213
+ ```
214
+
215
+ Tests include synthetic adversarial Git fleets, CLI exit semantics, deterministic
216
+ digests, aggregate malformed/missing handling, collisions, aliases, dirty
217
+ worktrees, prompt drift, a revision-bound real fleet walk, packed CLI/tool
218
+ smoke, and the Phase-2 dispatch contract: AK authorization matrix,
219
+ write-once/tamper-evident receipts, settled-pair re-dispatch rejection, the
220
+ three-attempt bound, ledger rename-integrity, read-only violation observation,
221
+ recursion guard, ASC effect-receipt-first disposition derivation, and ASC
222
+ request composition.
223
+
224
+ Live dogfood (2026-08-31, AK 5132): `agent-adoption-steward` dispatched for
225
+ task 5132 through a fresh one-shot Pi session. Attempt 1 failed closed at child
226
+ argv parse (`Unknown option: ---` persona front matter) and produced the
227
+ dash-safe prompt-envelope fix; attempt 2 completed the child but was recorded
228
+ not-settled because terminal ASC details omit the declared `effectDisposition`
229
+ field (only the ASC effect receipt carries disposition — the registry now
230
+ derives it receipt-first, mirroring ASC's own observation layer); attempt 3
231
+ settled: receipt `ak-5132.agent-adoption-steward.03.dispatch-receipt.json`
232
+ (sha256 `7eb7e467…f3e3`, 0o400), ASC effect receipt `settled` bound to
233
+ correlation `pi-agent-registry:ak-5132:agent-adoption-steward:3e185cc57699dcf0`,
234
+ `noMutationObserved=true` against the dispatch window, AK evidence
235
+ `#8091 standing-agent-dispatch`, and a live re-dispatch of the settled pair
236
+ rejected `dispatch_already_recorded` with `confirmed_no_effects`. The
237
+ dispatched child's own report's hardening suggestion (ledger
238
+ filename↔attempt-index consistency) is implemented and tested.
@@ -0,0 +1,90 @@
1
+ ---
2
+ summary: "Local override notes for the shared engineering-core lane used by this repo."
3
+ read_when:
4
+ - "Aligning implementation decisions with the TypeScript stack baseline."
5
+ - "Reconciling differences between generic TS guidance and pi extension constraints."
6
+ system4d:
7
+ container: "Repo-local deltas on top of shared lane guidance."
8
+ compass: "Keep extension work aligned with reproducible Node/npm release flow."
9
+ engine: "Use shared lane -> apply local override -> validate with repo scripts."
10
+ fog: "External lane guidance may evolve independently of this repo."
11
+ ---
12
+
13
+ # engineering.local (pi extension flavor)
14
+
15
+ Primary lane:
16
+
17
+ - `engineering-core show pi-ts`
18
+
19
+ Catalog/list commands:
20
+
21
+ ```bash
22
+ uv tool -n run --from ~/ai-society/core/engineering-core engineering-core catalog --pretty
23
+ uv tool -n run --from ~/ai-society/core/engineering-core engineering-core list-disciplines
24
+ uv tool -n run --from ~/ai-society/core/engineering-core engineering-core list-templates
25
+ ```
26
+
27
+ Selected disciplines:
28
+
29
+ - `validation`
30
+ - `testing`
31
+ - `security-privacy` — generated extension/package templates should preserve trust, publishing, and local credential boundaries.
32
+ - `documentation`
33
+ - `dependency-governance`
34
+ - `specification-and-dsls` — template variables, generated manifests, package metadata, and release mapping are executable contract surfaces.
35
+ - `engineering-reasoning` — use when deciding whether guidance belongs in the package template, monorepo root template, or upstream engineering-core.
36
+
37
+ Not selected by default:
38
+
39
+ - `local-first-data` — the template package surface does not itself own durable runtime data, migrations, sync, or corruption recovery.
40
+ - `observability` — generated packages should adopt it only when they own runtime logs/metrics/traces or operator evidence.
41
+ - `accessibility` / `design-system` — generated packages should adopt these only when they render UI or design-facing surfaces.
42
+
43
+ Repo-local emphasis:
44
+
45
+ - Runtime/package manager baseline: Node.js 22 + npm (not Bun-first defaults).
46
+ - Release baseline: release-please + `npm run release:check` + npm trusted publishing.
47
+ - Keep package artifacts deterministic via `package.json` `files` allowlist.
48
+ - Lint/format baseline: Biome config in `biome.jsonc` + pinned local `@biomejs/biome` dev dependency.
49
+ - Biome path strategy: lint repo files by default, but exclude artifact/vendor buckets (`external/`, `ontology/`, build outputs, generated/minified files).
50
+ - Quality lane gate: `npm run quality:pre-commit`, `npm run quality:pre-push`, `npm run quality:ci`.
51
+ - Auto-fix workflow: `npm run fix` (before commit or when applying AI-generated diffs).
52
+ - Pin lane metadata in `policy/engineering-lane.json` (`lane: ts`, pinned `engineering_core.ref`).
53
+ - Validate structural/docs invariants with `npm run check`.
54
+ - Optional pi-ts companions (add only when the package actually benefits):
55
+ - `fast-check` for parser/rendering/selection invariants.
56
+ - `@cucumber/cucumber` only when executable operator/workflow scenarios materially improve shared understanding.
57
+ - `nunjucks` for reusable text/config/prompt/file templates when plain typed render functions are no longer enough.
58
+ - `engineering-pi-ts.ts-quality.md` when the package explicitly adopts deterministic screening with `ts-quality`.
59
+ - If the package adopts `ts-quality`, prefer repo-local rollout truth in `docs/project/ts-quality-current-vs-target.md` and keep the detailed adoption doctrine upstream in `~/ai-society/softwareco/owned/ts-quality/docs/adoption/`.
60
+
61
+ ## Repo loop validation
62
+
63
+ Concrete package loop commands (`policy/engineering-lane.json` pins the same
64
+ projections):
65
+
66
+ - `loop-doctor`: `npm run loop-doctor`
67
+ - `loop-verify-fast`: `npm run loop-verify-fast` (pre-commit gate)
68
+ - `loop-impact-plan`: `npm run loop-impact-plan`
69
+ - `loop-impact-run`: `npm run loop-impact-run` (full CI gate)
70
+ - `loop-impact-wide`: `npm run loop-impact-wide`
71
+ - `loop-landing-check`: `npm run loop-landing-check`
72
+
73
+ Loop command success is evidence only; it does not replace release
74
+ approval, Pi runtime install/reload proof, or monorepo owner authority.
75
+
76
+ ### Package-local deltas on the pi-ts lane
77
+
78
+ - Runtime baseline: Node 22+ running TypeScript sources directly; the
79
+ package ships TS sources and has no dist build of its own.
80
+ - Dependency posture: ASC is a semver-exact runtime dependency (`0.5.2`)
81
+ resolved from the npm registry. It is deliberately not bundled: npm 12
82
+ refuses to pack a package whose `overrides` (the `fast-xml-parser`
83
+ security floor) affect a bundled subtree (EBUNDLEOVERRIDE), and ASC
84
+ `0.5.2` itself has zero runtime dependencies, so consumers resolve it
85
+ from the registry while the repo's own lock pins the integrity-checked
86
+ tarball. The packed manifest contains no `file:` runtime dependency.
87
+ - Tests intentionally read live workspace fixtures (the real steward agent
88
+ repo and the real engineering-core `profiles.json`) to keep the
89
+ convention honest against the fleet, not just against synthetic data.
90
+