Dashboard › opencode-lore › Session 11O4IPi38mGF
11O4IPi38mGFDE1JKIndependent READ-ONLY security/privacy review of immutable candidate /home/byk/Code/opencode-lore-responses-reference-v2. Base 2cbf40060c67df229731cf1b9e34d5bf22ec2145; head stable change wywumkptssoy commit 8063355cb328; expected diff hash 007a15b7fd1bcf9b346d89911b2353098b6fec408c12d3b6fcc24a498a37a356. No edits/format/install/VCS/server/network/DB/exhaustive rerun. Verify identity/status/conflicts/two files/hash start/end. Inspect every changed line and privacy-sensitive surrounding code. Attack item_reference lifecycle with done-only/terminal-only shorthand, same-ID different-type replacement, sparse indices and shifted overflow, identity/call-ID collisions, unsupported fields, private query/result/coverage/diagnostic leakage, malformed ordering, retries, cancellation/backpressure, retained-state limits, resource amplification and CPU complexity. Verify references always accumulate privately before suppression/limits, never reach wire/log/callback public projection/persistence, failure envelopes fixed with output [], zero recall/follow-up side effects before invalid reference rejection, exact terminal reconciliation, rollback/exact-once. Evaluate fail-first/mutation evidence. Report PASS/CONCERN/MUST-FIX exact file:line and exploit. Never empty. End exactly MERGE or DO-NOT-MERGE.
<skill_content name="jj-guide"> # Skill: jj-guide # jj Guide for AI Agents Jujutsu (jj) is a Git-compatible VCS with mutable commits, automatic snapshotting, no staging area, and first-class conflicts. This skill teaches you how to use it safely from a non-interactive agent environment. If `.jj/` exists in the repo root, this is a jj repo. **Use `jj` commands, not `git`.** In a colocated repo (`.jj/` *and* `.git/`), git tools can read the state, but mutations should go through `jj` so the operation log stays consistent. ## Critical Rules - **NEVER** use interactive flags (`-i`, `--interactive`). TUI prompts hang in agent environments. This applies to `jj split -i`, `jj squash -i`, `jj commit -i`, `jj resolve`, `jj diffedit`, etc. - **ALWAYS** pass `-m "msg"` when describing/committing. Without `-m`, an editor opens and hangs. - **VERIFY** mutations with `jj st` and `jj log` after `squash`, `abandon`, `rebase`, `restore`, `commit`. ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2</path> <type>directory</type> <entries> .craft.yml .git .github/ .gitignore .jj/ .lore.md .oxfmtrc.json .oxlintrc.json AGENTS.md CHANGELOG.md codecov.yml LICENSE node_modules/ package.json packages/ patches/ pnpm-lock.yaml pnpm-workspace.yaml quality/ README.md scripts/ stryker.config.mjs supabase/ tsconfig.base.json tsconfig.json vitest.config.ts vitest.evals.config.ts vitest.mutation.config.ts (28 entries) </entries>
<path>/home/byk/Code/opencode-lore-responses-reference-v2/AGENTS.md</path> <type>file</type> <content> 1: <!-- This section is maintained by the coding agent via lore (https://github.com/BYK/loreai) --> 2: ## Long-term Knowledge 3: 4: For long-term knowledge entries managed by [lore](https://github.com/BYK/loreai) (gotchas, patterns, decisions, architecture), see [`.lore.md`](.lore.md) in the project root. 5: <!-- End lore-managed section --> 6: 7: ## Review 8: 9: See [`quality/REVIEW.md`](quality/REVIEW.md) for the review heuristics and workflow — regression-test discipline, adversarial-order state setup, fan-out registry coverage, recurring bug-class batteries, and the two-reviewer rule. Every non-trivial PR requires an adversarial correctness review before merge. 10: 11: # Project Overview 12: 13: Lore is a **three-tier memory architecture** for AI coding agents. ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/quality/REVIEW.md</path> <type>file</type> <content> 1: # Review Heuristics — Lore 2: 3: This document codifies the review bar for pull requests. It exists because 4: adversarial review has repeatedly caught correctness bugs that a green test 5: suite missed — skip/early-return branches, lifecycle sequences, and fan-out 6: registry gaps. Institutionalizing these patterns so they compound. 7: 8: The review workflow (§6) is referenced from AGENTS.md. 9: 10: --- 11: 12: ## 1. Regression-test discipline 13: 14: Every adversarial-review finding that surfaces a defect **must** land a 15: deterministic regression test in the same PR. The test: 16: - fails on the base branch (proving it reproduces the bug), 17: - passes on the fix (proving the fix works), 18: - drives the *real* precondition, not an artificially-constructed state (e.g. ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/package.json</path>
<type>file</type>
<content>
1: {
2: "name": "lore-monorepo",
3: "private": true,
4: "type": "module",
5: "license": "FSL-1.1-Apache-2.0",
6: "description": "Monorepo root for Lore — three-tier memory architecture",
7: "main": "./packages/opencode/src/index.ts",
8: "exports": {
9: ".": "./packages/opencode/src/index.ts"
10: },
11: "packageManager": "pnpm@10.28.0",
12: "volta": {
13: "node": "24.16.0",
14: "pnpm": "10.28.0"
15: },
16: "pnpm": {
17: "onlyBuiltDependencies": [
18: "esbuild",
19: "onnxruntime-node",
20: "sharp"
21: ],
22: "overrides": {
23: "basic-ftp": "5.3.1",
24: "ip-address": "10.2.0",
25: "fast-xml-parser": "5.7.3",
26: "@huggingface/hub": "2.11.0",
27: "onnxruntime-node": "1.27.0",
28: "yaml": ">=2.8.3",
29: "esbuild": ">=0.28.1",
30: "@opentelemetry/core": ">=2.8.0",
31: ...
No files found
The working copy has no changes. Working copy (@) : zkttmwun b30b51fc (empty) (no description set) Parent commit (@-): wywumkpt 8063355c fix/responses-private-references-v2 | fix(responses): keep item references private Warning: These bookmarks have conflicts: fix/responses-private-references Hint: Use `jj bookmark list` to see details. Use `jj bookmark set <name> -r <rev>` to resolve. zkttmwuntxzm b30b51fc2df58ae55a58170c315057892a5f05c5 wywumkptssoy 8063355cb32832bd8fac492bcbba7da22ae1976c fix(responses): keep item references private
wywumkptssoyokzxuqtnkmlrtmqquurq 8063355cb32832bd8fac492bcbba7da22ae1976c parents=2cbf40060c67df229731cf1b9e34d5bf22ec2145 conflict=false fix(responses): keep item references private pxrvwsvvkmpoxnsqmrkwrnlqvvkoltwz 2cbf40060c67df229731cf1b9e34d5bf22ec2145 parents=e977b4b1da8f8197c3238466d41de0bccd8eb054 conflict=false feat(cch): add seeds for Claude Code up to 2.1.272 (#1780)
M packages/gateway/src/pipeline.ts M packages/gateway/test/openai-responses-recall-aware-stream.test.ts packages/gateway/src/pipeline.ts | 505 +++++++++----- ...est/openai-responses-recall-aware-stream.test.ts | 760 +++++++++++++++++++++- 2 files changed, 1098 insertions(+), 167 deletions(-)
jj-default 007a15b7fd1bcf9b346d89911b2353098b6fec408c12d3b6fcc24a498a37a356 - jj-git f711a1dafa4aae40d1001f9ae6f7d245db7f35b0b355898044045db19b8a6ea3 - git-plain 80175bb03b5acff02b11ac391536ebc4fa441a53ce39f846c9c0d593f1ee23cd - git-binary 80175bb03b5acff02b11ac391536ebc4fa441a53ce39f846c9c0d593f1ee23cd -
Modified regular file packages/gateway/src/pipeline.ts:
...
7826 7826: }) => Promise<Response>;
7827 7827: /** Test-only override for the stream inactivity deadline. */
7828 7828: sseInactivityMs?: number;
7829: /** Test-only deterministic operation counter for identity-index regressions. */
7830: _onIdentityIndexOperationForTest?: () => void;
7829 7831: /**
7830 7832: * Called when a `recall` function_call is fully parsed. Runs the recall
7831 7833: * (LTM search + optional LLM result) and returns the pieces needed to
... ...
Modified regular file packages/gateway/test/openai-responses-recall-aware-stream.test.ts:
...
2019 2019: expect(JSON.stringify(completedResponse)).not.toContain("item_reference");
2020 2020: });
2021 2021:
2022: test("privately accumulates a done-only sparse Codex item_reference", async () => {
2023: const completion: {
2024: response?: GatewayResponse;
2025: successful?: boolean;
2026: } = {};
2027: const privateIdentity = "msg_done_only_private";
2028: const client = streamResponsesRecallAware(
2029: streamFrom([
2030: created("resp_done_only_reference", "gpt-5.6-terra"),
2031: sseEvent("response.output_item.done", {
2032: output_index: 7,
2033: item: { type: "item_reference", id: privateIdentity },
2034: }),
2035: sseEvent("response.completed", {
2036: response: {
2037: id: ...
Found 60 matches
/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts:
Line 7881: const referenceIdentities = new Set<string>();
Line 7883: const outputIdentityIndices = new WeakMap<
Line 7887: const referenceIdentityIndices = new WeakMap<
Line 7930: let referenceFailureDetected = false;
Line 7932: referenceFailureDetected = true;
Line 8505: if (identities.some((identity) => referenceIdentities.has(identity))) {
Line 8516: const identityIndex = identityIndexFor(outputIdentityIndices, state);
Line 8618: referenceIdentities.has(finalCallId)
Line 8981: identityIndexFor(outputIdentityIndices, state),
Line 9379: const assertTerminalOutputMatches = (
Line 9438: identityIndexFor(referenceIdentityIndices, acc),
Line 9450: identityIndexFor(outputIdentityIndices, acc),
Line 9564: const consumeReferenceEvent = (
Line 9602: const referenceIndex = ...
Found 100 matches (more matches available) /home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts: Line 207: formatResponsesEvent, Line 440: // Recall tool commit reminder Line 445: * `.lore.md` is shared project knowledge and must be committed alongside the Line 455: "Before any git commit, always run `git add .lore.md`. " + Line 458: "NEVER leave `.lore.md` modified or untracked after a commit. " + Line 633: * Detect whether a request contains a completed `git commit` tool invocation. Line 635: * output on user messages for commit indicators. Used to trigger curation at Line 636: * commit boundaries — natural checkpoints where decisions crystallize. Line 641: const GIT_COMMIT_RE = /\bgit\s+commit\b/i; Line 656: // Check user tool_result content for git commit output patterns Line 659: // Match common git commit output (e.g., "[main abc1234] commit message") Line 687: let ...
Found 100 matches (more matches available) /home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts: Line 207: formatResponsesEvent, Line 440: // Recall tool commit reminder Line 445: * `.lore.md` is shared project knowledge and must be committed alongside the Line 455: "Before any git commit, always run `git add .lore.md`. " + Line 458: "NEVER leave `.lore.md` modified or untracked after a commit. " + Line 633: * Detect whether a request contains a completed `git commit` tool invocation. Line 635: * output on user messages for commit indicators. Used to trigger curation at Line 636: * commit boundaries — natural checkpoints where decisions crystallize. Line 641: const GIT_COMMIT_RE = /\bgit\s+commit\b/i; Line 656: // Check user tool_result content for git commit output patterns Line 659: // Match common git commit output (e.g., "[main abc1234] commit message") Line 2479: // safe if a future ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts</path> <type>file</type> <content> 7780: * flow events, emits a synthetic marker text item, then rebuilds the 7781: * terminal `response.completed` reflecting only client-visible output. 7782: * - **Recall only**: suppresses the recall item, emits a synthetic marker 7783: * text item, runs the (streaming) recall follow-up, pipes the continuation 7784: * events inline continuing the `output_index` numbering, then rebuilds the 7785: * terminal `response.completed` reflecting marker + continuation. 7786: * 7787: * `onComplete` mirrors `streamResponsesPassthrough` (invoked exactly once with 7788: * the accumulated internal response for `postResponse`/calibration). ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
8380: event: string,
8381: parsed: Record<string, unknown>,
8382: state: ResponsesAccState,
8383: onDoneOnlyItem?: (
8384: outputIndex: number,
8385: item: Record<string, unknown>,
8386: ) => void,
8387: ): number | undefined => {
8388: const requiresOutputIndex =
8389: /^response\.(?:output_item|output_text|function_call_arguments|content_part|reasoning_(?:summary|text)|refusal)/.test(
8390: event,
8391: );
8392: const hasOutputIndex = Object.hasOwn(parsed, "output_index");
8393: if (!requiresOutputIndex && !hasOutputIndex) return undefined;
8394: const index = parsed.output_index;
8395: if (!Number.isSafeInteger(index) || (index as number) < 0) {
8396: throw new Error(`invalid Responses output_index for ${event}`);
8397: }
8398: const outputIndex = index as number;
8399: ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
9030: contentState.kind,
9031: finalPart,
9032: "output item content",
9033: );
9034: if (
9035: (contentState.authoritativeValueSeen &&
9036: finalValue !== contentState.authoritativeValue) ||
9037: (contentState.finalValue !== undefined &&
9038: finalValue !== contentState.finalValue) ||
9039: (contentState.partFinalValue !== undefined &&
9040: finalValue !== contentState.partFinalValue)
9041: ) {
9042: throw new Error(
9043: `Responses output_item.done changed content for index ${outputIndex}:${contentIndex}`,
9044: );
9045: }
9046: }
9047: }
9048: if (declaredType === "reasoning") {
9049: const summary ...
Found 1 matches /home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/stream/openai-responses.ts: Line 582: export function applyResponsesEvent(
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/stream/openai-responses.ts</path>
<type>file</type>
<content>
500: malformedResponsesEvent();
501: }
502: }
503: }
504:
505: function finalizedResponsesMessageContent(
506: outputIndex: number,
507: terminalContentParts: ReadonlyMap<
508: string,
509: { kind: "text" | "refusal"; value: string }
510: >,
511: ): Array<{ kind: "text" | "refusal"; value: string }> {
512: return Array.from(terminalContentParts)
513: .flatMap(([key, part]) => {
514: const [itemIndex, contentIndex] = key.split(":").map(Number);
515: return itemIndex === outputIndex ? [{ contentIndex, part }] : [];
516: })
517: .sort((a, b) => a.contentIndex - b.contentIndex)
518: .map(({ part }) => part);
519: }
520:
521: function completeCodexMessageSnapshot(
522: snapshot: Record<string, unknown>,
523: outputIndex: number,
524: terminalContentParts: ReadonlyMap<
525: ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
9748:
9749: const finish = (resp: GatewayResponse, successful: boolean): boolean => {
9750: if (completionAttempted) return completed;
9751: completionAttempted = true;
9752: recallDiagnostics.finish(successful ? "completed" : "failed");
9753: try {
9754: opts.onComplete(resp, successful);
9755: completed = true;
9756: return true;
9757: } catch (err) {
9758: log.error("openai-responses recall-aware onComplete error:", err);
9759: return false;
9760: }
9761: };
9762: const settleRecall = async (
9763: input: Parameters<typeof opts.onRecall>[0],
9764: ): ReturnType<typeof opts.onRecall> => {
9765: const admission = recallBudget.admit(recallItemReservation(input));
9766: if (admission) throw new RecallContinuationFailure("depth_exhausted");
9767: const operation = ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
10260: };
10261: const promoteDeferredCandidate = (outputIndex: number): void => {
10262: hiddenRecallBytes += unresolvedToolBytes.get(outputIndex) ?? 0;
10263: unresolvedToolBytes.delete(outputIndex);
10264: if (hiddenRecallBytes > maxHiddenRecallBytes) {
10265: throw new SSEStreamLimitError(
10266: "recall stream exceeded deferred event limit",
10267: );
10268: }
10269: };
10270:
10271: resetKeepalive();
10272: for await (const { event, data } of parseSSEStream(reader, {
10273: maxFrames: maxSSEFrames,
10274: inactivityMs: sseInactivityMs,
10275: signal,
10276: frameCounter,
10277: })) {
10278: resetKeepalive(); // upstream alive — reset inactivity ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
10914: let cparsed: Record<string, unknown>;
10915: try {
10916: cparsed = JSON.parse(cd) as Record<string, unknown>;
10917: } catch {
10918: if (ce.startsWith("response.")) {
10919: throw new Error(
10920: `malformed JSON in Responses event ${ce}`,
10921: );
10922: }
10923: if (ce !== "message") {
10924: const chunk = encoder.encode(
10925: formatResponsesEvent(ce, cd),
10926: );
10927: if (
10928: contRecallIndices.size > 0 ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
11610:
11611: // Non-terminal, non-recall event: forward verbatim.
11612: const chunk = encoder.encode(formatResponsesEvent(event, data));
11613: if (recallIndices.size > 0 || unresolvedToolIndices.size > 0) {
11614: deferredBytes += chunk.byteLength;
11615: if (deferredBytes > maxDeferredBytes) {
11616: throw new SSEStreamLimitError(
11617: "recall stream exceeded deferred event limit",
11618: );
11619: }
11620: deferredEvents.push({ chunk });
11621: } else if (!(await enqueuePrincipal(chunk, otherToolSeen))) {
11622: break;
11623: }
11624: }
11625:
11626: principalFailureCategory = "principal_missing_terminal";
11627: throw new Error(
11628: ...
Found 1 matches /home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/stream/openai-responses.ts: Line 815: export function finalizeResponsesAcc(
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/stream/openai-responses.ts</path>
<type>file</type>
<content>
800: 0,
801: respUsage.input_tokens - cacheTokens,
802: );
803: }
804: }
805: }
806: break;
807: }
808:
809: // Other events (response.content_part.*,
810: // response.reasoning_summary_*, etc.) — ignored for accumulation
811: }
812: }
813:
814: /** Build the final GatewayResponse from accumulated state. */
815: export function finalizeResponsesAcc(
816: state: ResponsesAccState,
817: ): GatewayResponse {
818: const content: GatewayContentBlock[] = [];
819: const sortedIndices = Array.from(state.items.keys()).sort((a, b) => a - b);
820:
821: for (const index of sortedIndices) {
822: const item = state.items.get(index);
823: if (!item) continue;
824: if (item.type === "text") {
825: if (item.content) {
826: for (const part of ...
Found 46 matches
/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts:
Line 375: test.each(["failed", "cancelled"])(
Line 680: test("bounds retained output before recall detection", async () => {
Line 1137: test("rejects response.in_progress changing the created response identity", async () => {
Line 1546: test("rejects terminal output changing streamed identity", async () => {
Line 1862: test.each([
Line 1978: test("never forwards response-side item_reference lifecycle events", async () => {
Line 2022: test("privately accumulates a done-only sparse Codex item_reference", async () => {
Line 2066: test("keeps done-only continuation references private", async () => {
Line 2122: test.each([
Line 2216: test("fails closed when a continuation terminal references visible output", async () => {
Line 2278: test("fails closed when a continuation terminal changes a private ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
1800: },
1801: ],
1802: },
1803: }),
1804: ]),
1805: {
1806: onComplete: () => {},
1807: onRecall: async () => ({ anchorText: "", resultText: "" }),
1808: runFollowUp: async () => {
1809: throw new Error("should not run");
1810: },
1811: },
1812: );
1813:
1814: expect(await drain(client)).toContain("response.failed");
1815: });
1816:
1817: test("accepts terminal items that add optional status metadata", async () => {
1818: const doneItem = {
1819: type: "function_call",
1820: id: "fc_terminal_status",
1821: call_id: "call_terminal_status",
1822: name: "read",
1823: arguments: "{}",
1824: };
1825: const client = streamResponsesRecallAware(
1826: streamFrom([
1827: ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
2750: );
2751:
2752: const output = await drain(client);
2753: expect(output).not.toContain("response.failed");
2754: expect(output).not.toContain("item_reference");
2755: expect(operations.count).toBe(cardinality * 5);
2756: });
2757:
2758: test("rejects an item_reference missing output_item.done", async () => {
2759: const client = streamResponsesRecallAware(
2760: streamFrom([
2761: created("resp_reference_incomplete", "gpt-5.6-terra"),
2762: sseEvent("response.output_item.added", {
2763: output_index: 0,
2764: item: { type: "item_reference", id: "msg_reference_incomplete" },
2765: }),
2766: completed("resp_reference_incomplete"),
2767: ]),
2768: {
2769: onComplete: () => {},
2770: onRecall: async () => ({ ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
3380: const client = streamResponsesRecallAware(
3381: streamFrom([
3382: created("resp_terminal_failed_sparse_recall", "gpt-5.6-terra"),
3383: sseEvent("response.output_item.added", {
3384: output_index: 0,
3385: item: {
3386: type: "function_call",
3387: id: "fc_terminal_failed_sparse_recall",
3388: call_id: "",
3389: name: "",
3390: arguments: "",
3391: status: "in_progress",
3392: },
3393: }),
3394: sseEvent("response.function_call_arguments.delta", {
3395: output_index: 0,
3396: item_id: "fc_terminal_failed_sparse_recall",
3397: delta: privateArguments,
3398: }),
3399: sseEvent("response.completed", {
3400: response: {
3401: ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
4450: output_index: 0,
4451: item_id: "msg_part_initial_changed",
4452: content_index: 0,
4453: text: "safe",
4454: }),
4455: sseEvent("response.content_part.done", {
4456: output_index: 0,
4457: item_id: "msg_part_initial_changed",
4458: content_index: 0,
4459: part: { type: "output_text", text: "safe" },
4460: }),
4461: sseEvent("response.output_item.done", {
4462: output_index: 0,
4463: item: {
4464: type: "message",
4465: id: "msg_part_initial_changed",
4466: role: "assistant",
4467: content: [{ type: "output_text", text: "safe" }],
4468: },
4469: }),
4470: completed("resp_part_initial_changed"),
4471: ]),
4472: ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
4880: text: "safe",
4881: }),
4882: sseEvent("response.reasoning_summary_text.delta", {
4883: output_index: 0,
4884: item_id: "rs_late_delta",
4885: summary_index: 0,
4886: delta: "evil",
4887: }),
4888: sseEvent("response.output_item.done", {
4889: output_index: 0,
4890: item: {
4891: type: "reasoning",
4892: id: "rs_late_delta",
4893: summary: [{ type: "summary_text", text: "safe" }],
4894: },
4895: }),
4896: completed("resp_reasoning_late_delta"),
4897: ]),
4898: {
4899: onComplete: () => {},
4900: onRecall: async () => ({ anchorText: "", resultText: "" }),
4901: runFollowUp: async () => {
4902: throw new Error("should ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
5280: recallCall(0, { query: "companion" }),
5281: sseEvent("response.output_item.added", {
5282: output_index: 1,
5283: item: {
5284: type: "function_call",
5285: id: "fc_failed_companion",
5286: call_id: "call_failed_companion",
5287: name: "read",
5288: status: "in_progress",
5289: },
5290: }),
5291: sseEvent("response.function_call_arguments.done", {
5292: output_index: 1,
5293: item_id: "fc_failed_companion",
5294: arguments: companionArgs,
5295: }),
5296: sseEvent("response.output_item.done", {
5297: output_index: 1,
5298: item: {
5299: type: "function_call",
5300: id: "fc_failed_companion",
5301: ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
5670: const followUp = streamFrom([
5671: created("resp_terminal_metadata_followup", "gpt-5.6-terra"),
5672: textItem(0, "answer", "msg_terminal_metadata_followup"),
5673: sseEvent("response.incomplete", {
5674: response: {
5675: id: "resp_terminal_metadata_followup",
5676: model: "gpt-5.6-terra",
5677: status: "incomplete",
5678: incomplete_details: { reason: "content_filter" },
5679: output: [
5680: {
5681: type: "message",
5682: id: "msg_terminal_metadata_followup",
5683: role: "assistant",
5684: status: "completed",
5685: content: [
5686: {
5687: type: "output_text",
5688: text: "answer",
5689: ...
Found 2 matches
/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts:
Line 6706: item: { type: "item_reference", id: "ref_retry_baseline" },
Line 6710: item: { type: "item_reference", id: "ref_retry_baseline" },
Found 1 matches /home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/stream/openai-responses.ts: Line 1750: export function normalizeCodexResponsesEvent(
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/stream/openai-responses.ts</path>
<type>file</type>
<content>
1740: normalizeCodexDataEvent(state, event, parsed, maxSparseIndex);
1741: break;
1742: }
1743: }
1744:
1745: /**
1746: * Normalize one sparse Codex event and advance an independent normalization
1747: * state. Callers that also accumulate the event must use a separate state: the
1748: * Codex normalizer binds omitted indices and may seed done-only items.
1749: */
1750: export function normalizeCodexResponsesEvent(
1751: state: ResponsesAccState,
1752: event: string,
1753: parsed: Record<string, unknown>,
1754: maxSparseIndex = DEFAULT_MAX_SSE_FRAMES,
1755: ): void {
1756: validateCodexResponsesEvent(state, event, parsed, maxSparseIndex);
1757: if (
1758: (event === "response.function_call_arguments.delta" ||
1759: event === "response.function_call_arguments.done") &&
1760: ...
Found 7 matches
/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/stream/openai-responses.ts:
Line 615: case "response.output_item.added": {
Line 644: case "response.output_item.done": {
Line 995: case "response.output_item.added": {
Line 1044: case "response.output_item.done": {
Line 1625: function validateCodexResponsesEvent(
Line 1709: case "response.output_item.added":
Line 1710: case "response.output_item.done":
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/stream/openai-responses.ts</path>
<type>file</type>
<content>
1580:
1581: const existing = state.rawItems.get(outputIndex);
1582: if (event === "response.output_item.added" && existing) {
1583: malformedResponsesEvent();
1584: }
1585: if (event === "response.output_item.done" && existing) {
1586: if (
1587: existing.type !== item.type ||
1588: (isNonEmptyString(existing.id) &&
1589: isNonEmptyString(item.id) &&
1590: existing.id !== item.id)
1591: ) {
1592: malformedResponsesEvent();
1593: }
1594: } else if (event === "response.output_item.done") {
1595: const seedItem = { ...item };
1596: delete seedItem.content;
1597: applyResponsesEvent(state, "response.output_item.added", {
1598: output_index: outputIndex,
1599: item: seedItem,
1600: });
1601: }
1602: if (event === "response.output_item.done") {
1603: ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/stream/openai-responses.ts</path>
<type>file</type>
<content>
1430: ): void {
1431: const existing = state.rawItems.get(outputIndex);
1432: if (!existing) malformedResponsesEvent();
1433:
1434: const itemId = reconcileCodexIdentity(existing.id, item.id);
1435: if (itemId) bindCodexItemId(state, outputIndex, itemId);
1436: if (itemId || existing.id !== undefined || item.id !== undefined) {
1437: item.id = itemId;
1438: }
1439:
1440: if (item.type !== "function_call") return;
1441: const normalized = state.items.get(outputIndex);
1442: if (normalized?.type !== "tool_use") malformedResponsesEvent();
1443:
1444: const previousEffectiveIdentity = normalized.callId || normalized.id;
1445: normalized.callId = reconcileCodexIdentity(normalized.callId, item.call_id);
1446: if (normalized.callId) {
1447: bindResponsesIdentity(
1448: state,
1449: ...
Found 2 matches /home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/stream/openai-responses.ts: Line 1156: function codexItemKind( Line 1302: function validateCodexOutputItem(
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/stream/openai-responses.ts</path>
<type>file</type>
<content>
1130: }
1131:
1132: /** `public` enforces OpenAI's lifecycle; `codex` validates ChatGPT's sparse variant. */
1133: export type ResponsesValidationMode = "public" | "codex";
1134:
1135: function isRecord(value: unknown): value is Record<string, unknown> {
1136: return !!value && typeof value === "object" && !Array.isArray(value);
1137: }
1138:
1139: function malformedResponsesEvent(): never {
1140: throw new Error("malformed Responses stream event");
1141: }
1142:
1143: function isNonEmptyString(value: unknown): value is string {
1144: return typeof value === "string" && value.length > 0;
1145: }
1146:
1147: function reconcileCodexIdentity(earlier: unknown, final: unknown): string {
1148: const earlierValue = isNonEmptyString(earlier) ? earlier : "";
1149: const finalValue = isNonEmptyString(final) ? ...
Found 1 matches /home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/stream/openai-responses.ts: Line 244: export function isValidResponsesOutputItemStatus(
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/stream/openai-responses.ts</path>
<type>file</type>
<content>
210: apply_patch_call: {
211: added: IN_PROGRESS,
212: done: COMPLETED,
213: terminal: COMPLETED,
214: },
215: apply_patch_call_output: {
216: added: COMPLETED_OR_FAILED,
217: done: COMPLETED_OR_FAILED,
218: terminal: COMPLETED_OR_FAILED,
219: },
220: };
221: for (const type of [
222: "function_call_output",
223: "computer_call_output",
224: "computer_tool_call_output",
225: "local_shell_call_output",
226: "shell_call_output",
227: "custom_tool_call_output",
228: "program_output",
229: "tool_search_output",
230: ]) {
231: OUTPUT_ITEM_STATUSES_BY_TYPE[type] = {
232: added: COMPLETED,
233: done: COMPLETED,
234: terminal: COMPLETED,
235: };
236: }
237:
238: export function isSupportedResponsesOutputItemType(
239: type: unknown,
240: ): type is string {
241: return typeof type === ...
Found 13 matches
/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts:
Line 6899: const recallDiagnostics = createRecallDiagnostics(
Line 7216: recallDiagnostics.record(input, result, coverage);
Line 7406: recallDiagnostics.finish("completed");
Line 7480: recallDiagnostics.finish("failed");
Line 7519: recallDiagnostics.finish("failed");
Line 7657: recallDiagnostics.finish("completed");
Line 7671: recallDiagnostics.finish(streamSignal.aborted ? "aborted" : "failed");
Line 7719: recallDiagnostics.finish("aborted");
Line 7878: const recallDiagnostics = createRecallDiagnostics(!opts.noStore);
Line 9752: recallDiagnostics.finish(successful ? "completed" : "failed");
Line 9803: recallDiagnostics.record(input, result.resultText, result.coverage);
Line 10092: recallDiagnostics.finish("aborted");
Line 11900: ...
Found 8 matches
/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts:
Line 353: import { createRecallDiagnostics } from "./recall-diagnostics";
Line 6899: const recallDiagnostics = createRecallDiagnostics(
Line 7878: const recallDiagnostics = createRecallDiagnostics(!opts.noStore);
Line 18260: const bufferedRecallDiagnostics = createRecallDiagnostics(
/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/recall-diagnostics.ts:
Line 8: export function createRecallDiagnostics(enabled = true) {
/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/recall-diagnostics.test.ts:
Line 4: createRecallDiagnostics,
Line 12: const diagnostics = createRecallDiagnostics();
Line 51: const diagnostics = createRecallDiagnostics(enabled);
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/recall-diagnostics.ts</path>
<type>file</type>
<content>
1: import { createHash } from "node:crypto";
2: import { log, type RecallCoverage } from "@loreai/core";
3:
4: /** Keep request-local diagnostic state bounded while observing chains beyond ten rounds. */
5: export const MAX_RECALL_DIAGNOSTIC_ROUNDS = 64;
6:
7: /** Request-local comparisons only. Fingerprints and recall content never leave this closure. */
8: export function createRecallDiagnostics(enabled = true) {
9: const inputs = new Set<string>();
10: const results = new Set<string>();
11: const pairs = new Set<string>();
12: const coverage = new Set<string>();
13: const started = performance.now();
14: let finished = false;
15: let rounds = 0;
16: let detailCalls = 0;
17: let emptyBodies = 0;
18: let resultBytes = 0;
19: const fingerprint = (value: string) =>
20: createHash("sha256").update(value).digest("hex");
21: ...
Found 15 matches
/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts:
Line 8106: let retainedStateBytes = 0;
Line 10230: const retainedStateBaseline = retainedStateBytes;
Line 10336: retainedStateBytes += encoder.encode(data).byteLength;
Line 10337: if (retainedStateBytes > maxRetainedStateBytes) {
Line 10362: retainedStateBytes += encoder.encode(data).byteLength;
Line 10363: if (retainedStateBytes > maxRetainedStateBytes) {
Line 10777: retainedStateBytes,
Line 10967: retainedStateBytes += encoder.encode(cd).byteLength;
Line 10968: if (retainedStateBytes > maxRetainedStateBytes) {
Line 10982: retainedStateBytes += encoder.encode(cd).byteLength;
Line 10983: if (retainedStateBytes > maxRetainedStateBytes) {
Line 11264: ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
3980: created("resp_added_only_message", "gpt-5.6-terra"),
3981: sseEvent("response.output_item.added", {
3982: item: {
3983: type: "message",
3984: id: "msg_added_only_message",
3985: role: "assistant",
3986: },
3987: }),
3988: completed("resp_added_only_message"),
3989: ]),
3990: {
3991: validation: "codex",
3992: onComplete: () => {},
3993: onRecall: async () => ({ anchorText: "", resultText: "" }),
3994: runFollowUp: async () => {
3995: throw new Error("should not run");
3996: },
3997: },
3998: );
3999:
4000: expect(await drain(client)).not.toContain("response.failed");
4001: });
4002:
4003: test("public mode still rejects an incomplete added-only message ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
4640: item_id: "msg_part_prefix",
4641: content_index: 0,
4642: part: { type: "output_text", text: "pre" },
4643: }),
4644: sseEvent("response.output_text.delta", {
4645: output_index: 0,
4646: item_id: "msg_part_prefix",
4647: content_index: 0,
4648: delta: "fix",
4649: }),
4650: sseEvent("response.output_text.done", {
4651: output_index: 0,
4652: item_id: "msg_part_prefix",
4653: content_index: 0,
4654: text: "prefix",
4655: }),
4656: sseEvent("response.content_part.done", {
4657: output_index: 0,
4658: item_id: "msg_part_prefix",
4659: content_index: 0,
4660: part: { type: "output_text", text: "prefix" },
4661: }),
4662: ...
Found 57 matches
/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts:
Line 1792: type: "item_reference",
Line 1978: test("never forwards response-side item_reference lifecycle events", async () => {
Line 1986: type: "item_reference",
Line 1993: type: "item_reference",
Line 2002: output: [{ type: "item_reference", id: "msg_server_only" }],
Line 2017: expect(out).not.toContain("item_reference");
Line 2019: expect(JSON.stringify(completedResponse)).not.toContain("item_reference");
Line 2022: test("privately accumulates a done-only sparse Codex item_reference", async () => {
Line 2033: item: { type: "item_reference", id: privateIdentity },
Line 2040: output: [{ type: "item_reference", id: privateIdentity }],
Line 2058: expect(output).not.toContain("item_reference");
Line 2073: item: { type: ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
1740: name: "read",
1741: }),
1742: );
1743: expect(completedResponse?.rawOutputItems).toContainEqual(
1744: expect.objectContaining({
1745: id: "fc_terminal_name",
1746: call_id: "call_terminal_name",
1747: name: "read",
1748: }),
1749: );
1750: expect(recallCalls).toBe(0);
1751: });
1752:
1753: test("rejects malformed terminal output items", async () => {
1754: const client = streamResponsesRecallAware(
1755: streamFrom([
1756: created("resp_terminal_malformed", "gpt-5.6-terra"),
1757: textItem(0, "answer", "msg_terminal_malformed"),
1758: sseEvent("response.completed", {
1759: response: {
1760: id: "resp_terminal_malformed",
1761: model: "gpt-5.6-terra",
1762: status: ...
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
6620: maxRetainedStateBytes: 1024 * 1024,
6621: onComplete: () => {},
6622: onRecall: async ({ query }) => ({
6623: anchorText: buildAnchor(query),
6624: resultText: "results",
6625: }),
6626: runFollowUp: async () => ({
6627: reader: (followUps++ === 0
6628: ? firstFollowUp
6629: : secondFollowUp
6630: ).body!.getReader(),
6631: }),
6632: },
6633: );
6634:
6635: const out = await drain(client);
6636: expect(out).toContain(PUBLIC_RECALL_ERROR);
6637: expect(out).not.toContain(firstEvent);
6638: expect(out).not.toContain(secondEvent);
6639: expect(failures).toEqual(["resource_limit"]);
6640: });
6641:
6642: test("does not double-charge transactional output when retrying a ...
Found 30 matches /home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts: Line 252: DEFAULT_MAX_SSE_FRAMES, Line 950: maxStreamingPostResponses = DEFAULT_MAX_STREAMING_POST_RESPONSES; Line 952: DEFAULT_MAX_STREAMING_POST_RESPONSES_PER_SESSION; Line 1037: const DEFAULT_MAX_STREAMING_POST_RESPONSES = 64; Line 1040: const DEFAULT_MAX_STREAMING_POST_RESPONSES_PER_SESSION = 2; Line 1060: let maxStreamingPostResponses = DEFAULT_MAX_STREAMING_POST_RESPONSES; Line 1062: DEFAULT_MAX_STREAMING_POST_RESPONSES_PER_SESSION; Line 1072: globalLimit ?? DEFAULT_MAX_STREAMING_POST_RESPONSES; Line 1074: perSessionLimit ?? ...
fix/responses-private-references (conflicted): - umutrurq/16 ec1eea0a (hidden) fix(responses): keep item references private - umutrurq/20 d4cb310b (hidden) fix(responses): keep item references private + umutrurq/0 079844c0 (divergent) (conflict) fix(responses): keep item references private + umutrurq/1 099729a2 (divergent) (conflict) fix(responses): keep item references private + umutrurq/2 cda3d347 (divergent) (conflict) fix(responses): keep item references private @git (ahead by 2 commits, behind by 3 commits): umutrurq/19 5c2a0221 (hidden) (conflict) fix(responses): keep item references private fix/responses-private-references-v2: wywumkpt 8063355c fix(responses): keep item references private Hint: Some bookmarks have conflicts. Use `jj bookmark set <name> -r <rev>` to resolve.
Found 2 matches
/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts:
Line 7794: export function streamResponsesRecallAware(
Line 18803: streamResponsesRecallAware(upstreamResponse, {
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
18760: async function captureUnsuccessfulResponses(
18761: operation: Promise<GatewayResponse>,
18762: ): Promise<{ response: GatewayResponse; successful: boolean } | undefined> {
18763: try {
18764: return { response: await operation, successful: true };
18765: } catch (error) {
18766: if (!(error instanceof ResponsesTerminalError)) throw error;
18767: finishUnsuccessfulStreaming(error.response);
18768: return error.status === "incomplete"
18769: ? { response: error.response, successful: false }
18770: : undefined;
18771: }
18772: }
18773:
18774: if (req.stream && upstreamResponse.body) {
18775: // Non-Anthropic upstream streaming responses need their own accumulator
18776: // since the Anthropic SSE accumulator can't parse OpenAI SSE formats. ...
Found 1 matches
/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts:
Line 18727: function finishUnsuccessfulStreaming(resp: GatewayResponse): void {
<path>/home/byk/Code/opencode-lore-responses-reference-v2/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
18680: sessionState.sessionID,
18681: sessionState.resolvedConversationTTL,
18682: genAiSpan,
18683: endGenAiSpan,
18684: () => {
18685: sessionState._dirty = true;
18686: },
18687: );
18688: return;
18689: }
18690: try {
18691: const postResponseFailed = new Error(
18692: "Responses recall post-response persistence failed",
18693: );
18694: try {
18695: withTenant(sessionState.storageTenantId ?? ...
The working copy has no changes. Working copy (@) : zkttmwun f6ecd07d (empty) fix(responses): close reference lifecycle gaps Parent commit (@-): wywumkpt 8063355c fix/responses-private-references-v2 | fix(responses): keep item references private Warning: These bookmarks have conflicts: fix/responses-private-references Hint: Use `jj bookmark list` to see details. Use `jj bookmark set <name> -r <rev>` to resolve. zkttmwuntxzm f6ecd07d98c3c92597d98c739a6903364dd99574 parents=8063355cb32832bd8fac492bcbba7da22ae1976c conflict=false fix(responses): close reference lifecycle gaps wywumkptssoy 8063355cb32832bd8fac492bcbba7da22ae1976c parents=2cbf40060c67df229731cf1b9e34d5bf22ec2145 conflict=false fix(responses): keep item references private pxrvwsvvkmpo 2cbf40060c67df229731cf1b9e34d5bf22ec2145 parents=e977b4b1da8f8197c3238466d41de0bccd8eb054 conflict=false feat(cch): add seeds for Claude Code up to 2.1.272 (#1780)
M packages/gateway/src/pipeline.ts M packages/gateway/test/openai-responses-recall-aware-stream.test.ts diff-sha256 007a15b7fd1bcf9b346d89911b2353098b6fec408c12d3b6fcc24a498a37a356 - 26e5e6b70512a2de326eebfb59d6d8f6b4198b098f4f560f353b3f26715b99e4 packages/gateway/src/pipeline.ts 5a5779ba10143315579dec688fe5e80a233da0972c96445b68dd33219672ad51 packages/gateway/test/openai-responses-recall-aware-stream.test.ts
5549ec1eb7a8 2026-09-16 20:30:13 snapshot working copy 8dd01c2b4c28 2026-09-16 20:26:19 describe commit b30b51fc2df58ae55a58170c315057892a5f05c5 3a8fd8768af3 2026-09-16 20:22:44 snapshot working copy 32809aeaf17b 2026-09-16 20:17:40 snapshot working copy 5ca1ee7bc249 2026-09-16 20:12:30 describe commit 913435b13aa2368c45385dc2d17efb018a63c6f9 c4595376b339 2026-09-16 20:11:34 create initial working-copy commit in workspace responses-projection-sanitize
PASS — candidate range remained exact
2cbf40060c67df229731cf1b9e34d5bf22ec2145wywumkptssoy, commit 8063355cb32832bd8fac492bcbba7da22ae1976cconflict=false; the candidate range contains no conflicted commit.packages/gateway/src/pipeline.tspackages/gateway/test/openai-responses-recall-aware-stream.test.tsjj diff SHA-256 matched the expected hash:
007a15b7fd1bcf9b346d89911b2353098b6fec408c12d3b6fcc24a498a37a356MUST-FIX — frozen workspace identity changed during review
The empty working-copy child changed from b30b51fc... with no description to f6ecd07d... with description fix(responses): close reference lifecycle gaps. The operation log records describe commit b30b51fc... at 20:26:19. The reviewed base, head, files, and diff hash stayed unchanged, but the workspace did not remain immutable. There is also an unrelated conflicted bookmark, fix/responses-private-references; the reviewed fix/responses-private-references-v2 bookmark remains clean.
assertTerminalOutputMatches() accepts a terminal item_reference that points to a completed private recall at packages/gateway/src/pipeline.ts:9462-9510, but it never records that the response used reference shorthand.
The first continuation preflight checks only explicit lifecycle references at packages/gateway/src/pipeline.ts:10651-10656. Nested continuation preflight checks only identities registered by explicit lifecycle events at packages/gateway/src/pipeline.ts:11316-11335.
Exploit:
maxSSEFrames=32.output_index=31.{type:"item_reference", id:<recall-id>}.