@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.
@@ -0,0 +1,287 @@
1
+ ---
2
+ summary: "Design record for pi-agent-registry runtime inspection, Fleet Phase-1 immutable lint, and the Phase-2 exact-task read-only dispatch contract."
3
+ read_when:
4
+ - "Changing manifest loading, fleet discovery/lint, immutable observations, or dispatch posture."
5
+ - "Onboarding to the standing-agent fleet contract implementation."
6
+ system4d:
7
+ container: "Pi-side read-only registry and fleet observation package."
8
+ compass: "Converge owner interfaces without absorbing lifecycle or execution authority."
9
+ engine: "Capture committed bytes -> lint every candidate -> report stable diagnostics -> keep dispatch disabled."
10
+ fog: "Mutable paths and a green process exit can be mistaken for immutable fleet health."
11
+ ---
12
+
13
+ # pi-agent-registry — Phase-1 design record
14
+
15
+ The monorepo manifest convention is the consumer contract. L0
16
+ `tpl-agent-repo` owns birth/propagation shape, `softwareco-agents` owns
17
+ fleet/role/lifecycle conventions, engineering-core owns profile keys/members,
18
+ AK owns task/evidence/decision truth, and ASC owns any future execution.
19
+
20
+ This package owns two read-only Pi-side surfaces and one bounded execution
21
+ contract:
22
+
23
+ 1. mutable manifest inspection for already loadable agents;
24
+ 2. aggregate immutable-observation fleet lint;
25
+ 3. the Fleet Phase-2 exact-task read-only dispatch contract (authorization,
26
+ receipt, evidence) with all spawn/session/capacity machinery ASC-owned.
27
+
28
+ None of these surfaces grants standing-agent lifecycle authority.
29
+
30
+ ## Architecture
31
+
32
+ ```text
33
+ src/manifest.ts
34
+ schema-1 runtime parser, additive role/creation_task, contained resources
35
+
36
+ src/registry-discovery.ts
37
+ shared bounded one-repo-per-agent discovery; lint sees missing manifests
38
+
39
+ src/registry.ts
40
+ mutable inspection index and resolution metadata; no execution
41
+
42
+ src/ec-profiles.ts
43
+ versioned profile envelope + aliases + exact parsed raw SHA-256
44
+
45
+ src/fleet-git-snapshot.ts
46
+ full commit/tree capture, committed blobs, worktree currentness, race fence
47
+
48
+ src/fleet-prompt-compiler.ts
49
+ trusted byte-for-byte v2 compiler reconstruction; never executes repo code
50
+
51
+ src/fleet-lint-provenance.ts
52
+ bounded ownership/Copier provenance and verifiable full source revisions
53
+
54
+ src/fleet-lint-skills.ts
55
+ immutable profile-member and extra-skill capture diagnostics
56
+
57
+ src/fleet-lint-repository.ts
58
+ per-agent manifest/profile/prompt/revision/lifecycle diagnostics
59
+
60
+ src/fleet-lint.ts + fleet-lint-types.ts
61
+ aggregate collisions, bounds, stable ordering, report identity
62
+
63
+ scripts/fleet-lint.mjs
64
+ shipped JSON CLI / npm bin with unhealthy vs infrastructure exit semantics
65
+
66
+ src/dispatch-contract.ts
67
+ Phase-2 constants: phase, schemas, tool allowlist, provenance marker, bounds
68
+
69
+ src/dispatch-authorization.ts
70
+ ak task-show read, exact-task claim/lease/repo authorization, evidence record
71
+
72
+ src/dispatch-receipt.ts
73
+ write-once 0o400 receipts with canonical digests and tamper-evident re-read
74
+
75
+ src/agent-skill-resolver.ts
76
+ registry-owned ExtraSkillProfileResolver for ASC's skill seam
77
+
78
+ src/dispatch-request.ts
79
+ ASC child-request composition and runtime wiring (sessions/model via ASC)
80
+
81
+ src/dispatch.ts + src/sessions-dir.ts
82
+ Phase-2 pipeline with fail-closed gates; sessions delegated to ASC
83
+ ```
84
+
85
+ ## Manifest compatibility
86
+
87
+ The ratified v2 template adds `role` and `creation_task` to
88
+ `ai-society.agent/1`. Runtime parsing accepts both but keeps them optional so
89
+ legacy adoption/backfill can remain owner-scoped. Fleet lint requires both and
90
+ emits stable errors when absent.
91
+
92
+ Unknown schema-1 additions at the top level and inside known objects are ignored
93
+ by runtime normalization and reported by lint. Known field values remain strict.
94
+ Unknown schema versions fail closed. Removing/renaming fields requires a future
95
+ schema and compatibility window.
96
+
97
+ `skills.profile: null`, empty `skills.extra`, and empty scope arrays from the
98
+ L0 template are valid. `tools: []` remains empty; Phase 1 does not fabricate a
99
+ `read` capability.
100
+
101
+ ## Discovery and aggregate failure semantics
102
+
103
+ Mutable runtime discovery indexes only repos with valid root manifests and may
104
+ fail fast. Fleet lint first enumerates every immediate candidate repo from each
105
+ configured `agent-*` pattern, including missing manifests, then captures each
106
+ independently. It aggregates malformed manifests and exact collisions instead
107
+ of letting the first failure hide later repos.
108
+
109
+ Configured missing roots fail closed. Defaults skip absent forward-compatible
110
+ company/lane patterns. Physical duplicate roots and repository-count overflow
111
+ fail closed.
112
+ Candidate-resolution failures, bounded blob reads, and repository/profile
113
+ endpoint-finalization failures are projected as stable local/aggregate
114
+ diagnostics rather than rejecting an otherwise coherent report. Configuration
115
+ ambiguity and an invalid profile source remain infrastructure failures.
116
+
117
+ ## Immutable observation
118
+
119
+ One report binds exact committed data where possible:
120
+
121
+ - full Git commit/tree for every included agent;
122
+ - committed manifest blob OID + SHA-256;
123
+ - engineering-core profile commit/blob/schema/SHA-256;
124
+ - trusted prompt compiler input/output SHA-256;
125
+ - template ownership and Copier answers digests;
126
+ - only a full template source commit that resolves exactly in a local
127
+ `tpl-agent-repo` source containing the required template files;
128
+ - separate initial/final HEAD and porcelain-status hashes for observed endpoint
129
+ drift;
130
+ - per-repo composite snapshot SHA-256;
131
+ - deterministic `stateSha256` plus complete-report `reportSha256`.
132
+
133
+ `stateSha256` excludes `observedAt`; `reportSha256` includes it. Physical paths
134
+ are projected logically/redacted and do not establish identity or freshness.
135
+ Native exception/command text is never serialized. Additive field names are
136
+ represented by SHA-256 rather than raw text; physical-path-shaped role values
137
+ are omitted with an error. This keeps machine reports, CLI JSON, and Pi lint
138
+ text/details independent of home/temp/repository paths.
139
+
140
+ Dirty worktrees remain observable but unhealthy because mutable runtime bytes
141
+ can differ from the committed snapshot. Different initial/final HEAD or status
142
+ invalidates the observation; an undetectable modify-and-restore interval is not
143
+ claimed absent. Missing, short, unverifiable, or author-only template revision
144
+ claims remain unbound. `verified_local_source` proves only a matching local Git
145
+ object and required source files, not template-owner authority or rendered
146
+ product currentness.
147
+
148
+ ## Trusted prompt freshness
149
+
150
+ Fleet lint never runs `scripts/compile-system-prompt.py` or any repository
151
+ script. Registry-owned code reconstructs the ratified compiler contract from:
152
+
153
+ - exact raw committed `agent.json`;
154
+ - `docs/person/README.md`;
155
+ - `identity.md`;
156
+ - `reason.md`;
157
+ - `main_task.md`;
158
+ - `dream_goal.md`;
159
+ - `behavior_rules.md`.
160
+
161
+ It first requires the manifest's runtime `system_prompt_file` to be the canonical
162
+ compiled path, then compares expected bytes to that exact committed artifact.
163
+ Missing inputs/output, mismatch, or noncanonical runtime paths are errors. The
164
+ compiler uses code-point key order and Python universal-newline semantics;
165
+ numeric additive values degrade freshness to unproven until byte-equivalence is
166
+ implemented. The compiler contract is explicitly versioned in the report.
167
+ Runtime manifest/profile loading also hashes/decodes exact bytes with strict
168
+ UTF-8, rejects BOM-invalid JSON and recursively rejects unpaired surrogates.
169
+ Template ownership and Copier `_src_path` recognition use the ratified Python
170
+ owner's whitespace, line, cardinality, quoting, comment, and overlap semantics.
171
+
172
+ ## Profile and skill references
173
+
174
+ Fleet lint requires `engineering-core.skill-profiles/1`. Runtime may retain a
175
+ legacy raw-map transition read, but a legacy source cannot produce healthy
176
+ fleet lint.
177
+
178
+ Canonical profile references are healthy. Runtime and L0 birth remain compatible
179
+ with `profile: null`, but the exact engineering-core fleet interface requires a
180
+ non-empty profile, so immutable fleet lint emits `profile.missing`. Deprecated
181
+ aliases warn with exact canonical target. Unknown profiles or committed profile
182
+ members fail. Extra
183
+ skills are immutable-bound only when committed in the agent or engineering-core
184
+ snapshot; a mutable user-skill fallback remains runtime-only and is an error in
185
+ immutable lint.
186
+
187
+ ## Collisions and lifecycle
188
+
189
+ Name and role collision automation proves only exact normalized equality.
190
+ Semantic recurring-pain/differentiation review remains the owner creation gate.
191
+
192
+ The 90-day signal reads the latest committed diary/learning activity at the
193
+ captured agent commit. It emits `recent_activity`, `stale_candidate`, or
194
+ `unknown`, always with `authorityEffect=none`. It never declares current,
195
+ active, retired, authorized, or approved lifecycle state.
196
+
197
+ ## Phase-2 exact-task read-only dispatch (AK 5132)
198
+
199
+ `dispatch_agent { agent, task, objective }` is no longer a static gate. It
200
+ executes the Fleet Phase-2 contract — at most one SETTLED read-only
201
+ standing-agent run per `(agent, exact AK task)` pair, with failed attempts
202
+ retained immutably and bounded to three — while every pre-authorization
203
+ failure still fails closed with `confirmed_no_effects`:
204
+
205
+ - **Exact-task authorization** reads `ak task show <id> -F json`; the task
206
+ must be bound to the dispatch-origin repository, `claimed`, and carry a
207
+ live lease. Readiness never becomes authorization.
208
+ - **Immutable revision** reuses the fleet git snapshot: the agent repo must be
209
+ `clean_observed`; committed `agent.json` and prompt blobs are bound by OID
210
+ and SHA-256; `finish()` must prove stability across the dispatch window.
211
+ - **Read-only posture** is three-layered: declared tools must be a non-empty
212
+ subset of `[read, bash]`; the child task contract is `mutationPolicy=read_only`
213
+ with explicit no-mutation constraints and stop conditions; and the parent
214
+ observes dispatch-origin HEAD + porcelain digests across the window. Any
215
+ drift fails `read_only_violation_observed` and voids AK evidence. The
216
+ observation is bounded; modify-and-restore is not claimed absent.
217
+ - **ASC-owned execution**: `src/dispatch-request.ts` composes the child
218
+ request and creates the runtime through ASC's exported
219
+ `createAscExecutionRuntime` + `resolveSubagentSessionsDir` + model
220
+ selection; the registry supplies only the `extraSkillProfileResolver` seam
221
+ (`skillProfile = agent name`). No spawn/session/capacity code lives here.
222
+ `src/sessions-dir.ts` now delegates to ASC instead of the Phase-0
223
+ quarantine.
224
+ - **One level deep**: dispatched children carry
225
+ `PI_PROVENANCE_STANDING_AGENT_DISPATCH` (an allowed request-env key) and the
226
+ gate rejects recursive dispatch.
227
+ - **Immutable attempt receipts**: `src/dispatch-receipt.ts` publishes
228
+ `pi-agent-registry.dispatch-receipt/1` write-once — private temp file,
229
+ hard-link publication, `0o400`, verified re-read, canonical-JSON
230
+ `receiptSha256` excluding the digest field. Attempt-indexed file names
231
+ `ak-<task>.<agent>.<NN>.dispatch-receipt.json` keep failed attempts as
232
+ immutable history while `readDispatchAttemptLedger` enforces one settled
233
+ receipt per pair and the three-attempt bound.
234
+ - **AK evidence**: a settled, provably-read-only dispatch records exactly one
235
+ `standing-agent-dispatch` evidence row binding receipt digest, ASC effect
236
+ receipt correlation, and observation outcome. Failed dispatches keep the
237
+ receipt as truth and leave AK recording to the parent task.
238
+ - **Effect truth is receipt-first**: terminal ASC `DispatchSubagentDetails`
239
+ omit the declared `effectDisposition` field; the owner-issued
240
+ `effectReceipt.disposition` is authoritative and the registry derives from it
241
+ exactly as ASC's own observation projection does (proven live 2026-08-31:
242
+ attempt 2 of the 5132 dogfood ran `done` with a settled effect receipt while
243
+ naive details-field reading classified it indeterminate).
244
+ - **Attempt ledger integrity**: a receipt whose file name disagrees with its
245
+ recorded `dispatch.attemptIndex` fails the ledger read closed, so renames
246
+ cannot skew the settled-once or three-attempt bounds (hardening proposed by
247
+ the dispatched child's own 5132 verification report and adopted).
248
+
249
+ Known Phase-2 limits (deliberate): the tool does not authenticate the caller
250
+ as the AK claimant (Fleet Phase 4 permit binding); dispatch is headless (no
251
+ Ghostty visibility — Fleet Phase 3); `bash` remains admitted as the fleet's
252
+ established read-only exploration instrument, bounded by the task contract and
253
+ window observation rather than a filesystem sandbox; and the child transport
254
+ carries the initial prompt as the child pi CLI's leading positional argument,
255
+ so dash-led prompts (persona front matter) require the registry's dispatch
256
+ header envelope — a pi/ASC transport hardening candidate for a later slice
257
+ (first observed live 2026-08-31 as child exit `Unknown option: ---`).
258
+
259
+ ## Real fleet baseline
260
+
261
+ The real `~/ai-society/agents/agent-*` walk is revision-bound in
262
+ `tests/fixtures/real-fleet-lint-baseline.json`. The known unhealthy result is a
263
+ successful implementation proof:
264
+
265
+ - four canonical repositories observed;
266
+ - three missing manifests;
267
+ - adoption-steward missing role/creation task;
268
+ - stale compiled prompt under the trusted v2 compiler;
269
+ - mutable/unbound extra skill and missing template provenance;
270
+ - three owner-dispositioned stale-candidate signals.
271
+
272
+ Phase 1 does not mutate those external repos. When owner-authorized L2 backfill
273
+ changes exact revisions, the baseline must change under a reviewed registry
274
+ slice rather than silently turning green.
275
+
276
+ ## Verification
277
+
278
+ - manifest tests: additive compatibility, role/task validation, null profile,
279
+ empty least-privilege tools;
280
+ - synthetic Git fleet tests: healthy v2, malformed/missing aggregation,
281
+ collisions, aliases, prompt drift, dirty state, extras, deterministic digest,
282
+ repository bounds;
283
+ - real fleet test: exact commits, profile bytes, diagnostics, and report digest;
284
+ - extension test: `action=lint` returns observation-only unhealthy baseline;
285
+ - CLI test: JSON and exit taxonomy;
286
+ - packed smoke: shipped CLI/module/action plus Phase-0 dispatch gate;
287
+ - package check, fresh Pi dogfood, root loop gates, and independent review.
@@ -0,0 +1,31 @@
1
+ ---
2
+ summary: "Compact project model with explicit project-purpose framing."
3
+ read_when:
4
+ - "Aligning project purpose, strategy, and delivery behavior."
5
+ system4d:
6
+ container: "Project-level concepts and boundaries for this repository."
7
+ compass: "Translate project purpose into executable outcomes."
8
+ engine: "Project purpose -> mission -> vision -> strategic objectives."
9
+ fog: "Project scope and priorities can drift without explicit review."
10
+ ---
11
+
12
+ # Project foundation model
13
+
14
+ ```mermaid
15
+ flowchart TD
16
+ ProjectPurpose("Project Purpose") -->|defines| ProjectMission("Project Mission")
17
+ ProjectMission -->|leads to| ProjectVision("Project Vision")
18
+ ProjectVision -->|is operationalized by| ProjectStrategicObjectives("Project Strategic Objectives")
19
+ ProjectPurpose -->|inspires| ProjectValues("Project Values")
20
+ ProjectValues -->|shape| ProjectEthics("Project Ethics")
21
+ ProjectValues -->|shape| ProjectCulture("Project Culture")
22
+ ProjectValues -->|are expressed in| ProjectCharter("Project Charter")
23
+ ProjectCharter -->|influences| ProjectEthics
24
+ ProjectEthics -->|guides behavior in| ProjectCulture
25
+ ProjectCulture -->|supports| ProjectStrategicObjectives
26
+ ```
27
+
28
+ ## Scope boundary
29
+
30
+ - **Organization purpose** lives at org level and is documented in [Organization operating model](../org/operating_model.md).
31
+ - **Project purpose** is repository-specific and can be narrower while staying aligned with organization strategy.
@@ -0,0 +1,18 @@
1
+ ---
2
+ summary: "Product and technical vision for pi-agent-registry."
3
+ read_when:
4
+ - "Defining or revisiting project direction."
5
+ system4d:
6
+ container: "Project north-star statement."
7
+ compass: "Build a reliable pi extension package with low maintenance overhead."
8
+ engine: "Translate goals into concrete implementation slices."
9
+ fog: "Real user workflows may reshape priorities."
10
+ ---
11
+
12
+ # Vision
13
+
14
+ Deliver a dependable extension package that is easy to understand, validate, and evolve.
15
+
16
+ Project purpose for this repository is scoped to extension delivery and maintenance.
17
+ It aligns with, but is distinct from, organization purpose documented in [Organization operating model](../org/operating_model.md).
18
+ For the project-level concept map, see [Project foundation model](foundation.md).
File without changes