@tryinget/pi-agent-vent 0.1.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,188 @@
1
+ ---
2
+ summary: "Overview and quickstart for the pi-agent-vent package."
3
+ read_when:
4
+ - "Starting work in this package workspace."
5
+ - "Installing or using the agent_vent tool."
6
+ system4d:
7
+ container: "Local pi extension for agent frustration capture."
8
+ compass: "Surface recurring agent friction while preserving authority boundaries and privacy."
9
+ engine: "Install package -> record minimized vents -> inspect recurrence summary -> human decides escalation."
10
+ fog: "Vents can be mistaken for canonical incidents, tasks, or telemetry."
11
+ ---
12
+
13
+ # @tryinget/pi-agent-vent
14
+
15
+ `pi-agent-vent` gives Pi agents a local `agent_vent` tool for recording and reviewing recurring frustrations they notice while working: long-lived bugs, repeated tool/runtime failures, brittle workflows, context-loss patterns, missing affordances, and documentation gaps.
16
+
17
+ It is intentionally local-first and advisory. It does **not** create AK tasks, GitHub issues, canonical evidence, external telemetry, ASC/self state, or real incidents.
18
+
19
+ - Workspace path: `packages/pi-agent-vent`
20
+ - Release component key: `pi-agent-vent`
21
+ - Package command: `/agent_vent` (`/agent-vent` remains a compatibility alias)
22
+ - LLM tool: `agent_vent`
23
+
24
+ ## Why this exists
25
+
26
+ Agents often encounter the same friction repeatedly but have no durable low-cost place to say “this keeps hurting.” This package captures those observations as small local JSONL records, groups them by recurrence key, and lets a human mark local review state before deciding whether any owner surface should act.
27
+
28
+ ## Install and activate
29
+
30
+ From this package directory:
31
+
32
+ ```bash
33
+ npm install
34
+ npm run check
35
+ pi install /absolute/path/to/your/monorepo/packages/pi-agent-vent
36
+ ```
37
+
38
+ Then in Pi:
39
+
40
+ ```text
41
+ /reload
42
+ /agent_vent help
43
+ ```
44
+
45
+ ## Tool behavior
46
+
47
+ `agent_vent` supports fourteen actions:
48
+
49
+ | Action | Purpose |
50
+ |---|---|
51
+ | `record` | Append a minimized vent record. Requires `summary`. |
52
+ | `summary` | Show recurrence groups and advisory candidate incidents. |
53
+ | `list` | Show recent local records. |
54
+ | `path` | Show the store path and boundary contract. |
55
+ | `review` | Show recurrence groups as a local operator review queue; optionally filter by local category/tag/tool/package facets; include a recurrence key to inspect bounded representative samples. |
56
+ | `outcomes` | Show read-only local follow-up grouped by review outcome state, including exact local next commands without owner-system mutation. |
57
+ | `compare` | Compare local review-state buckets before export, retention planning, or draft-only handoff without emitting archive/restore tokens. |
58
+ | `facets` | Show read-only local category/tag/tool/package facet counts for triage. |
59
+ | `set_review` | Set local review state for a recurrence group. |
60
+ | `curate` | Append local recurrence merge/rename projection events without rewriting raw vents. |
61
+ | `draft` | Generate draft-only owner-surface text for a recurrence group. |
62
+ | `stats` | Show local store counts, byte sizes, malformed-line counts, curation counts, and review-state totals. |
63
+ | `export` | Produce a bounded local diagnostic projection in markdown or JSON, optionally focused by local category/tag/tool/package facets. |
64
+ | `retention` | List read-only reviewed archive candidates and receipt history, preview, confirmation-gate, archive, and restore reviewed local diagnostic records with local backups/receipts. |
65
+
66
+ The tool prompt tells the agent to avoid ordinary status updates, raw logs, secrets, and private user payloads.
67
+
68
+ ## Human command
69
+
70
+ ```text
71
+ /agent_vent help
72
+ /agent_vent summary
73
+ /agent_vent list 20
74
+ /agent_vent facets
75
+ /agent_vent review
76
+ /agent_vent review new 20 category=tool_failure tag=reload tool=pi-reload package=tryinget-pi-agent-vent
77
+ /agent_vent review show bug:reload-tools
78
+ /agent_vent review set acknowledged bug:reload-tools "seen locally"
79
+ /agent_vent outcomes all 10 category=tool_failure tag=reload tool=pi-reload package=tryinget-pi-agent-vent
80
+ # outcomes and compare limits are per review-state bucket, not a global row cap
81
+ /agent_vent compare 10 category=tool_failure tag=reload tool=pi-reload package=tryinget-pi-agent-vent
82
+ /agent_vent retention candidates reviewed 20 category=tool_failure tag=reload tool=pi-reload package=tryinget-pi-agent-vent
83
+ /agent_vent retention history 20
84
+ /agent_vent curate merge bug:reload-tool-a bug:reload-tools "same local pattern"
85
+ /agent_vent curate remove bug:reload-tool-a "undo local merge"
86
+ /agent_vent draft github_issue bug:reload-tools
87
+ /agent_vent stats
88
+ /agent_vent export markdown acknowledged category=tool_failure tag=reload tool=pi-reload package=tryinget-pi-agent-vent
89
+ /agent_vent retention preview bug:reload-tools
90
+ /agent_vent retention archive bug:reload-tools archive:<token> "reviewed locally"
91
+ /agent_vent retention restore /path/to/backups/<backup>.agent-vent-backup.json restore:<token>
92
+ /agent_vent path
93
+ ```
94
+
95
+ `/agent-vent` remains a compatibility alias for users who prefer kebab-case slash commands. Review queue, outcome, compare, retention-candidate, retention-history, export, and detail output include advisory human-review hints, explicit local decision-posture projections, exact local next-action commands for review state, draft-only handoff targets, export prompts, retention preview eligibility, and rollback-candidate commands from archive receipts; generated commands quote dynamic recurrence keys/paths so legacy keys remain copyable. Decision posture is derived local diagnostic wording only: it is not resolution, assignment, issue status, task truth, incident state, evidence, or publication. Filtered compare follow-up commands preserve supported category/tag/tool/package filters for `outcomes`, `retention candidates`, and `export`. Export filters are local diagnostic focus aids only, not evidence scoping, publication, owner routing, or owner assignment; export applies review-state and facet scope before counts, summaries, display rows, and safe local follow-up commands. Outcome and compare limits are explicit per review-state bucket so `outcomes all 1` can show one `new`, one `acknowledged`, one `dismissed`, and one `escalation_drafted` group, while `compare 1` shows at most one group per state. Review/outcome/compare/export/retention-candidate/history command syntax fails closed before store reads for unknown filters, empty filter values such as `owner=` or `tag=`, invalid states/arguments, invalid category values, or invalid retention-history arguments. These surfaces are guidance only and do not route, file, create, declare, assign, record evidence, publish, archive, restore, or mutate owner systems.
96
+
97
+ ## Deeper Pi integration
98
+
99
+ `pi-agent-vent` is a companion to `pi-autonomous-session-control`, not part of it. ASC/`self` remains the execution and operational-mirror owner; this package owns only local vent diagnostics.
100
+
101
+ When `pi-toolbox-discovery` is installed, it exposes the `agent_vent` bundle so agents can discover or activate the same-named `agent_vent` tool on demand:
102
+
103
+ ```ts
104
+ toolbox({ action: "search", query: "vent" })
105
+ toolbox({ action: "activate", bundle: "agent_vent" })
106
+ ```
107
+
108
+ The owner extension must still be installed/reloaded so the `agent_vent` tool is registered before toolbox can activate it.
109
+
110
+ ## Local data contract
111
+
112
+ Default store:
113
+
114
+ ```text
115
+ ~/.pi/agent/agent-vent/vents.jsonl
116
+ ~/.pi/agent/agent-vent/review-events.jsonl
117
+ ~/.pi/agent/agent-vent/curation-events.jsonl
118
+ ~/.pi/agent/agent-vent/retention-events.jsonl
119
+ ~/.pi/agent/agent-vent/backups/
120
+ ```
121
+
122
+ Override:
123
+
124
+ ```bash
125
+ PI_AGENT_VENT_DIR=/path/to/private/dir pi
126
+ ```
127
+
128
+ Records are append-only JSONL with `schemaVersion: 1`. Optional `tool` and `packageName` record fields are local diagnostic facets only, not owner-routing truth. Review state changes are append-only local events in `review-events.jsonl`; recurrence curation changes are append-only local events in `curation-events.jsonl`. Retention lifecycle receipts are append-only local events in `retention-events.jsonl`; archive rollback artifacts are package-created local files under `backups/`. Recurrence review state, review outcome follow-up, and merged/renamed groups are projections from the latest local events; local review-state commands and record feedback resolve curated source keys to the active projected group. Raw vent records are not rewritten except by explicit, confirmation-gated local retention archive/restore operations.
129
+
130
+ Reads tolerate malformed old lines, oversized lines, invalid records, and semantic curation corruption by reporting ignored/quarantined counts. JSONL store files fail closed when replaced by symlinks or when a store exceeds the package file-size guard. `facets`, `review`, `outcomes`, `compare`, `curate`, `draft`, `stats`, `export`, and `retention` are local diagnostic surfaces, not evidence, owner routing, tasks, issues, incidents, publication, telemetry, or ASC/self state. Draft outputs are paste-ready text only; the owner system still decides acceptance, lifecycle, evidence, and publication.
131
+
132
+ Retention archive is intentionally destructive to the active local vents store, so it is confirmation-gated: use `retention candidates` for a read-only reviewed-group planning view that emits no archive tokens, preview a reviewed recurrence group first, copy the exact `archive:<token>`, then archive. The token includes the active store hash, archive and record append share a local lock, archive creates a backup before rewriting `vents.jsonl`, and receipt failures roll the active store back when the archive rewrite can still be identified. `retention history` is a read-only receipt projection that can rediscover recent archive/restore receipts and reconstruct rollback-candidate restore commands from archive receipts; those commands still fail closed during actual restore if the backup is stale, moved, symlink-escaped, missing, or outside the real backup directory. Restore requires the package-created backup path, exact derived `restore:<token>`, real backup-directory containment, and a current-store hash match so stale backups fail closed. The package intentionally has no hard-delete command in v0.1; permanent removal is operator-owned filesystem/data-lifecycle control, not evidence/task/incident lifecycle.
133
+
134
+ All display/export/draft/review-detail paths pass loaded records through a diagnostic-state membrane that normalizes schema, re-applies redaction on read, recomputes privacy metadata for loaded records, quarantines curation cycles, and keeps exact recurrence lookup separate from display limits. Review queue and export filters can use local category/tag/tool/package labels, but those filters are diagnostic focus aids only, not owner routing, owner assignment, evidence scoping, or publication. Filtered export is record/state scoped so mixed recurrence groups do not broaden exported counts, summaries, rows, or generated follow-up commands. Export follow-up commands are local diagnostic or draft-only next steps and intentionally include no archive/restore tokens. Drafts include local diagnostic facets when present, but those facets are hints for human review rather than owner-routing truth.
135
+
136
+ The package applies conservative redaction heuristics for common token/password/API-key shapes, including review notes, but callers must still avoid submitting secrets.
137
+
138
+ Data classification: local diagnostic user data. No network calls are made by this package.
139
+
140
+ ## Candidate incidents are not incidents
141
+
142
+ A recurrence group is flagged as a `candidateIncident` when it is repeated or high severity. That flag means “worth human review,” not “incident declared.” Escalation belongs to the appropriate owner surface.
143
+
144
+ ## Engineering-core alignment
145
+
146
+ This package follows `engineering-core` lane `pi-ts`:
147
+
148
+ ```bash
149
+ uv tool -n run --from ~/ai-society/core/engineering-core engineering-core show pi-ts --prefer-repo
150
+ ```
151
+
152
+ Package-specific selected disciplines are documented in [docs/engineering.local.md](docs/engineering.local.md), including `local-first-data`, `data-governance`, `domain-modeling`, and `observability` because this package owns durable local diagnostic records.
153
+
154
+ Product docs:
155
+
156
+ - [Vision](docs/project/vision.md)
157
+ - [Product posture](docs/project/product-posture.md)
158
+ - [Agent vent design](docs/project/2026-05-21-agent-vent-design.md)
159
+ - [Implementation plan](docs/project/2026-05-21-agent-vent-implementation-plan.md)
160
+
161
+ ## Package checks
162
+
163
+ Run from package directory:
164
+
165
+ ```bash
166
+ npm install
167
+ npm run check
168
+ ```
169
+
170
+ For release confidence, `npm run release:check` packs the package, verifies packaged docs/scripts, runs the packaged fallback gate, installs the tarball into an isolated npm prefix for a no-auth shadow registered-tool `agent_vent path` smoke, then installs the tarball with isolated Pi settings and npm prefix/cache, validates that local `npm:<tarball>` is being used only as the install source, and smokes the installed artifact through local-path Pi package discovery with `/agent_vent path`. Use `npm run release:check:quick` for artifact-only checks when live Pi smoke is not available; quick checks still include the no-auth installed shadow registered-tool smoke. These smokes prove artifact/package-loading behavior only, not npm/GitHub publication or provenance.
171
+
172
+ Run from monorepo root through the canonical package gate:
173
+
174
+ ```bash
175
+ bash ./scripts/package-quality-gate.sh ci packages/pi-agent-vent
176
+ ```
177
+
178
+ ## AK task/work-item operations
179
+
180
+ This package is a monorepo member, not a git root. Use plain installed `ak` from the monorepo root or this package directory; repo identity still belongs to the monorepo root. Do not invent package-local AK wrappers.
181
+
182
+ ## Release metadata
183
+
184
+ - npm package name: `@tryinget/pi-agent-vent`
185
+ - release component/tag stem: `pi-agent-vent` (for example `pi-agent-vent-vX.Y.Z`)
186
+ - release config mode: `component`
187
+
188
+ Keep `.copier-answers.yml` tracked and do not edit it manually.
package/biome.jsonc ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3
+ "vcs": {
4
+ "enabled": true,
5
+ "clientKind": "git",
6
+ "useIgnoreFile": true
7
+ },
8
+ "files": {
9
+ "ignoreUnknown": true,
10
+ "includes": [
11
+ "**",
12
+ "!**/node_modules/**/*",
13
+ "!**/dist/**/*",
14
+ "!**/coverage/**/*",
15
+ "!**/.pi-subagent-sessions/**/*",
16
+ "!**/.pi-subagent-sessions.*",
17
+ // external/ is reserved for vendored or synced third-party assets.
18
+ "!external/**/*",
19
+ // ontology/ contains generated domain artifacts/snapshots.
20
+ "!ontology/**/*",
21
+ "!**/*.min.js",
22
+ "!**/*.generated.*"
23
+ ]
24
+ },
25
+ "formatter": {
26
+ "enabled": true,
27
+ "indentStyle": "space",
28
+ "indentWidth": 2,
29
+ "lineWidth": 100
30
+ },
31
+ "linter": {
32
+ "enabled": true,
33
+ "rules": {
34
+ "recommended": true,
35
+ "suspicious": {
36
+ "noExplicitAny": "error"
37
+ },
38
+ "style": {
39
+ "useTemplate": "error"
40
+ }
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,65 @@
1
+ ---
2
+ summary: "ADR: keep pi-agent-vent hard-delete out of the v0.1 package surface; use backup-backed archive as the destructive lifecycle baseline."
3
+ read_when:
4
+ - "Changing agent_vent retention, archive, restore, delete, purge, or backup behavior."
5
+ - "Deciding whether pi-agent-vent should remove local diagnostic records or backup artifacts."
6
+ system4d:
7
+ container: "Package-local retention/delete policy decision."
8
+ compass: "Protect local diagnostic user data while avoiding false evidence/task/incident authority."
9
+ engine: "Prefer reversible archive -> explicit operator filesystem control -> future delete only by new decision."
10
+ fog: "Hard-delete can be mistaken for privacy compliance, evidence deletion, or owner-system lifecycle closure."
11
+ ---
12
+
13
+ # ADR — Agent vent retention/delete policy
14
+
15
+ Date: 2026-05-22
16
+
17
+ ## Status
18
+
19
+ Accepted.
20
+
21
+ ## Context
22
+
23
+ `pi-agent-vent` stores local diagnostic user data under the operator's Pi data directory. The package now supports confirmation-gated `retention preview|archive|restore`:
24
+
25
+ - archive removes reviewed recurrence-group records from the active `vents.jsonl` store;
26
+ - archive writes a package-created local backup first;
27
+ - restore requires the backup, exact derived restore token, real backup-directory containment, and current-store hash match;
28
+ - retention receipts and backups are local diagnostics only, not evidence, tasks, issues, incidents, telemetry, publication, or ASC/self state.
29
+
30
+ The remaining question was whether the package should also expose a hard-delete surface beyond backup-backed archive.
31
+
32
+ ## Decision
33
+
34
+ Do **not** add an in-package hard-delete action for v0.1.
35
+
36
+ The accepted package policy is:
37
+
38
+ 1. Backup-backed archive/restore is the only package-owned destructive lifecycle operation for local vent records.
39
+ 2. Permanent deletion remains operator-owned filesystem/data-lifecycle control, not a package command.
40
+ 3. The package may document store and backup paths so operators can inspect, back up, or remove local data deliberately.
41
+ 4. The package must not claim that local deletion resolves evidence, incidents, tasks, issues, telemetry, publication, or owner-system lifecycle.
42
+ 5. Any future package hard-delete or purge action requires a new decision/design pass covering confirmation, exact affected-artifact preview, backup/receipt semantics, stale-state handling, path/symlink containment, partial-failure rollback, privacy wording, and explicit non-claims about secure erasure.
43
+
44
+ ## Rationale
45
+
46
+ Hard-delete sounds simple but creates false expectations:
47
+
48
+ - local deletion is not secure erasure on all filesystems;
49
+ - backups and receipts complicate what “deleted” means;
50
+ - deleting diagnostic records could be mistaken for deleting canonical evidence or closing owner-system lifecycle;
51
+ - accidental deletion has worse recovery posture than archive/restore;
52
+ - the package's product promise is reviewable local maintenance signal, not compliance-grade data destruction.
53
+
54
+ Backup-backed archive already satisfies the near-term product need: keep active review surfaces small while preserving a rollback path.
55
+
56
+ ## Consequences
57
+
58
+ - `agent_vent retention` may include read-only planning/history projections such as `candidates` and `history`, while `archive|restore` remain the only package-owned mutating lifecycle actions.
59
+ - Product docs should describe archive as the destructive package baseline and retention history as a local receipt projection, not evidence or owner-system lifecycle.
60
+ - Future review-ergonomics work can proceed without waiting for hard-delete implementation.
61
+ - Operators who need permanent removal must use filesystem-level removal of the local store/backups and remain responsible for their own backup, retention, and secure-erasure requirements.
62
+
63
+ ## Authority boundary
64
+
65
+ This ADR governs only `packages/pi-agent-vent` local diagnostic data behavior. It does not mutate or define policy for AK tasks/evidence, GitHub issues, incident systems, Prompt Vault, ROCS, publication, KES, ASC/self state, or telemetry systems.
@@ -0,0 +1,57 @@
1
+ ---
2
+ summary: "Local engineering-core override for pi-agent-vent."
3
+ read_when:
4
+ - "Aligning implementation decisions with the TypeScript stack baseline."
5
+ - "Changing local vent persistence, privacy posture, or tool behavior."
6
+ system4d:
7
+ container: "Repo-local deltas on top of shared engineering-core guidance."
8
+ compass: "Keep local diagnostic capture minimal, testable, private, and authority-safe."
9
+ engine: "Use pi-ts lane -> apply selected disciplines -> validate with package gate."
10
+ fog: "A convenient vent log can accidentally become hidden task/evidence/incident authority."
11
+ ---
12
+
13
+ # engineering.local — pi-agent-vent
14
+
15
+ Primary lane:
16
+
17
+ - `engineering-core show pi-ts`
18
+
19
+ Retrieval command:
20
+
21
+ ```bash
22
+ uv tool -n run --from ~/ai-society/core/engineering-core engineering-core show pi-ts --prefer-repo
23
+ ```
24
+
25
+ ## Selected disciplines
26
+
27
+ Always selected:
28
+
29
+ - `validation` — package gate and unit tests are required before handoff.
30
+ - `testing` — pure recurrence/redaction/store logic belongs in `node:test` tests.
31
+ - `security-privacy` — vent records are local diagnostic user data; minimize and redact.
32
+ - `documentation` — README/design docs must match shipped tool behavior.
33
+ - `dependency-governance` — prefer Node built-ins; do not add runtime deps for trivial helpers.
34
+ - `specification-and-dsls` — JSONL record shape, `package.json#pi.extensions`, and tool parameters are executable contracts.
35
+
36
+ Package-specific selected disciplines:
37
+
38
+ - `local-first-data` — this package owns durable local JSONL state at `~/.pi/agent/agent-vent/vents.jsonl` or `PI_AGENT_VENT_DIR`.
39
+ - `data-governance` — vent records are append-only local diagnostic events, not tasks/incidents/evidence.
40
+ - `domain-modeling` — preserve the distinction between vent record, recurrence group, candidate incident, and canonical incident.
41
+ - `observability` — local summaries make recurring friction visible without cloud telemetry.
42
+
43
+ Not selected by default:
44
+
45
+ - `accessibility` / `design-system` — no custom UI surface in v0.1.
46
+ - `service-api` — no network/API boundary in v0.1.
47
+ - `ai-ml` — the package records model/tool observations but does not evaluate models or make ML safety claims.
48
+
49
+ ## Repo-local emphasis
50
+
51
+ - Runtime/package manager baseline: Node.js 22 + npm.
52
+ - Extension runtime: TypeScript entrypoint loaded by Pi; pure core logic lives in `src/vent-store.js` for deterministic tests.
53
+ - Storage: append-only JSONL; tolerate malformed old lines during reads; do not silently rewrite user data.
54
+ - Privacy: no network calls, no telemetry, no secrets in records, conservative runtime redaction.
55
+ - Authority: candidate incidents are recommendations only; do not create or imply AK/GitHub/incident mutations.
56
+ - Validation: `npm run check` from this package, or root `bash ./scripts/package-quality-gate.sh ci packages/pi-agent-vent`.
57
+ - Optional companions are intentionally not adopted for v0.1: no `fast-check`, Cucumber, Nunjucks, or ts-quality rollout.
@@ -0,0 +1,182 @@
1
+ ---
2
+ summary: "Design for pi-agent-vent: local, privacy-aware agent frustration capture."
3
+ read_when:
4
+ - "Changing the agent_vent tool or its persistence model."
5
+ - "Reviewing whether vent records may become tasks, incidents, evidence, or telemetry."
6
+ system4d:
7
+ container: "Pi extension package for local agent frustration capture."
8
+ compass: "Make recurring agent friction visible without turning vents into authority."
9
+ engine: "Agent records minimal vent -> append-only local JSONL -> local summary groups recurrence candidates -> human/operator decides escalation."
10
+ fog: "Vents can be mistaken for incident authority, telemetry, or complete evidence if boundaries are unclear."
11
+ ---
12
+
13
+ # Agent vent design
14
+
15
+ ## Product intent
16
+
17
+ `pi-agent-vent` gives the assistant a narrow tool, `agent_vent`, for recording recurring frustrations it notices while working: long-lived bugs, brittle workflows, missing affordances, repeated permission/tool failures, documentation gaps, or context-loss patterns.
18
+
19
+ The design mirrors the useful part of the referenced Lovable experiment: let the agent complain in a structured way so patterns become visible. It deliberately does **not** let the agent create canonical incidents, GitHub issues, AK tasks, or evidence records by itself.
20
+
21
+ ## Engineering-core basis
22
+
23
+ Selected guidance from `~/ai-society/core/engineering-core/`:
24
+
25
+ - `pi-ts` lane: Node 22 + npm, explicit `package.json#pi.extensions`, small deterministic package checks, no unnecessary runtime dependencies.
26
+ - `validation` + `testing`: pure grouping/redaction logic gets unit tests; package gate remains the handoff validation surface.
27
+ - `security-privacy`: records are local by default, minimized, redacted heuristically, and must not contain secrets or raw user payloads.
28
+ - `local-first-data`: durable state is append-only JSONL under an explicit local store path; export/delete posture is documented.
29
+ - `data-governance`: vent records are local audit/diagnostic events, not canonical task/evidence authority.
30
+ - `domain-modeling`: vocabulary distinguishes `vent`, `recurrence group`, and `candidate incident` to avoid authority drift.
31
+ - `observability`: the package emits useful local diagnostic summaries without cloud telemetry.
32
+
33
+ ## Boundary model
34
+
35
+ | Concept | Meaning | Authority |
36
+ |---|---|---|
37
+ | Vent record | One agent-observed frustration/friction event. | Local append-only diagnostic event. |
38
+ | Recurrence key | Stable grouping key, explicit or derived from category + summary. | Local grouping aid only. |
39
+ | Review event | Append-only local state change for one recurrence group. | Local operator inbox state only. |
40
+ | Curation event | Append-only merge/rename projection for recurrence keys. | Local grouping projection only; raw vents are not rewritten. |
41
+ | Retention event | Append-only receipt for a local archive or restore operation. | Local lifecycle receipt only; not evidence or owner-system deletion. |
42
+ | Retention backup | Package-created local rollback artifact containing the pre-archive vents store. | Local rollback artifact only; not canonical evidence. |
43
+ | Candidate incident | A repeated/high-severity local pattern worth human review. | Recommendation only; not an incident declaration. |
44
+ | Task/issue/evidence | Canonical work or evidence artifact. | Owned by AK/GitHub/other owner surfaces, not this package. |
45
+
46
+ ## Storage contract
47
+
48
+ Default path:
49
+
50
+ ```text
51
+ ~/.pi/agent/agent-vent/vents.jsonl
52
+ ```
53
+
54
+ Override:
55
+
56
+ ```text
57
+ PI_AGENT_VENT_DIR=/path/to/private/dir
58
+ ```
59
+
60
+ Record shape is schema-versioned (`schemaVersion: 1`) and append-only. Each line is one JSON object.
61
+
62
+ Review-state, recurrence-curation, and retention lifecycle events are stored beside vents; retention backups are stored under a package-created local backup directory:
63
+
64
+ ```text
65
+ ~/.pi/agent/agent-vent/review-events.jsonl
66
+ ~/.pi/agent/agent-vent/curation-events.jsonl
67
+ ~/.pi/agent/agent-vent/retention-events.jsonl
68
+ ~/.pi/agent/agent-vent/backups/
69
+ ```
70
+
71
+ Review lifecycle is local-only:
72
+
73
+ ```text
74
+ new -> acknowledged | dismissed | escalation_drafted
75
+ ```
76
+
77
+ A missing review event means `new`; the latest event for a recurrence key is the projected local review state. Resetting to `new` appends another local event. Curation events project source recurrence keys onto target recurrence keys for merge/rename views; raw vent records keep their original keys. Local review-state commands and record feedback resolve curated source keys to the active projected recurrence group before displaying or appending review state. Curation rollback uses an append-only `remove` event for the source recurrence key.
78
+
79
+ Read behavior goes through a diagnostic-state membrane: malformed JSONL lines are ignored and counted, oversized lines are skipped, oversized files fail closed, schema-invalid records are ignored, stored display fields are redacted again on read, privacy metadata is recomputed for loaded vent records, and semantic curation cycles are quarantined instead of bricking all projections. JSONL store files fail closed if replaced by symlinks.
80
+
81
+ Retention/delete posture: no automatic deletion. Reviewed recurrence groups can be archived only after an explicit preview returns the exact affected record count/sample ids and an `archive:<token>` derived from the active store hash. Archive and vent-record append share a local lock, archive writes a package-created backup before replacing the active `vents.jsonl`, and receipt failures roll the active store back when the archive rewrite can still be identified. Restore requires the package-created backup path, exact derived `restore:<token>`, real backup-directory containment, and a current-store hash match so stale rollback attempts fail closed. Backup artifacts remain local diagnostic user data and are not evidence. The accepted retention/delete policy is [ADR 2026-05-22](../adr/2026-05-22-agent-vent-retention-delete-policy.md): no in-package hard-delete action for v0.1; permanent removal remains operator-owned filesystem/data-lifecycle control unless a future decision accepts a narrower purge design.
82
+
83
+ ## Privacy contract
84
+
85
+ The tool prompt and runtime validation both bias toward minimal summaries:
86
+
87
+ - do not include secrets, tokens, credentials, or raw user payloads;
88
+ - use short summaries and concrete reproduction hints instead of copied logs;
89
+ - apply conservative redaction heuristics for common token/password/API-key shapes;
90
+ - keep everything local; no network calls and no cloud telemetry.
91
+
92
+ ## Tool surface
93
+
94
+ ### `agent_vent`
95
+
96
+ Actions:
97
+
98
+ - `record` — append a vent record.
99
+ - `summary` — summarize recurrence groups and candidate incidents.
100
+ - `list` — show recent records.
101
+ - `path` — show local store path and data contract.
102
+ - `review` — show recurrence groups as a local review queue, optionally focused by local category/tag/tool/package facet filters; when given a recurrence key, show bounded representative local samples for that group.
103
+ - `outcomes` — show read-only post-review follow-up grouped by local review outcome state, optionally focused by local category/tag/tool/package facet filters.
104
+ - `compare` — show a read-only cross-state review comparison before export, retention planning, or draft-only handoff, optionally focused by local category/tag/tool/package facet filters.
105
+ - `facets` — show read-only local category/tag/tool/package facet counts for triage.
106
+ - `set_review` — append a local review-state event for a recurrence group.
107
+ - `curate` — append a local recurrence merge/rename projection event.
108
+ - `draft` — generate draft-only owner-surface text for a recurrence group.
109
+ - `stats` — show local store counts, byte sizes, malformed-line counts, curation counts, and review-state totals.
110
+ - `export` — emit a bounded local diagnostic projection in markdown or JSON.
111
+ - `retention` — list read-only retention candidates and receipt history, preview, confirmation-gate, archive, and restore reviewed local diagnostic records with local backup receipts.
112
+
113
+ Important behavior:
114
+
115
+ - `record` requires `summary`.
116
+ - `severity` defaults to `medium`.
117
+ - `category` defaults to `other`.
118
+ - `recurrenceKey` may be supplied by the agent; otherwise it is derived from category + summary.
119
+ - candidate incident flagging is local and advisory.
120
+ - `tool` and `packageName` are optional caller-supplied local diagnostic facets, not owner-routing truth.
121
+ - `facets` is read-only and summarizes local labels; it never mutates AK, GitHub, incident, evidence, telemetry, or ASC/self state.
122
+ - `review` facet filters are read-only local diagnostic focus aids; review command syntax fails closed before store reads for unknown filter keys, invalid states, and invalid category values, and filters do not assign owners, route work, mutate owner surfaces, or change review state.
123
+ - `review` queue/detail, `outcomes`, `compare`, and retention-candidate output may show explicit derived decision posture, advisory human-review hints, exact next-action commands for local review states, draft-only handoff targets, export prompts, and retention preview eligibility; generated commands quote dynamic recurrence keys/paths for legacy key safety. Decision posture is a local diagnostic projection derived from current review state and candidate-incident priority; it is not resolution, assignment, issue status, task truth, incident state, evidence, or publication. Filtered compare follow-up commands preserve supported category/tag/tool/package filters for `outcomes`, `retention candidates`, and `export`; export applies review-state and facet scope before counts, summaries, and display rows so mixed recurrence groups do not broaden output. Outcome and compare limits are per review-state bucket rather than global. Review/outcome/compare/export command syntax fails closed before store reads for unknown filters, empty filter values such as `owner=` or `tag=`, invalid states/arguments, and invalid category values. These are UX guidance only and do not route, submit, file, create, declare, assign owners, record evidence, publish, archive, restore, or mutate owner systems; compare intentionally emits no retention confirmation tokens.
124
+ - `set_review` requires an existing recurrence group and never mutates AK, GitHub, incident, evidence, telemetry, or ASC/self state.
125
+ - `curate` requires an existing source group, rejects self/cycle aliases, supports append-only `remove` undo events, and stores local projection events only.
126
+ - `draft` supports `github_issue`, `ak_task`, `incident_review`, and `maintainer_note`; it includes local diagnostic facets when present, returns text only, and never submits, files, declares, records evidence, assigns owners, or changes review state automatically.
127
+ - `stats` and `export` are read-only projections and must not claim evidence, publication, task, issue, owner-routing, owner-assignment, or incident authority. Export may preserve local category/tag/tool/package facet scope as a diagnostic focus aid only, and export follow-up commands must remain local diagnostic or draft-only hints with no archive/restore confirmation tokens.
128
+ - `retention candidates` and `retention history` are read-only projections; history reconstructs rollback-candidate restore commands from archive receipts without reading active vents/backups, while actual restore still enforces realpath containment and stale-state checks. `retention preview` is read-only; `retention archive` mutates only the active local vents store after exact confirmation, lock acquisition, store-hash verification, and backup creation; `retention restore` mutates only the active local vents store after exact confirmation, realpath containment, and stale-state checks.
129
+
130
+ ### `/agent_vent`
131
+
132
+ Human/operator command for lightweight inspection. `/agent-vent` remains a compatibility alias.
133
+
134
+ - `/agent_vent help`
135
+ - `/agent_vent summary`
136
+ - `/agent_vent list [limit]`
137
+ - `/agent_vent path`
138
+ - `/agent_vent facets [limit]`
139
+ - `/agent_vent review [new|acknowledged|dismissed|escalation_drafted|all] [limit] [category=bug] [tag=reload] [tool=pi-reload] [package=tryinget-pi-agent-vent]`
140
+ - `/agent_vent review show <recurrenceKey> [limit]`
141
+ - `/agent_vent review set <state> <recurrenceKey> [note]`
142
+ - `/agent_vent outcomes [new|acknowledged|dismissed|escalation_drafted|all] [per-state-limit] [category=bug] [tag=reload] [tool=pi-reload] [package=tryinget-pi-agent-vent]`
143
+ - `/agent_vent compare [per-state-limit] [category=bug] [tag=reload] [tool=pi-reload] [package=tryinget-pi-agent-vent]`
144
+ - `/agent_vent curate merge <sourceRecurrenceKey> <targetRecurrenceKey> [note]`
145
+ - `/agent_vent curate rename <sourceRecurrenceKey> <targetRecurrenceKey> [note]`
146
+ - `/agent_vent curate remove <sourceRecurrenceKey> [note]`
147
+ - `/agent_vent draft <github_issue|ak_task|incident_review|maintainer_note> <recurrenceKey> [limit]`
148
+ - `/agent_vent stats`
149
+ - `/agent_vent export [markdown|json] [state|all] [limit] [category=bug] [tag=reload] [tool=pi-reload] [package=tryinget-pi-agent-vent]`
150
+ - `/agent_vent retention history [limit]`
151
+ - `/agent_vent retention preview <recurrenceKey>`
152
+ - `/agent_vent retention archive <recurrenceKey> <archive:token> [note]`
153
+ - `/agent_vent retention restore <backupPath> <restore:token> [note]`
154
+
155
+ ## Candidate incident heuristic
156
+
157
+ A recurrence group is flagged as a candidate incident when:
158
+
159
+ - any record is `critical`; or
160
+ - the group has at least three records and max severity is at least `medium`; or
161
+ - the group has at least two records and max severity is at least `high`.
162
+
163
+ This heuristic intentionally errs toward surfacing review candidates, not asserting operational truth.
164
+
165
+ ## Cross-package integration
166
+
167
+ `pi-agent-vent` remains separate from `pi-autonomous-session-control` by design:
168
+
169
+ - ASC/`self` owns operational introspection, subagent/runtime control, and mirror-only handoff/progress summaries.
170
+ - `pi-agent-vent` owns local diagnostic vent records, redaction, recurrence grouping, and advisory candidate-incident heuristics.
171
+ - `pi-toolbox-discovery` owns discovery/activation of the already-registered `agent_vent` tool through the same-named `agent_vent` bundle.
172
+
173
+ This keeps vent persistence from becoming hidden ASC state while still making the capability discoverable during autonomous work.
174
+
175
+ ## Non-goals for v0.1
176
+
177
+ - No automatic GitHub issue creation.
178
+ - No AK task creation.
179
+ - No incident declaration in external systems.
180
+ - No model judging/evaluation loop.
181
+ - No remote telemetry or team sync.
182
+ - No UI dashboard beyond command/tool text output.