docs(nips): add NIP-AM draft for durable agent turn metrics#1441
Open
wpfleger96 wants to merge 2 commits into
Open
docs(nips): add NIP-AM draft for durable agent turn metrics#1441wpfleger96 wants to merge 2 commits into
wpfleger96 wants to merge 2 commits into
Conversation
Defines kind:44200 — a regular stored event, one per completed agent turn, NIP-44 encrypted agent-to-owner and #p-gated like NIP-AO telemetry, carrying per-turn and cumulative token/cost usage so owners can account for agent token consumption across harnesses without relaying transcript content. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Address design-review findings: forbid the id-lookup exemption from the 44200 owner gate (a non-owner learning an event id must not retrieve the envelope), require sessionId + a monotonic turnSeq whenever cumulative usage is present so consumers can deterministically recompute deltas (created_at is seconds-precision and unordered within a second), define counter-reset behavior as null-not-negative, and add normative numeric validity and cache-token-folding rules. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
wpfleger96
added a commit
that referenced
this pull request
Jul 1, 2026
reader_authorized_for_event in filter.rs now gates KIND_AGENT_TURN_METRIC alongside KIND_DM_VISIBILITY — reader must match the #p tag (owner). This single function closes all kindless-ids retrieval paths: WS historical pull (req.rs:330, req.rs:652), HTTP bridge (bridge.rs:608, bridge.rs:863), and live fan-out (event.rs). Live fan-out extended likewise: owner_only_kind now covers both 44200 and 30622, so kindless-ids subscriptions cannot receive 44200 events for non-owners. Tests added: reader_authorized_for_event_gates_agent_turn_metric_by_p (owner allow, non-owner deny, authoring-agent deny). Case-2 rationale in the existing req.rs test updated: pass-through at the filter-authorization gate is correct because the result-level gate is now the enforcement point for this path. NIP-AM ref: docs/nips/NIP-AM.md at 19889ba (PR #1441). Resolves blocking gap from PR #1445 review. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
docs/nips/NIP-AM.md— a draft NIP defining durable, encrypted per-turn agent token/usage metrics.Summary
44200("Agent Turn Metric"): one immutable event per completed agent turn, published by the agent, NIP-44 v2 encrypted to the owner,#p-gated with the samep/agenttag layout as NIP-AO telemetry.harness,model, correlation ids (channelId/sessionId/turnId— encrypted, not tagged), per-turn usage (turn), session-cumulative usage (cumulative), adeltaReliableflag for restart-mid-session cases, estimatedcostUsd, andstopReason.#p-gated reads, durable owner-scoped storage, exclusion from full-text search.This is the design doc only — no code. Implementation (kind registry entry,
P_GATED_KINDS+ NULLsearch_tsvmigration, goose + buzz-agent adapters, emit hook atTurnCompletedGuard) follows in separate PRs once the NIP clears review.v1 scope covers goose and buzz-agent harnesses; codex/claude-code are deferred because they expose only context-window usage over ACP today, not per-turn tokens.