@wyattjoh/rfc-pi 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/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # `@wyattjoh/rfc-pi`
2
+
3
+ Native [Pi](https://pi.dev) integration for the RFC Evidence Engine. The package registers the six `rfc_*` tools, adds the bounded RFC lookup workflow to the system prompt, and includes the `/rfc-lookup` skill.
4
+
5
+ ## Install
6
+
7
+ Requires Bun 1.4.2 or newer:
8
+
9
+ ```sh
10
+ pi install npm:@wyattjoh/rfc-pi@latest
11
+ ```
12
+
13
+ Authenticate the latest published CLI once before using semantic tools:
14
+
15
+ ```sh
16
+ bunx @wyattjoh/rfc@latest auth login
17
+ bunx @wyattjoh/rfc@latest auth
18
+ ```
19
+
20
+ The extension runs `bunx @wyattjoh/rfc@latest` for each tool call. Credentials remain in the OS credential manager and are never exposed to Pi or accepted through tool input.
21
+
22
+ Review the package before installation: Pi extensions execute with the user's full system permissions.
@@ -0,0 +1,321 @@
1
+ import { spawn } from "node:child_process";
2
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
+ import {
4
+ renderAuthStatus,
5
+ renderCitationVerification,
6
+ renderEvidenceBundle,
7
+ renderSourceCacheRemove,
8
+ renderSourceCacheStatus,
9
+ rfcAgentToolMetadata,
10
+ rfcMcpInstructions,
11
+ type AuthStatus,
12
+ } from "@wyattjoh/rfc";
13
+ import {
14
+ datatrackerTopicSearchTermLimit,
15
+ datatrackerTopicSearchTermMaximumCharacters,
16
+ schemaVersion,
17
+ type CitationVerificationResult,
18
+ type EvidenceBundle,
19
+ type RfcSourceCacheRemoveResult,
20
+ type RfcSourceCacheStatus,
21
+ } from "@wyattjoh/rfc-core";
22
+ import { Type } from "typebox";
23
+
24
+ const rfcPackageSpec = "@wyattjoh/rfc@latest";
25
+ const commandTimeoutMilliseconds = 180_000;
26
+ const commandOutputMaximumBytes = 1024 * 1024;
27
+
28
+ const nonEmptyString = (description: string) => Type.String({ description, minLength: 1 });
29
+
30
+ const knownRfcResearchParameters = Type.Object(
31
+ {
32
+ question: nonEmptyString("One independently answerable RFC question"),
33
+ rfc: nonEmptyString("Exact published RFC identifier, for example RFC9110"),
34
+ },
35
+ { additionalProperties: false },
36
+ );
37
+
38
+ const topicResearchParameters = Type.Object(
39
+ {
40
+ question: nonEmptyString("One independently answerable topic question"),
41
+ searchTerms: Type.Array(
42
+ Type.String({
43
+ description:
44
+ "Deliberate topic-discovery term sent verbatim in Datatracker query URLs and upstream logs",
45
+ minLength: 1,
46
+ maxLength: datatrackerTopicSearchTermMaximumCharacters,
47
+ }),
48
+ { minItems: 1, maxItems: datatrackerTopicSearchTermLimit },
49
+ ),
50
+ },
51
+ { additionalProperties: false },
52
+ );
53
+
54
+ const citationParameters = Type.Object(
55
+ {
56
+ rfc: nonEmptyString("Exact published RFC identifier containing the quotation"),
57
+ claim: nonEmptyString("One factual claim to check"),
58
+ quote: nonEmptyString("Exact unchanged RFC quotation"),
59
+ offset: Type.Optional(
60
+ Type.Integer({
61
+ description:
62
+ "Absolute UTF-8 byte offset copied from research provenance; omit for a unique quotation",
63
+ minimum: 0,
64
+ }),
65
+ ),
66
+ },
67
+ { additionalProperties: false },
68
+ );
69
+
70
+ const rfcParameters = Type.Object(
71
+ {
72
+ rfc: nonEmptyString("Exact named RFC source-cache entry, for example RFC9110"),
73
+ },
74
+ { additionalProperties: false },
75
+ );
76
+
77
+ const sourceCacheRemoveParameters = Type.Object(
78
+ {
79
+ rfc: nonEmptyString("Exact named RFC source-cache entry, for example RFC9110"),
80
+ confirm: Type.Literal(true, {
81
+ description: "Must be true to confirm removal of the named cache entry",
82
+ }),
83
+ },
84
+ { additionalProperties: false },
85
+ );
86
+
87
+ const emptyParameters = Type.Object({}, { additionalProperties: false });
88
+
89
+ type RfcToolDetails = {
90
+ readonly structuredContent: object;
91
+ readonly warnings: ReadonlyArray<object>;
92
+ };
93
+
94
+ type RfcCommandResult<A extends object> = {
95
+ readonly value: A;
96
+ readonly warnings: ReadonlyArray<object>;
97
+ };
98
+
99
+ const successResult = (
100
+ structuredContent: object,
101
+ text: string,
102
+ warnings: ReadonlyArray<object> = [],
103
+ ) => ({
104
+ content: [
105
+ { type: "text" as const, text },
106
+ ...warnings.map((warning) => ({ type: "text" as const, text: JSON.stringify(warning) })),
107
+ ],
108
+ details: { structuredContent, warnings } satisfies RfcToolDetails,
109
+ });
110
+
111
+ const parseJsonObject = (value: string): object | undefined => {
112
+ try {
113
+ const parsed: unknown = JSON.parse(value);
114
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)
115
+ ? parsed
116
+ : undefined;
117
+ } catch {
118
+ return undefined;
119
+ }
120
+ };
121
+
122
+ const runRfcCommand = <A extends object>(
123
+ args: ReadonlyArray<string>,
124
+ input: object | undefined,
125
+ signal: AbortSignal | undefined,
126
+ ): Promise<RfcCommandResult<A>> =>
127
+ new Promise((resolve, reject) => {
128
+ signal?.throwIfAborted();
129
+
130
+ const child = spawn("bunx", [rfcPackageSpec, ...args], {
131
+ stdio: ["pipe", "pipe", "pipe"],
132
+ });
133
+ const stdout: Array<Buffer> = [];
134
+ const stderr: Array<Buffer> = [];
135
+ let outputBytes = 0;
136
+ let outputError: Error | undefined;
137
+ let settled = false;
138
+
139
+ const cleanup = (): void => {
140
+ clearTimeout(timeout);
141
+ signal?.removeEventListener("abort", abort);
142
+ };
143
+ const finishWithError = (error: Error): void => {
144
+ if (settled) return;
145
+ settled = true;
146
+ cleanup();
147
+ reject(error);
148
+ };
149
+ const abort = (): void => {
150
+ child.kill("SIGTERM");
151
+ finishWithError(new Error("RFC tool execution was cancelled"));
152
+ };
153
+ const timeout = setTimeout(() => {
154
+ child.kill("SIGTERM");
155
+ finishWithError(new Error("RFC tool execution timed out"));
156
+ }, commandTimeoutMilliseconds);
157
+ const capture = (chunks: Array<Buffer>) => (chunk: Buffer) => {
158
+ outputBytes += chunk.byteLength;
159
+ if (outputBytes > commandOutputMaximumBytes) {
160
+ outputError = new Error("RFC tool output exceeded 1048576 bytes");
161
+ child.kill("SIGTERM");
162
+ return;
163
+ }
164
+ chunks.push(chunk);
165
+ };
166
+
167
+ signal?.addEventListener("abort", abort, { once: true });
168
+ child.stdout.on("data", capture(stdout));
169
+ child.stderr.on("data", capture(stderr));
170
+ child.once("error", finishWithError);
171
+ child.once("close", (code) => {
172
+ if (settled) return;
173
+ if (outputError !== undefined) {
174
+ finishWithError(outputError);
175
+ return;
176
+ }
177
+
178
+ const stdoutText = Buffer.concat(stdout).toString("utf8").trim();
179
+ const stderrLines = Buffer.concat(stderr)
180
+ .toString("utf8")
181
+ .split("\n")
182
+ .map((line) => line.trim())
183
+ .filter((line) => line.length > 0);
184
+ const stderrObjects = stderrLines.flatMap((line) => {
185
+ const parsed = parseJsonObject(line);
186
+ return parsed === undefined ? [] : [parsed];
187
+ });
188
+
189
+ if (code !== 0) {
190
+ const envelope = stderrObjects.find((entry) => "kind" in entry && entry.kind === "error");
191
+ finishWithError(
192
+ new Error(
193
+ envelope === undefined
194
+ ? "RFC CLI failed without a versioned error envelope"
195
+ : JSON.stringify(envelope),
196
+ ),
197
+ );
198
+ return;
199
+ }
200
+
201
+ const value = parseJsonObject(stdoutText);
202
+ if (value === undefined) {
203
+ finishWithError(new Error("RFC CLI returned an invalid JSON result"));
204
+ return;
205
+ }
206
+
207
+ settled = true;
208
+ cleanup();
209
+ resolve({ value: value as A, warnings: stderrObjects });
210
+ });
211
+
212
+ child.stdin.on("error", () => undefined);
213
+ child.stdin.end(input === undefined ? undefined : `${JSON.stringify(input)}\n`);
214
+ });
215
+
216
+ /**
217
+ * Register the RFC evidence engine as native Pi tools with the MCP surface's names and metadata.
218
+ *
219
+ * @param pi Pi extension API used to register tools and prompt guidance.
220
+ */
221
+ export default function rfcExtension(pi: ExtensionAPI): void {
222
+ pi.on("before_agent_start", (event) => {
223
+ event.systemPromptOptions.sections.rfc_evidence_engine = rfcMcpInstructions;
224
+ });
225
+
226
+ pi.registerTool({
227
+ name: rfcAgentToolMetadata.researchKnownRfc.name,
228
+ label: rfcAgentToolMetadata.researchKnownRfc.title,
229
+ description: rfcAgentToolMetadata.researchKnownRfc.description,
230
+ promptSnippet: rfcAgentToolMetadata.researchKnownRfc.title,
231
+ parameters: knownRfcResearchParameters,
232
+ async execute(_toolCallId, { question, rfc }, signal) {
233
+ const result = await runRfcCommand<EvidenceBundle>(
234
+ ["research"],
235
+ { schemaVersion, question, rfc },
236
+ signal,
237
+ );
238
+ return successResult(result.value, renderEvidenceBundle(result.value), result.warnings);
239
+ },
240
+ });
241
+
242
+ pi.registerTool({
243
+ name: rfcAgentToolMetadata.researchTopic.name,
244
+ label: rfcAgentToolMetadata.researchTopic.title,
245
+ description: rfcAgentToolMetadata.researchTopic.description,
246
+ promptSnippet: rfcAgentToolMetadata.researchTopic.title,
247
+ parameters: topicResearchParameters,
248
+ async execute(_toolCallId, { question, searchTerms }, signal) {
249
+ const result = await runRfcCommand<EvidenceBundle>(
250
+ ["research"],
251
+ { schemaVersion, question, rfc: null, searchTerms },
252
+ signal,
253
+ );
254
+ return successResult(result.value, renderEvidenceBundle(result.value), result.warnings);
255
+ },
256
+ });
257
+
258
+ pi.registerTool({
259
+ name: rfcAgentToolMetadata.verifyCitation.name,
260
+ label: rfcAgentToolMetadata.verifyCitation.title,
261
+ description: rfcAgentToolMetadata.verifyCitation.description,
262
+ promptSnippet: rfcAgentToolMetadata.verifyCitation.title,
263
+ parameters: citationParameters,
264
+ async execute(_toolCallId, { rfc, claim, quote, offset }, signal) {
265
+ const result = await runRfcCommand<CitationVerificationResult>(
266
+ ["verify-citation"],
267
+ { schemaVersion, rfc, claim, quote, offset: offset ?? null },
268
+ signal,
269
+ );
270
+ return successResult(result.value, renderCitationVerification(result.value), result.warnings);
271
+ },
272
+ });
273
+
274
+ pi.registerTool({
275
+ name: rfcAgentToolMetadata.sourceCacheStatus.name,
276
+ label: rfcAgentToolMetadata.sourceCacheStatus.title,
277
+ description: rfcAgentToolMetadata.sourceCacheStatus.description,
278
+ promptSnippet: rfcAgentToolMetadata.sourceCacheStatus.title,
279
+ parameters: rfcParameters,
280
+ async execute(_toolCallId, { rfc }, signal) {
281
+ const result = await runRfcCommand<RfcSourceCacheStatus>(
282
+ ["cache", "status", "--rfc", rfc, "--format", "json"],
283
+ undefined,
284
+ signal,
285
+ );
286
+ return successResult(result.value, renderSourceCacheStatus(result.value), result.warnings);
287
+ },
288
+ });
289
+
290
+ pi.registerTool({
291
+ name: rfcAgentToolMetadata.sourceCacheRemove.name,
292
+ label: rfcAgentToolMetadata.sourceCacheRemove.title,
293
+ description: rfcAgentToolMetadata.sourceCacheRemove.description,
294
+ promptSnippet: rfcAgentToolMetadata.sourceCacheRemove.title,
295
+ parameters: sourceCacheRemoveParameters,
296
+ async execute(_toolCallId, { rfc }, signal) {
297
+ const result = await runRfcCommand<RfcSourceCacheRemoveResult>(
298
+ ["cache", "remove", "--rfc", rfc, "--format", "json"],
299
+ undefined,
300
+ signal,
301
+ );
302
+ return successResult(result.value, renderSourceCacheRemove(result.value), result.warnings);
303
+ },
304
+ });
305
+
306
+ pi.registerTool({
307
+ name: rfcAgentToolMetadata.authStatus.name,
308
+ label: rfcAgentToolMetadata.authStatus.title,
309
+ description: rfcAgentToolMetadata.authStatus.description,
310
+ promptSnippet: rfcAgentToolMetadata.authStatus.title,
311
+ parameters: emptyParameters,
312
+ async execute(_toolCallId, _params, signal) {
313
+ const result = await runRfcCommand<AuthStatus>(
314
+ ["auth", "status", "--format", "json"],
315
+ undefined,
316
+ signal,
317
+ );
318
+ return successResult(result.value, renderAuthStatus(result.value), result.warnings);
319
+ },
320
+ });
321
+ }
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@wyattjoh/rfc-pi",
3
+ "version": "0.1.0",
4
+ "description": "Native Pi extension and lookup skill for evidence-grounded IETF RFC research.",
5
+ "keywords": [
6
+ "ietf",
7
+ "pi-extension",
8
+ "pi-package",
9
+ "rfc"
10
+ ],
11
+ "license": "MIT",
12
+ "author": "Wyatt Johnson",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/wyattjoh/rfc.git",
16
+ "directory": "packages/rfc-pi"
17
+ },
18
+ "files": [
19
+ "extensions",
20
+ "skills"
21
+ ],
22
+ "type": "module",
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "scripts": {
27
+ "test": "bun test test",
28
+ "typecheck": "tsc --noEmit -p tsconfig.json"
29
+ },
30
+ "dependencies": {
31
+ "@wyattjoh/rfc": "0.2.1",
32
+ "@wyattjoh/rfc-core": "0.1.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/bun": "1.4.2",
36
+ "typescript": "7.0.2"
37
+ },
38
+ "peerDependencies": {
39
+ "@earendil-works/pi-coding-agent": "*",
40
+ "typebox": "*"
41
+ },
42
+ "engines": {
43
+ "bun": ">=1.4.2"
44
+ },
45
+ "pi": {
46
+ "extensions": [
47
+ "./extensions/rfc.ts"
48
+ ],
49
+ "skills": [
50
+ "./skills"
51
+ ]
52
+ }
53
+ }
@@ -0,0 +1,279 @@
1
+ ---
2
+ name: rfc-lookup
3
+ description: Answer questions about published IETF RFCs from exact authoritative source text through the self-describing RFC MCP or linked typed `rfc` CLI. Use for RFC requirements, definitions, procedures, updates, obsoletions, or citations. For one atomic question, never exceed two research calls and two citation calls, never loop by rephrasing a valid result, and preserve the status of qualified review candidates.
4
+ argument-hint: "[RFC number or question]"
5
+ ---
6
+
7
+ # RFC lookup
8
+
9
+ Use the RFC MCP when its tools are available; otherwise use the linked `rfc`
10
+ binary. Both are complete RFC research backends and own live RFC discovery,
11
+ source retrieval, evidence selection, RFC currency, and citation verification.
12
+ Compose only a short answer from returned canonical passages, preserving whether
13
+ each passage is accepted evidence or a qualified review candidate; never answer
14
+ from memory or a second provider.
15
+
16
+ ## Self-describing MCP surface
17
+
18
+ Launch the local stdio server with `rfc mcp`. A model connected through MCP does
19
+ not need this skill or direct CLI access: initialization instructions contain the
20
+ bounded workflow, and `rfc://docs/agent-workflow` contains the complete agent
21
+ reference. The typed tools are `rfc_research_known_rfc`, `rfc_research_topic`,
22
+ `rfc_verify_citation`, `rfc_source_cache_status`, `rfc_source_cache_remove`, and
23
+ `rfc_auth_status`.
24
+
25
+ Successful calls return concise text plus complete version-two structured
26
+ content. Operational failures are MCP tool errors containing the same safe error
27
+ envelope as the CLI. Research status and citation verdict remain domain results,
28
+ not tool failures. `rfc_source_cache_remove` requires `confirm: true`.
29
+
30
+ The MCP deliberately excludes credential mutation and per-call cache or upstream
31
+ URL overrides. If `rfc_auth_status` or a tool error reports a missing credential, ask
32
+ the human operator to run `rfc auth login`; never solicit a key through MCP. Trusted
33
+ cache and upstream overrides may be set only when the operator launches
34
+ `rfc mcp`.
35
+
36
+ ## Bounded agent workflow
37
+
38
+ Use the typed MCP tools directly when available. Otherwise use `rfc` directly;
39
+ do not resolve its installation path, invoke its TypeScript entrypoint with
40
+ `bun`, read source-cache internals, or use shell loops to probe wording and
41
+ offsets.
42
+
43
+ For each simple atomic user question, use this hard budget:
44
+
45
+ 1. Call `rfc_research_known_rfc` or `rfc_research_topic` once, or run one
46
+ `rfc research --format human` fallback call.
47
+ 2. Only when that result has no usable evidence, run at most one targeted
48
+ follow-up research call. Do not repeatedly rephrase a valid result to chase
49
+ `answered` or a higher confidence.
50
+ 3. If the result includes accepted evidence, quote it directly with provenance.
51
+ If it includes a review candidate, quote it only as qualified, unaccepted
52
+ evidence. Verify at most two paraphrased claims once each; exact reproduction
53
+ of a returned passage does not require duplicate verification.
54
+ 4. Stop after the budget. Do not say that no source passage was found when the
55
+ backend returned a review candidate; report its status and qualification.
56
+ Keep nearby protocol categories distinct rather than substituting one for
57
+ another.
58
+
59
+ A direct quote-verification request starts with one `rfc_verify_citation` tool call
60
+ or `rfc verify-citation` fallback call and needs no research preflight. If the
61
+ quote is `fabricated`, use at most one research call to locate current wording
62
+ and at most one verification call for the replacement. Never guess or
63
+ brute-force byte offsets: copy an offset from research provenance, or omit it
64
+ when the quote occurs only once. If replacement research returns a review
65
+ candidate, report that exact candidate and its qualification instead of
66
+ re-querying for a higher score.
67
+
68
+ Use MCP's concise text content for agent-facing calls; the complete result also
69
+ remains available as structured content. For the CLI fallback, use
70
+ `--format human`. Both include status, accepted quotes, qualified review
71
+ candidates, source URLs, byte offsets, input tokens, and estimated cost without
72
+ dumping full model diagnostics into the conversation. Use CLI JSON only when
73
+ code needs to extract a specific field, and summarize it before returning it to
74
+ model context.
75
+
76
+ ## Install and link the CLI
77
+
78
+ From the repository checkout:
79
+
80
+ ```sh
81
+ bun install --frozen-lockfile
82
+ bun run build
83
+ (cd packages/rfc && bun link)
84
+ rfc --help
85
+ ```
86
+
87
+ The MCP contract is the `rfc mcp` stdio process and its advertised metadata. The
88
+ CLI fallback contract is the `rfc` executable, not a legacy script, its resolved
89
+ installation path, or an embedded library call.
90
+
91
+ ## Authenticate once with Bun.secrets
92
+
93
+ The TypeSafe key is stored only through Bun's OS credential manager. It is never
94
+ an argv value, environment-variable authority, repository file, or output.
95
+
96
+ ```sh
97
+ rfc auth
98
+ rfc auth login
99
+ rfc auth remove
100
+ ```
101
+
102
+ `auth login` uses a masked TTY prompt. Automation may pipe one protected,
103
+ single-line key through `rfc auth login --stdin`. If the credential store is
104
+ unavailable or denied, report the typed error; do not bypass `Bun.secrets` with
105
+ a plaintext fallback.
106
+
107
+ ## Version-two semantic protocol
108
+
109
+ Use human output for normal agent work and JSON standard input only when a
110
+ multiline quote or programmatic extraction requires it. Non-whitespace standard
111
+ input is authoritative over convenience flags and positional arguments, and it
112
+ defaults to JSON output. Argument-based invocations default to human output;
113
+ pass `--format json` only for programmatic extraction. A valid research status
114
+ is a successful process result even when it is not `answered`.
115
+
116
+ ### Research one known RFC
117
+
118
+ ```sh
119
+ cat <<'JSON' | rfc research --format human
120
+ {
121
+ "schemaVersion": 2,
122
+ "question": "What does RFC 9110 require a client to send?",
123
+ "rfc": "RFC9110"
124
+ }
125
+ JSON
126
+ ```
127
+
128
+ Known-RFC research retrieves only the requested RFC's metadata and the bounded
129
+ successor relationships needed for RFC currency.
130
+
131
+ ### Discover RFCs for a topic
132
+
133
+ A topic request sets `rfc` to `null` and supplies one to four ordered, non-empty
134
+ search terms. Supply the technical phrases intentionally; they are transmitted
135
+ verbatim in Datatracker query URLs and may appear in upstream access logs. The
136
+ full natural-language question is not sent to Datatracker.
137
+
138
+ ```sh
139
+ cat <<'JSON' | rfc research --format human
140
+ {
141
+ "schemaVersion": 2,
142
+ "question": "Which published RFC defines HTTP caching requirements?",
143
+ "rfc": null,
144
+ "searchTerms": ["HTTP caching", "cache control"]
145
+ }
146
+ JSON
147
+ ```
148
+
149
+ The short form accepts the question positionally or through `--question`, then
150
+ uses repeatable `--search-term` flags. Preserve the caller's order. Do not generate hidden terms, rewrite phrases, infer a broad
151
+ query from the question, or run a catalog preflight: each supplied term appears
152
+ in Datatracker query URLs and can be retained in upstream access logs.
153
+
154
+ The result is a version-two `evidence_bundle` containing `status`, exact
155
+ `evidence`, optional exact `reviewCandidates`, optional requested/current
156
+ `contexts`, and bounded `diagnostics`. Review candidates are canonical source
157
+ passages surfaced only for bounded review; they are never accepted evidence and
158
+ must be labeled as qualified when quoted. Each human-rendered passage names its
159
+ RFC and whether it came from the requested or a current context. Do not answer a
160
+ question about the requested RFC with a current-context passage unless you
161
+ explicitly explain the distinction.
162
+ `diagnostics.usage.inputTokens` reports the provider-observed input tokens, while
163
+ `diagnostics.inputCost` reports the estimated USD charge and its per-million-token
164
+ rate. Treat a null estimate as unavailable rather than zero cost. Each successful
165
+ research or citation operation atomically updates the per-user running total in
166
+ `~/.config/rfc/usage.json`; its unpriced and missing-usage counters qualify the
167
+ cumulative estimate. Each evidence passage includes an unchanged quote and
168
+ provenance with RFC identity, nullable section, canonical URLs, source hash,
169
+ `offsetUnit`, and UTF-8 byte offsets.
170
+ Metadata, relationships, candidate collections, questions, and model responses
171
+ are request-local and are not persisted.
172
+
173
+ When the user supplies up to two explicit, independently answerable questions,
174
+ run one `rfc research` process per atomic question. For example, “Can the server
175
+ issue this?” and “What protections are required?” are two atomic questions even
176
+ when they share a topic. Keep each input and output separate. Do not merge
177
+ questions, split into more than two parts, or invent a split for an ambiguous
178
+ request.
179
+
180
+ ### Verify accepted claims once
181
+
182
+ Keep a simple answer to at most two factual claims. Exact reproduction of a
183
+ returned passage with its status and provenance needs no duplicate citation
184
+ call. For a paraphrased claim, make one citation request, once, using the exact
185
+ returned quote and byte offset. Do not split one claim into multiple paraphrased
186
+ verification attempts:
187
+
188
+ ```sh
189
+ cat <<'JSON' | rfc verify-citation --format human
190
+ {
191
+ "schemaVersion": 2,
192
+ "rfc": "RFC9110",
193
+ "claim": "The client sends a request containing the target resource.",
194
+ "quote": "The client MUST send a request containing the target resource.",
195
+ "offset": 12345
196
+ }
197
+ JSON
198
+ ```
199
+
200
+ Only accepted research evidence or a `verified` citation supports an
201
+ unqualified factual claim. A verified citation is an independent acceptance
202
+ path even when discovery was fail-closed. A review candidate may be reproduced
203
+ exactly only when explicitly labeled unaccepted or `needs_review`; do not turn it
204
+ into an unqualified paraphrase. Remove or qualify claims whose verdict is
205
+ `unsupported`, `contradicted`, or `fabricated`. Present each accepted normative
206
+ claim with its unchanged quote, RFC identifier, section when available, byte
207
+ offsets, and canonical source URL. Never repair quote wording, retry with guessed
208
+ offsets, or replace an evidence gap with recall.
209
+
210
+ ## RFC source-cache operations
211
+
212
+ Canonical RFC Editor text is cached only after that RFC is requested. Inspect or
213
+ remove one named entry without network access:
214
+
215
+ ```sh
216
+ rfc cache status RFC9110
217
+ rfc cache remove RFC9110
218
+ ```
219
+
220
+ There is no list-all, refresh-all, download-all, prefetch, or bulk-clear
221
+ operation. Fresh entries are reused; stale entries are conditionally revalidated.
222
+ A revalidation failure is an operational error, never permission to serve stale
223
+ text.
224
+
225
+ ## Fail-closed statuses and failures
226
+
227
+ Report research status exactly:
228
+
229
+ - `answered`: accepted direct evidence with no disqualifying uncertainty.
230
+ - `partial`: only part of the question or currency coverage is established.
231
+ - `unsupported`: bounded research found no accepted answering evidence.
232
+ - `needs_review`: confidence is low, evidence conflicts, discovery is empty, or
233
+ RFC currency is uncertain.
234
+ - `needs_split`: the question is compound and requires atomic questions.
235
+
236
+ Keep requested and current RFC contexts distinct. Follow returned
237
+ `relationshipPath`, `isCurrent`, and currency diagnostics; never silently
238
+ substitute a successor for the requested RFC.
239
+
240
+ On a nonzero exit, parse the version-two JSON error envelope from standard error
241
+ and stop. Common recovery actions:
242
+
243
+ | Code | Recovery |
244
+ | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
245
+ | `invalid_input` | Correct the version-two JSON, RFC, or ordered search terms. |
246
+ | `credential_missing` | Run `rfc auth login` or `rfc auth login --stdin`. |
247
+ | `credential_store_unavailable` / `credential_access_denied` | Unlock or authorize the OS store; never use plaintext fallback. |
248
+ | `discovery_failed` | Report the Datatracker failure and URL; do not use stale or invented metadata. |
249
+ | `source_cache_failed` / `source_fetch_failed` / `source_revalidation_failed` | Retry the authoritative source operation; do not substitute another representation or stale text. |
250
+ | `rfc_not_found` | Correct the exact RFC identifier or make a topic request with explicit search terms. |
251
+ | `decision_model_failed` | Report provider failure after bounded retries; do not switch providers or models. |
252
+ | `citation_quote_ambiguous` / `citation_offset_mismatch` | Never guess. Copy the exact UTF-8 byte offset from research provenance, or stop if none exists. |
253
+ | `internal_error` / `configuration_error` | Report an operational failure instead of asserting an answer. |
254
+
255
+ Never turn an operational failure into a research status or unverified
256
+ fail-closed evidence into an affirmative answer. A valid non-answer result is
257
+ not an operational failure and must not trigger a rephrasing loop.
258
+
259
+ ## Verification boundaries
260
+
261
+ Normal repository gates are deterministic and offline. They inject Datatracker,
262
+ RFC Editor, DecisionModel, clock, and credential behavior at public boundaries.
263
+ Live provider evaluation is opt-in and uses the same `Bun.secrets` boundary as
264
+ production.
265
+
266
+ ## Required scenarios
267
+
268
+ 1. **Known RFC:** pass an RFC hint, preserve exact evidence, and verify each claim.
269
+ 2. **Topic discovery:** pass one to four explicit search terms and report evidence
270
+ only when the returned status permits it.
271
+ 3. **Compound request:** split only explicit independent subquestions; otherwise
272
+ preserve `needs_split`.
273
+ 4. **Updated RFC:** show requested and current contexts and relationship paths.
274
+ 5. **Unsupported question:** report the evidence gap without recall.
275
+ 6. **Provider or upstream failure:** preserve the typed nonzero error and stop.
276
+ 7. **Citation rejection:** remove or qualify rejected claims and retain only exact
277
+ verified citations.
278
+
279
+ The linked typed CLI and this skill are the supported RFC workflow.