Dashboard › opencode-lore › Session 1egSQWP0Mgfe
1egSQWP0MgfeTJ1PTPerform an independent read-only security/privacy/pentest review of immutable accumulation candidate in /home/byk/Code/opencode-lore-responses-accumulation. Base main@origin exact commit 2cbf40060c67df229731cf1b9e34d5bf22ec2145. Candidate stable change tklkqxytmpkzzryqlolnpvxouropxznp, exact head ce88c614c0ae55d229cb605aa7c7369d918d3650. Expected plain jj diff --from main@origin --to tklkqxyt SHA-256 02d06b2f84d7d2d8cfa5f22443384d12a2a9bc922ade879449de9b0b9d971d1c. Exactly 3 changed files. Do not edit, format, install, mutate VCS, use network/server, or access production DB. Read AGENTS.md, quality/REVIEW.md, current scripts, every changed line and relevant parser/state/output/log/callback/persistence/cancellation paths/tests. Verify identity/status/conflicts/scope/hash start/end. Attack terminal-only/gapped/malformed reasoning arrays, absent/empty Codex terminal output, sparse/high coordinates, shifted continuation coordinates, huge item counts, limit crossings, retries, cancellation, backpressure, recall/nested recall side effects, callback/log/telemetry leakage, failed output projection, and rollback/accounting exact-once. Ensure accepted events accumulate privately before local limits but arbitrary event fields never reach callbacks/output; malformed reasoning never reaches recall; public failures stay fixed and empty. Evaluate tests/mutations and complexity bounds. Exhaustive validation already passed 4 shards: 469 files, 10,345 tests, 230 skipped; do not rerun exhaustive. Report PASS/CONCERN/MUST-FIX with exact current file:line evidence and residual risks; end exactly MERGE or DO-NOT-MERGE. If model recall warns, preserve the session and run local lore recall '<specific query>' rather than return warning/empty output.
<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`. ...
The working copy has no changes. Working copy (@) : lrqlyykx d890b184 (empty) (no description set) Parent commit (@-): tklkqxyt ce88c614 fix/responses-accumulation-order | fix(responses): complete lifecycle reconciliation 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. lrqlyykxvwoqrxzowonmmytxulyqmqlu d890b184d786a4348e30bcdac7412baa7ae01ae9 parents=ce88c614c0ae55d229cb605aa7c7369d918d3650 conflict=false empty=true description= tklkqxytmpkzzryqlolnpvxouropxznp ce88c614c0ae55d229cb605aa7c7369d918d3650 parents=683dff02101f15198b18e3088a0b57dade290056 conflict=false empty=false description=fix(responses): complete lifecycle reconciliation pxrvwsvvkmpoxnsqmrkwrnlqvvkoltwz 2cbf40060c67df229731cf1b9e34d5bf22ec2145 parents=e977b4b1da8f8197c3238466d41de0bccd8eb054 conflict=false empty=false description=feat(cch): add seeds for Claude Code up to 2.1.272 (#1780) M ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/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-accumulation/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. ...
...output truncated... Full output saved to: /home/byk/.local/share/opencode/tool-output/tool_0aa88eba3001YhC6jngkAgfRv9 + const materializedItem = finalizeSpy.mock.calls + .map(([acc]) => acc.rawItems.get(0)) + .find((item) => item?.id === scenario.itemId); + const materializedParts = materializedItem?.[ + scenario.expectedField + ] as unknown[]; + expect(materializedParts).toHaveLength(scenario.partIndex + 1); + expect(Object.keys(materializedParts)).toEqual([ + String(scenario.partIndex), + ]); + expect(materializedParts[scenario.partIndex]).toEqual( + scenario.expectedPart, + ); + expect( + Object.keys(materializedParts[scenario.partIndex] as object), + ).toEqual(["type", "text"]); + expect(completedResponse?.content).toEqual([]); + expect(completedResponse?.rawOutputItems).toEqual([]); + expect(out.match(/^event: response\.failed$/gm)).toHaveLength(1); + ...
Found 100 matches (more matches available) /home/byk/.local/share/opencode/tool-output/tool_0aa892d6e001OD0qCRNCQLvMCT: Line 12: diff --git a/packages/gateway/src/pipeline.ts b/packages/gateway/src/pipeline.ts Line 16: @@ -7971,14 +7971,75 @@ Line 100: @@ -8052,7 +8113,8 @@ Line 110: @@ -8321,6 +8383,43 @@ Line 154: @@ -8949,22 +9048,8 @@ Line 179: @@ -9006,6 +9091,13 @@ Line 193: @@ -9062,6 +9154,13 @@ Line 207: @@ -9301,6 +9400,20 @@ Line 228: @@ -9345,6 +9458,7 @@ Line 236: @@ -9405,7 +9519,14 @@ Line 252: @@ -9414,31 +9535,35 @@ Line 295: @@ -9614,8 +9739,11 @@ Line 308: @@ -9919,6 +10047,96 @@ Line 405: @@ -10023,6 +10241,7 @@ Line 413: @@ -10149,6 +10368,7 @@ Line 421: @@ -10185,13 +10405,16 @@ Line 444: @@ -10232,24 +10455,29 @@ Line 487: @@ -10698,12 +10926,27 @@ Line 520: @@ -10755,6 +10998,7 @@ Line 528: @@ -10782,13 +11026,16 @@ Line 551: @@ -10828,24 +11075,30 @@ Line 593: @@ -11042,6 +11295,36 @@ Line ...
<path>/home/byk/.local/share/opencode/tool-output/tool_0aa88eba3001YhC6jngkAgfRv9</path>
<type>file</type>
<content>
1: diff --git a/packages/gateway/src/pipeline.ts b/packages/gateway/src/pipeline.ts
2: index 004e03b3e2..635477d648 100644
3: --- a/packages/gateway/src/pipeline.ts
4: +++ b/packages/gateway/src/pipeline.ts
5: @@ -7971,14 +7971,75 @@
6: const finalizedMessageContent = (
7: lifecycle: OutputLifecycle,
8: ): Array<Record<string, unknown>> =>
9: - Array.from(lifecycle.content)
10: - .sort(([left], [right]) => left - right)
11: - .filter(([, part]) => part.valueDone || part.partDone)
12: - .map(([, part]) =>
13: - part.kind === "refusal"
14: - ? { type: "refusal", refusal: part.authoritativeValue }
15: - : { type: "output_text", text: part.authoritativeValue },
16: - );
17: + Array.from(lifecycle.content).reduce<Array<Record<string, unknown>>>(
18: + (content, [contentIndex, part]) => {
19: + if ...
<path>/home/byk/.local/share/opencode/tool-output/tool_0aa88eba3001YhC6jngkAgfRv9</path>
<type>file</type>
<content>
381: + const normalized = acc.items.get(outputIndex);
382: + if (normalized?.type === "text") {
383: + normalized.content = content.filter(
384: + (part): part is Record<string, unknown> => part !== undefined,
385: + );
386: + }
387: + }
388: + acc.rawItems.set(outputIndex, preserved);
389: + };
390: +
391: let resumeDemand: (() => void) | undefined;
392: const cleanupAbort = (): void =>
393: signal.removeEventListener("abort", onStreamAbort);
394: @@ -10023,6 +10241,7 @@
395: | undefined;
396: let continuationFailureReported = false;
397: let recallDetected = false;
398: + let resourceLimitedContinuationResponse: GatewayResponse | undefined;
399: type PrincipalFailureCategory =
400: | "principal_transport"
401: | "principal_resource_limit"
402: @@ ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts:
Line 205: applyResponsesEvent,
Line 206: finalizeResponsesAcc,
Line 208: makeResponsesAccState,
Line 217: type ResponsesAccState,
Line 252: DEFAULT_MAX_SSE_FRAMES,
Line 361: RecallContinuationFailure,
Line 362: reportRecallContinuationFailure,
Line 363: type RecallContinuationFailureCategory,
Line 6827: onComplete: (response: GatewayResponse) => void,
Line 6841: onTransactionReady?: (transaction: {
Line 6893: if (recallPersistence) recallContext?.onTransactionReady?.(recallPersistence);
Line 6896: onComplete(response);
Line 7043: maxFrames: DEFAULT_MAX_SSE_FRAMES,
Line 7188: throw new RecallContinuationFailure("parallel_recall");
Line 7195: throw new RecallContinuationFailure("depth_exhausted");
Line 7462: throw new ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
120: SessionState,
121: UpstreamSnapshot,
122: WarmupState,
123: } from "./translate/types";
124: import {
125: applyUpstreamExtraHeaders,
126: buildUpstreamSnapshotHeaders,
127: blocksToText,
128: isEmptyCompletion,
129: looksLikeSSE,
130: providerRoutingValue,
131: requestTargetsOpenRouter,
132: ZERO_USAGE,
133: } from "./translate/types";
134: import type { GatewayConfig } from "./config";
135: import {
136: getProjectPath,
137: extractGitRemoteHeader,
138: resolveUpstreamRoute,
139: extractUpstreamUrlHeader,
140: extractUpstreamPathHeader,
141: verbatimUpstreamUrl,
142: extractProviderHeader,
143: hasCopilotIntegrationHeader,
144: resolveProviderRoute,
145: extraHeadersForUpstream,
146: upstreamUrlForLog,
147: isUpstreamWithinBase,
148: isCallerUpstreamAllowed,
149: normalizeUpstreamBase,
150: ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/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: ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/package.json</path>
<type>file</type>
<content>
1: {
2: "name": "@loreai/gateway",
3: "version": "0.40.0",
4: "type": "module",
5: "license": "FSL-1.1-Apache-2.0",
6: "description": "Lore as a transparent LLM proxy — context management for any AI coding client",
7: "main": "./dist/index.cjs",
8: "types": "./dist/index.d.cts",
9: "exports": {
10: ".": {
11: "types": "./dist/index.d.cts",
12: "bun": "./dist/index.bun.js",
13: "require": "./dist/index.cjs",
14: "default": "./dist/index.cjs"
15: }
16: },
17: "bin": {
18: "lore": "./dist/bin.cjs",
19: "lore-gateway": "./dist/bin.cjs"
20: },
21: "scripts": {
22: "typecheck": "tsc --noEmit",
23: "build": "tsx script/build.ts",
24: "bundle": "tsx script/bundle.ts",
25: "build:binary": "tsx script/build.ts --binary",
26: "build:binary:sea": "tsx script/build-binary-sea.ts",
27: ...
/home/byk/Code/opencode-lore-responses-accumulation/stryker.config.mjs
<path>/home/byk/Code/opencode-lore-responses-accumulation/stryker.config.mjs</path> <type>file</type> <content> 1: // Mutation testing — issue #832. 2: // 3: // Measures whether our tests CONSTRAIN behavior (not merely pass) on the 4: // high-risk STATEFUL modules where review — not tests — caught the recent bugs 5: // (sync prune-floor wedge #828, tier residue #828, decay/evict edge cases #816). 6: // A surviving mutant = a line the suite does not pin (sometimes an equivalent 7: // mutant). ALWAYS hand-verify a survivor by applying the EXACT replacement from 8: // the report — Stryker splits compound `A && B` conditions, so a `:col → "true"` 9: // mutant may be a sub-operand, not the whole condition. See 10: // quality/MUTATION_TESTING.md. 11: // 12: // Run nightly / on-demand; NOT per-PR (slow). No hard gate while we establish a 13: // baseline: `thresholds.break` is null, so the run never fails CI — we record 14: // the score and ratchet over time. ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path> <type>file</type> <content> 7760: }, 7761: streamSignal, 7762: recallPersistence.rollback, 7763: ); 7764: } 7765: 7766: /** 7767: * True-streaming, recall-aware variant of `streamResponsesPassthrough` for the 7768: * OpenAI Responses API (codex/ChatGPT) — used when the request carries the 7769: * gateway-injected `recall` tool but the client speaks the Responses API. 7770: * 7771: * Unlike the buffered `accumulateResponsesSSEStream` path (which withholds ALL 7772: * client bytes until the entire slow reasoning-heavy upstream completes — the 7773: * cause of opencode's 10s `ProviderHeaderTimeoutError`), this function forwards 7774: * every upstream SSE event to the client AS IT ARRIVES, while transparently 7775: * intercepting a `recall` `function_call` output item: 7776: * 7777: * - **No recall**: forwards everything unchanged (identical to 7778: * ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
8710: }
8711: if (
8712: event.startsWith("response.output_text") ||
8713: event.startsWith("response.content_part") ||
8714: event.startsWith("response.reasoning_text") ||
8715: event.startsWith("response.refusal")
8716: ) {
8717: const contentIndex = parsed.content_index as number;
8718: const expectedKind = event.startsWith("response.output_text")
8719: ? "output_text"
8720: : event.startsWith("response.refusal")
8721: ? "refusal"
8722: : event.startsWith("response.reasoning_text")
8723: ? "reasoning_text"
8724: : undefined;
8725: const part = parsed.part as Record<string, unknown> | undefined;
8726: const partKind =
8727: event.startsWith("response.content_part") &&
8728: typeof ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
9680: syntheticIdentities.has(syntheticId) ||
9681: referenceIdentities.has(syntheticId) ||
9682: outputIdentities.has(syntheticId) ||
9683: states.some(
9684: (acc) =>
9685: [...acc.items.values()].some(
9686: (item) =>
9687: item.id === syntheticId ||
9688: (item.type === "tool_use" && item.callId === syntheticId),
9689: ) ||
9690: [...acc.rawItems.values()].some(
9691: (item) => item.id === syntheticId || item.call_id === syntheticId,
9692: ),
9693: )
9694: ) {
9695: throw new Error("duplicate synthetic Responses item identity");
9696: }
9697: syntheticIdentities.add(syntheticId);
9698: };
9699:
9700: // --- Keepalive (same as streamResponsesPassthrough) ---
9701: const KEEPALIVE_INACTIVITY_MS = ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
10660: encoder.encode(
10661: formatResponsesEvent(
10662: event,
10663: terminalParsed === parsed
10664: ? data
10665: : JSON.stringify(terminalParsed),
10666: ),
10667: ),
10668: otherToolSeen,
10669: () => {
10670: terminalDelivered = true;
10671: finish(
10672: finalResponse,
10673: state.terminalEvent === "response.completed",
10674: );
10675: },
10676: ))
10677: )
10678: break;
10679: cancelAndReleaseReader(reader, signal.reason);
10680: ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
11660: encoder.encode(buildTerminal(visibleResp)),
11661: () => {
11662: terminalDelivered = true;
11663: const successful =
11664: state.terminalEvent === "response.completed";
11665: let transactionSettled = false;
11666: const transaction = {
11667: commit: () => {
11668: if (transactionSettled) return;
11669: try {
11670: for (const commit of pendingCommits) commit();
11671: transactionSettled = true;
11672: pendingCommits.length = 0;
11673: transactionRollbacks.length = 0;
11674: transactionBaseline = undefined;
11675: ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/stream/openai-responses.ts</path> <type>file</type> <content> 1: /** 2: * OpenAI Responses API SSE stream accumulator. 3: * 4: * Parses upstream Responses API streaming events and accumulates the full 5: * response into a `GatewayResponse`. The Responses API uses a different 6: * SSE event lifecycle than Anthropic: 7: * 8: * response.created → response.in_progress → 9: * response.output_item.added → response.output_text.delta (repeated) → 10: * response.output_item.done → response.function_call_arguments.delta → 11: * response.function_call_arguments.done → 12: * response.completed 13: * 14: * Reuses `parseSSEStream` from the Anthropic stream module since the 15: * underlying SSE wire format is the same. ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/stream/openai-responses.ts</path> <type>file</type> <content> 1051: !validOutputIndex || 1052: !doneItem || 1053: typeof doneItem !== "object" || 1054: Array.isArray(doneItem) || 1055: typeof doneItem.type !== "string" || 1056: !isSupportedResponsesOutputItemType(doneItem.type) || 1057: !isValidResponsesReasoningEncryptedContent(doneItem) || 1058: (doneItem.id !== undefined && typeof doneItem.id !== "string") || 1059: !isValidResponsesOutputItemStatus( 1060: doneItem.type, 1061: doneItem.status, 1062: "done", 1063: ) || 1064: (doneItem.type === "message" && typeof doneItem.id !== "string") || 1065: (doneItem.type === "message" && 1066: doneItem.status !== undefined && 1067: doneItem.status !== "completed" && 1068: doneItem.status !== "incomplete") ...
<path>/home/byk/.local/share/opencode/tool-output/tool_0aa88eba3001YhC6jngkAgfRv9</path>
<type>file</type>
<content>
760: diff --git a/packages/gateway/test/openai-responses-recall-aware-stream.test.ts b/packages/gateway/test/openai-responses-recall-aware-stream.test.ts
761: index dca2a57d78..026c9abab9 100644
762: --- a/packages/gateway/test/openai-responses-recall-aware-stream.test.ts
763: +++ b/packages/gateway/test/openai-responses-recall-aware-stream.test.ts
764: @@ -11,7 +11,7 @@
765: * `response.completed`).
766: */
767: import { log } from "@loreai/core";
768: -import { afterEach, describe, test, expect } from "vitest";
769: +import { afterEach, describe, test, expect, vi } from "vitest";
770: import { streamResponsesRecallAware } from "../src/pipeline";
771: import {
772: setRecallContinuationFailureHook,
773: @@ -31,6 +31,7 @@
774: };
775:
776: afterEach(() => {
777: + vi.restoreAllMocks();
778: setRecallContinuationFailureHook(undefined);
779: ...
<path>/home/byk/.local/share/opencode/tool-output/tool_0aa88eba3001YhC6jngkAgfRv9</path>
<type>file</type>
<content>
1430: + streamFrom([
1431: + created("resp_sparse_omitted_content", "gpt-5.6-terra"),
1432: + sseEvent("response.output_item.added", {
1433: + output_index: 0,
1434: + item: {
1435: + type: "message",
1436: + id: "msg_sparse_omitted_content",
1437: + role: "assistant",
1438: + },
1439: + }),
1440: + sseEvent("response.content_part.added", {
1441: + output_index: 0,
1442: + item_id: "msg_sparse_omitted_content",
1443: + content_index: 2,
1444: + part: { type: "output_text", text: "sparse finalized text" },
1445: + }),
1446: + sseEvent("response.output_text.done", {
1447: + output_index: 0,
1448: + item_id: "msg_sparse_omitted_content",
1449: + content_index: 2,
1450: + text: "sparse finalized ...
<path>/home/byk/.local/share/opencode/tool-output/tool_0aa88eba3001YhC6jngkAgfRv9</path>
<type>file</type>
<content>
1870: + created("resp_retained_continuation", "gpt-5.6-terra"),
1871: + recallCall(0, { query: "retained continuation" }),
1872: + completed("resp_retained_continuation"),
1873: + ];
1874: + const added = sseEvent("response.output_item.added", {
1875: + output_index: 0,
1876: + item: {
1877: + type: "message",
1878: + id: "msg_retained_continuation_trigger",
1879: + role: "assistant",
1880: + },
1881: + });
1882: + const retainedBeforeTrigger =
1883: + indexedSSEDataBytes(principal.join("")) + sseDataBytes(added);
1884: + const maxRetainedStateBytes = retainedBeforeTrigger * 32;
1885: + const triggerText =
1886: + "private continuation retained-state trigger " +
1887: + "x".repeat(maxRetainedStateBytes);
1888: + const followUp = streamFrom([
1889: + ...
Found 4 matches /home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/stream/anthropic.ts: Line 58: export const DEFAULT_MAX_SSE_FRAMES = 100_000; Line 150: export async function* parseSSEStream( Line 175: const maxFrames = opts.maxFrames ?? DEFAULT_MAX_SSE_FRAMES; Line 1993: ? (opts.maxFrames ?? DEFAULT_MAX_SSE_FRAMES)
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/stream/anthropic.ts</path>
<type>file</type>
<content>
40: /** Format a single named SSE event for sending to the client. */
41: export function formatSSEEvent(eventType: string, data: string): string {
42: return `event: ${eventType}\ndata: ${data}\n\n`;
43: }
44:
45: // ---------------------------------------------------------------------------
46: // SSE parsing
47: // ---------------------------------------------------------------------------
48:
49: type StreamChunkRead = Awaited<
50: ReturnType<ReadableStreamDefaultReader<Uint8Array>["read"]>
51: >;
52:
53: /**
54: * Foreground and worker SSE streams share this finite frame ceiling. The byte
55: * ceilings bound retained data, while this independently bounds parser work for
56: * tiny frames (including blank and comment-only frames). ...
Found 6 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/core/src/log.ts:
Line 13: * An optional {@link LogSink} can be registered via {@link registerSink}.
Line 51: error(message: string, attrs?: Record<string, unknown>): void;
Line 66: export function registerSink(s: LogSink): void {
Line 218: function sanitizedError(error: Error): Error {
Line 497: export function error(...args: unknown[]): void {
Line 504: if (err) sink?.captureException(sanitizedError(err));
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/core/src/log.ts</path>
<type>file</type>
<content>
1: /**
2: * Lightweight logger that suppresses informational messages by default.
3: *
4: * In TUI mode, all stderr output renders as red "error" text — confusing
5: * for routine status messages like "incremental distillation" or "pruned
6: * temporal messages". Only actual errors should be visible by default.
7: *
8: * Set LORE_DEBUG=1 to see informational messages (useful when debugging
9: * the plugin itself).
10: *
11: * ## Sink registration
12: *
13: * An optional {@link LogSink} can be registered via {@link registerSink}.
14: * When registered, every log call (regardless of `isDebug`) also forwards
15: * to the sink. This is used by the gateway to bridge logs → Sentry without
16: * adding a Sentry dependency to `@loreai/core`. ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/core/src/log.ts</path>
<type>file</type>
<content>
190: .replace(
191: new RegExp(
192: String.raw`(^|[\r\n])([\t ]*(?:${LOG_SENSITIVE_KEY})[\t ]*:[\t ]*)[^\r\n]*`,
193: "gi",
194: ),
195: `$1$2${LOG_FILTERED}`,
196: )
197: .replace(/\bsk-[A-Za-z0-9_-]{12,}\b/g, LOG_FILTERED)
198: .replace(/\bgh[pousr]_[A-Za-z0-9]{20,}\b/g, LOG_FILTERED)
199: .replace(/\bAKIA[A-Z0-9]{16}\b/g, LOG_FILTERED)
200: .replace(
201: /\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g,
202: LOG_FILTERED,
203: );
204: }
205:
206: function safeArgs(args: unknown[]): string[] {
207: return args.map((arg) =>
208: redactSensitiveLogText(
209: typeof arg === "string"
210: ? arg
211: : arg instanceof Error
212: ? (arg.stack ?? arg.message)
213: : String(arg),
214: ),
215: );
216: }
217:
218: function ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/worker-copilot-responses.test.ts:
Line 289: test("provider-declared incomplete response is a typed failure even with text", async () => {
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/provider-usage-headers.test.ts:
Line 240: new Response("private upstream diagnostic", {
Line 254: if (!meta) expect(body).not.toContain("private upstream diagnostic");
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openrouter-provider-routing.test.ts:
Line 1141: expect(await oversized.text()).toContain("Gateway request failed");
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-stream.test.ts:
Line 4030: expect(output).not.toContain("event: response.failed");
Line 4042: expect(output).toContain("event: response.failed");
Line 4073: ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
430: status: "completed",
431: content: [{ type: "output_text", text }],
432: },
433: });
434:
435: describe("streamResponsesRecallAware", () => {
436: test("forwards events live with NO recall — no header hold-back", async () => {
437: const client = streamResponsesRecallAware(
438: streamFrom([
439: created("resp_plain", "gpt-5.6-terra"),
440: textItem(0, "hello world"),
441: completed("resp_plain", { input_tokens: 10, output_tokens: 3 }),
442: ]),
443: {
444: onComplete: () => {},
445: onRecall: async () => ({ anchorText: "", resultText: "" }),
446: runFollowUp: async () => {
447: throw new Error("should not be called");
448: },
449: },
450: );
451: const out = await drain(client);
452: // The ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/vitest.config.ts</path>
<type>file</type>
<content>
1: import { defineConfig } from "vitest/config";
2: import path from "node:path";
3:
4: export default defineConfig({
5: // Alias @loreai/core and @loreai/gateway for test imports.
6: // MUST be at the top level of the vite config — putting this under
7: // `test.resolve.alias` does NOT work (vite's resolver is a top-level
8: // option, not a test.* option). The previous placement silently
9: // resolved to the stale dist build, masking real test failures.
10: resolve: {
11: alias: {
12: "@loreai/core": path.resolve(__dirname, "packages/core/src"),
13: "@loreai/gateway": path.resolve(__dirname, "packages/gateway/src"),
14: },
15: },
16: test: {
17: // Run all packages' tests
18: include: [
19: "packages/core/test/**/*.test.ts",
20: // Fast, pure unit tests for the eval suite's own logic (scorers,
21: // analysis). ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/core/test/setup.ts</path>
<type>file</type>
<content>
1: import { mkdtempSync, rmSync } from "node:fs";
2: import { join } from "node:path";
3: import { tmpdir } from "node:os";
4: import { afterAll, afterEach } from "vitest";
5: import { close, invalidateProjectIdCache } from "../src/db";
6: import { silenceStderr } from "../src/log";
7:
8: // Create an isolated temporary database for the entire test run.
9: // This prevents test fixtures from leaking into the live lore DB
10: // at ~/.local/share/lore/lore.db.
11: const tmp = mkdtempSync(join(tmpdir(), "lore-test-"));
12: process.env.LORE_DB_PATH = join(tmp, "test.db");
13:
14: // ---------------------------------------------------------------------------
15: // Block live network to models.dev during tests.
16: //
17: // `fetchModelData()` (gateway/src/worker-model.ts) hits
18: // https://models.dev/api.json to pull pricing/limits, and the gateway
19: // pre-warms ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
2200: id: "fc_terminal_name",
2201: call_id: "call_terminal_name",
2202: name: "read",
2203: },
2204: }),
2205: sseEvent("response.function_call_arguments.done", {
2206: output_index: 0,
2207: item_id: "fc_terminal_name",
2208: arguments: "{}",
2209: }),
2210: sseEvent("response.output_item.done", {
2211: output_index: 0,
2212: item: {
2213: type: "function_call",
2214: id: "fc_terminal_name",
2215: call_id: "call_terminal_name",
2216: name: "read",
2217: arguments: "{}",
2218: status: "completed",
2219: },
2220: }),
2221: sseEvent("response.completed", {
2222: response: {
2223: id: ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/bundle-exports.test.ts:
Line 20: * bundle on demand in `beforeAll`, so it always runs against a bundle built
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/batch-queue.test.ts:
Line 9: * - Shutdown drains the queue
Line 367: test("shutdown drains queue synchronously via inner client", async () => {
Line 383: // Shutdown should drain via fallback
Line 394: test("shutdown({ drainQueue: false }) drops queued items without calling inner (fast process exit)", async () => {
Line 413: await client.shutdown({ drainQueue: false });
Line 1326: await client.shutdown({ drainQueue: false });
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/background-limiter.test.ts:
Line 4: drainBackground,
Line 524: describe("drainBackground", () => {
Line 526: await ...
Found 19 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts:
Line 478: cancel() {
Line 501: await reader.cancel();
Line 1574: cancel() {
Line 1592: await reader.cancel(new Error("client disconnected"));
Line 1615: cancel() {
Line 7125: test("stops reading upstream while the client applies backpressure", async () => {
Line 7128: created("resp_backpressure", "gpt-5.6-terra"),
Line 7130: completed("resp_backpressure"),
Line 7160: await reader.cancel();
Line 8666: const cancelled = reader.cancel();
Line 8709: await reader.cancel();
Line 8738: reader.cancel().then(() => "cancelled"),
Line 8767: cancel() {
Line 8778: const cancelled = reader.cancel();
Line 8801: cancel() {
Line 8864: reader.cancel().then(() => "cancelled"),
Line 8922: cancel() {
Line ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
7080: const sparseArguments = `{"path":"${"x".repeat(10 * 1024)}"}`;
7081: const anchorText = "a".repeat(4 * 1024);
7082: const followUp = streamFrom([
7083: created("resp_sparse_transactional_once", "gpt-5.6-terra"),
7084: sparseVisibleFunctionCall(0, sparseArguments),
7085: completed("resp_sparse_transactional_once"),
7086: ]);
7087: const client = streamResponsesRecallAware(
7088: streamFrom([
7089: created("resp_sparse_transactional_once_principal", "gpt-5.6-terra"),
7090: recallCall(0, { query: "sparse transactional once" }),
7091: completed("resp_sparse_transactional_once_principal"),
7092: ]),
7093: {
7094: maxDeferredBytes: 16 * 1024,
7095: maxRetainedStateBytes: 48 * 1024,
7096: validation: "codex",
7097: ...
Found 2 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts:
Line 7794: export function streamResponsesRecallAware(
Line 18903: streamResponsesRecallAware(upstreamResponse, {
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
18780: sessionState.sessionID,
18781: sessionState.resolvedConversationTTL,
18782: genAiSpan,
18783: endGenAiSpan,
18784: () => {
18785: sessionState._dirty = true;
18786: },
18787: );
18788: return;
18789: }
18790: try {
18791: const postResponseFailed = new Error(
18792: "Responses recall post-response persistence failed",
18793: );
18794: try {
18795: withTenant(sessionState.storageTenantId ?? ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/recall-continuation-failure.ts</path>
<type>file</type>
<content>
1: export const RECALL_CONTINUATION_FAILURE_CATEGORIES = [
2: "recall_execution",
3: "follow_up_setup",
4: "follow_up_transport",
5: "follow_up_protocol",
6: "follow_up_failed",
7: "follow_up_missing_output",
8: "follow_up_incomplete_arguments",
9: "parallel_recall",
10: "nested_recall_incomplete",
11: "nested_recall_execution",
12: "depth_exhausted",
13: "missing_recall_block",
14: "resource_limit",
15: "delivery",
16: "unexpected",
17: ] as const;
18:
19: export type RecallContinuationFailureCategory =
20: (typeof RECALL_CONTINUATION_FAILURE_CATEGORIES)[number];
21:
22: type RecallContinuationFailureHook = (
23: category: RecallContinuationFailureCategory,
24: ) => void;
25:
26: let failureHook: RecallContinuationFailureHook | undefined;
27:
28: export class RecallContinuationFailure extends Error {
29: ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/recall-budget.ts</path>
<type>file</type>
<content>
1: import type { RecallCoverage } from "@loreai/core";
2: import type { GatewayUsage } from "./translate/types";
3:
4: /** Finite backstop only; normal termination is time, tokens, bytes, items, or stall. */
5: export const MAX_RECALL_EXECUTIONS = 24;
6: export const MAX_RECALL_CHAIN_TOKENS = 128_000;
7: export const MAX_RECALL_CHAIN_RESULT_BYTES = 512 * 1024;
8: export const MAX_RECALL_CHAIN_ITEMS = 64;
9: /** The formatter's configured maximum for source previews in one search. ...
Found 3 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts:
Line 4195: test("rejects unfinished reasoning omitted from output_item.done", async () => {
Line 4247: item: { type: "reasoning", id: "rs_summary_field_omitted" },
Line 4809: test("accepts reasoning summary prefixes extended by deltas", async () => {
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
4120: model: "gpt-5.6-terra",
4121: status: "completed",
4122: output: [
4123: {
4124: type: "reasoning",
4125: id: "rs_repeated_ciphertext",
4126: summary: [],
4127: ...terminalEnvelope,
4128: },
4129: ],
4130: },
4131: }),
4132: ]),
4133: {
4134: validation: "codex",
4135: onComplete: () => {},
4136: onRecall: async () => ({ anchorText: "", resultText: "" }),
4137: runFollowUp: async () => {
4138: throw new Error("should not run");
4139: },
4140: },
4141: );
4142:
4143: expect(await drain(client)).toContain("response.failed");
4144: },
4145: ...
packages/gateway/src/pipeline.ts | 519 ++++-- packages/gateway/src/stream/openai-responses.ts | 1 + ...st/openai-responses-recall-aware-stream.test.ts | 1684 +++++++++++++++++++++- 3 files changed, 2068 insertions(+), 136 deletions(-)
tklkqxytmpkz ce88c614c0ae55d229cb605aa7c7369d918d3650 fix(responses): complete lifecycle reconciliation kvpmnlwnznqx 683dff02101f15198b18e3088a0b57dade290056 fix(responses): bound sparse lifecycle coordinates lplymwvllmzn df49b0cec904a3f432a0f7f29ea398840d62fe9e fix(responses): preserve limit-crossing state pxrvwsvvkmpo 2cbf40060c67df229731cf1b9e34d5bf22ec2145 feat(cch): add seeds for Claude Code up to 2.1.272 (#1780)
No files found
Found 5 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts:
Line 13490: function accountUnsuccessfulResponse(
Line 18689: if (currentResp.codexRateLimits?.length) {
Line 18690: continuationResp.codexRateLimits = [
Line 18691: ...currentResp.codexRateLimits,
Line 18692: ...(continuationResp.codexRateLimits ?? []),
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
13450: loreConfig().curator.afterTurns * curationMultiplier;
13451: if (sessionState.turnsSinceCuration < effectiveAfterTurns) {
13452: log.info(
13453: `commit detected in session ${sessionID.slice(0, 16)} — triggering curation`,
13454: );
13455: sessionState.turnsSinceCuration = effectiveAfterTurns;
13456: }
13457: }
13458:
13459: // --- Schedule background work (fire-and-forget) ---
13460: saveSessionTracking(sessionID, {
13461: messageCount: sessionState.messageCount,
13462: turnsSinceCuration: sessionState.turnsSinceCuration,
13463: consecutiveTextOnlyTurns: sessionState.consecutiveTextOnlyTurns,
13464: projectPath: sessionState.projectPath || null,
13465: projectPathProvisional: sessionState.projectPathProvisional === true,
13466: ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
8600: call_id: "call_malformed_unfinished",
8601: name: "recall",
8602: },
8603: }),
8604: "event: response.output_item.done\ndata: {not json\n\n",
8605: ]);
8606: const client = streamResponsesRecallAware(
8607: streamFrom([
8608: created("resp_malformed_unfinished_principal", "gpt-5.6-terra"),
8609: recallCall(0, { query: "architecture" }),
8610: completed("resp_malformed_unfinished_principal"),
8611: ]),
8612: {
8613: onComplete: () => {},
8614: onRecall: async ({ query }) => ({
8615: anchorText: buildAnchor(query),
8616: resultText: "results",
8617: }),
8618: runFollowUp: async () => ({ reader: followUp.body!.getReader() }),
8619: },
8620: );
8621:
8622: expect(await ...
Found 11 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts:
Line 15818: downstreamSettled: Promise<void>,
Line 15893: await downstreamSettled;
Line 16165: await downstreamSettled;
Line 16344: downstreamSettled: Promise<void>,
Line 16433: downstreamSettled,
Line 18766: await downstreamSettled;
Line 18834: await downstreamSettled;
Line 20061: const downstreamSettled = new Promise<void>((resolve) => {
Line 20071: downstreamSettled,
Line 20088: downstreamSettled: Promise<void>,
Line 20218: downstreamSettled,
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
20030: {
20031: status,
20032: headers: { "content-type": "application/json" },
20033: },
20034: );
20035: }
20036:
20037: // ---------------------------------------------------------------------------
20038: // Main entry point
20039: // ---------------------------------------------------------------------------
20040:
20041: /**
20042: * Process an incoming gateway request through the full Lore pipeline.
20043: *
20044: * Returns a standard `Response` object — either a streaming SSE response
20045: * or a JSON response, depending on the client's `stream` setting.
20046: */
20047: async function handleRequestForTenant(
20048: req: GatewayRequest,
20049: config: GatewayConfig,
20050: ): Promise<Response> {
20051: if (!req?.rawHeaders) {
20052: return errorResponse(400, "Malformed request: missing headers");
20053: ...
Found 1 matches /home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts: Line 15372: async function runActivePipelineRequest(
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
15340: signal.throwIfAborted();
15341: if (pipelineSessionHasCapacity(sessionID)) {
15342: active.sessionIDs.add(sessionID);
15343: return;
15344: }
15345: if (
15346: pendingSessionClaims.has(sessionID) ||
15347: pendingSessionClaims.size >= MAX_PENDING_SESSION_CLAIMS ||
15348: pendingSessionClaimsForAdmissionKey(active.admissionKey) >=
15349: MAX_ACTIVE_PIPELINE_REQUESTS_PER_ADMISSION_KEY
15350: ) {
15351: throw new PipelineCapacityError("session request queue full");
15352: }
15353:
15354: activePipelineRequests.delete(active);
15355: return new Promise<void>((resolve, reject) => {
15356: let claim: PendingSessionClaim;
15357: const onAbort = () => {
15358: if (pendingSessionClaims.get(sessionID) !== claim) return;
15359: pendingSessionClaims.delete(sessionID);
15360: ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/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: ...
tklkqxytmpkzzryqlolnpvxouropxznp fix(responses): complete lifecycle reconciliation --- kvpmnlwnznqxomuzywlvmotqtplywzvm fix(responses): bound sparse lifecycle coordinates --- lplymwvllmznozzrzoroxvnnuymnusxs fix(responses): preserve limit-crossing state ---
RUN v4.1.8 /home/byk/Code/opencode-lore-responses-accumulation
Test Files 1 passed (1)
Tests 48 passed | 207 skipped (255)
Start at 14:20:03
Duration 7.76s (transform 3.85s, setup 521ms, import 6.11s, tests 923ms, environment 0ms)
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
4890: content_index: 0,
4891: text: "prefix",
4892: }),
4893: sseEvent("response.content_part.done", {
4894: output_index: 0,
4895: item_id: "rs_text",
4896: content_index: 0,
4897: part: { type: "reasoning_text", text: "prefix" },
4898: }),
4899: sseEvent("response.output_item.done", {
4900: output_index: 0,
4901: item: {
4902: type: "reasoning",
4903: id: "rs_text",
4904: content: [{ type: "reasoning_text", text: "prefix" }],
4905: },
4906: }),
4907: completed("resp_reasoning_text"),
4908: ]),
4909: {
4910: onComplete: () => {},
4911: onRecall: async () => ({ anchorText: "", resultText: "" }),
4912: runFollowUp: async ...
Found 1 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts:
Line 7668: test("computes the continuation offset without spreading 126000 retained item keys", async () => {
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
7660: expect(out).not.toContain(privateText);
7661: expect(
7662: JSON.parse(/event: response\.failed\ndata: (.+)/.exec(out)?.[1] ?? "{}"),
7663: ).toMatchObject({ response: { status: "failed", output: [] } });
7664: expect(outcomes).toEqual([false]);
7665: expect([commits, rollbacks, rollbacksAtComplete]).toEqual([0, 1, 1]);
7666: });
7667:
7668: test("computes the continuation offset without spreading 126000 retained item keys", async () => {
7669: const visibleItemCount = 63_000;
7670: const initialPrincipalEvents = [
7671: created("resp_many_retained_items", "gpt-5.6-terra"),
7672: ];
7673: for (const outputIndex of Array.from(
7674: { length: visibleItemCount },
7675: (_, index) => index,
7676: )) {
7677: initialPrincipalEvents.push(
7678: ...
Found 6 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts:
Line 969: test("accumulates the principal event that crosses the retained-state limit", async () => {
Line 1070: "retains principal %s state when it crosses the retained-state limit",
Line 1143: "bounds principal $kind coordinate $coordinate before sparse state mutation",
Line 7250: test("accumulates the continuation event that crosses the retained-state limit", async () => {
Line 7598: test("iteratively reconstructs a resource-limited continuation with 125500 content blocks", async () => {
Line 7794: test("accounts for terminal Codex continuation usage once when candidate flush exceeds the transaction limit", async () => {
Found 1 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/translate/types.ts:
Line 341: export type GatewayResponse = {
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/translate/types.ts</path>
<type>file</type>
<content>
320: /**
321: * True when a response body is Server-Sent Events rather than a JSON object —
322: * even if the provider mislabeled or omitted the `content-type`.
323: *
324: * Detected by the header OR by sniffing the body prefix: an LLM-completion SSE
325: * stream always begins with a `data:` or `event:` field, whereas a JSON body
326: * begins with `{` or `[`. Some providers (the ChatGPT/Copilot/Codex backend,
327: * DeepSeek) return SSE even when a NON-streaming request was made — and
328: * sometimes WITHOUT the `text/event-stream` content-type — so a header-only
329: * check misses them and `JSON.parse`-ing the SSE body throws
330: * (`Unexpected token 'e', "event: res"...` — LOREAI-GATEWAY-38 / -1P).
331: *
332: * Recognizes every legal field/comment that may precede the first data event. ...
The working copy has no changes. Working copy (@) : lrqlyykx d890b184 (empty) (no description set) Parent commit (@-): tklkqxyt ce88c614 fix/responses-accumulation-order | fix(responses): complete lifecycle reconciliation 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. lrqlyykxvwoqrxzowonmmytxulyqmqlu d890b184d786a4348e30bcdac7412baa7ae01ae9 parents=ce88c614c0ae55d229cb605aa7c7369d918d3650 conflict=false empty=true description= tklkqxytmpkzzryqlolnpvxouropxznp ce88c614c0ae55d229cb605aa7c7369d918d3650 parents=683dff02101f15198b18e3088a0b57dade290056 conflict=false empty=false description=fix(responses): complete lifecycle reconciliation pxrvwsvvkmpoxnsqmrkwrnlqvvkoltwz 2cbf40060c67df229731cf1b9e34d5bf22ec2145 parents=e977b4b1da8f8197c3238466d41de0bccd8eb054 conflict=false empty=false description=feat(cch): add seeds for Claude Code up to 2.1.272 (#1780) M ...
The failure boundary is not fixed or empty:
response.failed terminal is forwarded verbatim at packages/gateway/src/pipeline.ts:10639-10674."provider failed" to reach the client at packages/gateway/test/openai-responses-recall-aware-stream.test.ts:507-532.buildOutputItems(...) at packages/gateway/src/pipeline.ts:11939-11976; only resource-limit failures receive output: [].packages/gateway/test/openai-responses-recall-aware-stream.test.ts:2254-2268.The new unsuccessful callback projection is also incomplete. finish() spreads the full response and clears only content and rawOutputItems at packages/gateway/src/pipeline.ts:9738-9746. It retains codexRateLimits, whose allowlisted keys still contain unvalidated provider values copied at packages/gateway/src/stream/openai-responses.ts:588-603 and exported at packages/gateway/src/stream/openai-responses.ts:888-900.
A hidden codex.rate_limits event after recall detection can therefore reach onComplete after a later failure, even though the event was never delivered publicly.
Required fix: sanitize every failed terminal before forwarding. Every client-visible response.failed must use the fixed public error and output: []. Build unsuccessful callback data from an explicit minimal projection—validated usage and required protocol identity only—rather than spreading the accumulated response.
materializeCompletedCodexMessages() handles only messages at packages/gateway/src/pipeline.ts:7985-7996. Reasoning summaries and reasoning content are not materialized. ...
Date: Sep 16, 2026 * 🟡 (14:25) Tool output showed a clean, empty working copy `lrqlyykxvwoqrxzowonmmytxulyqmqlu` / Git commit `d890b184d786a4348e30bcdac7412baa7ae01ae9`, parented by candidate `tklkqxytmpkzzryqlolnpvxouropxznp` / `ce88c614c0ae55d229cb605aa7c7369d918d3650`; an unrelated bookmark `fix/responses-private-references` had conflicts. * 🟡 (14:25) Candidate diff touched exactly 3 files: …
Date: Sep 16, 2026 * 🟡 (14:19) `runActivePipelineRequest()` in `/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts` rejects admission with HTTP `503` and `"Gateway is busy"` when detached + active + pending session claims reach `maxDetachedPipelineRequests`, active + `streamingPostResponsePending` reach `maxActivePipelineRequests`, or per-admission-key active + …
Date: Sep 16, 2026 * 🟡 (14:13) In `/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts`, successful streaming post-response persistence runs `postResponseForTenant()` inside `withTenant()` and savepoint `"responses_recall_post_response"`; it requires a truthy persistence result before `recallPersistenceTransaction?.commit()`, otherwise rolls back through `rollbac…
Date: Sep 16, 2026 * 🔴 (14:11) User asserted that `error()` output in `/home/byk/Code/opencode-lore-responses-accumulation/packages/core/src/log.ts` is “Always visible — these indicate real failures.” * 🟡 (14:11) `/home/byk/Code/opencode-lore-responses-accumulation/packages/core/src/log.ts` distinguishes `notice()` from `warn()` and `error()`: `notice()` is not debug-gated, reports to the regis…
Date: Sep 16, 2026 * 🔴 (14:09) User asserted the invariant in `/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/stream/anthropic.ts`: deterministic local stream limits must never be reclassified as transport. * 🟡 (14:09) `/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/stream/anthropic.ts` defines `SSEStreamTransportError` with `kind: "inactivity…
Date: Sep 16, 2026 * 🔴 (14:08) User asserted the requirement/test invariant `test("never executes recall from an incomplete principal", async () => {`. * 🟡 (14:08) Added test `accounts for terminal Codex continuation usage once when candidate flush exceeds the transaction limit`, using model `gpt-5.6-terra`; the shown terminal usage is `{ input_tokens: 11, output_tokens: 7, total_tokens: 18 }`,…
Date: Sep 16, 2026 * 🔴 (14:08) User asserted that the stream “never forwards response-side item_reference lifecycle events,” expressed as the test name `test("never forwards response-side item_reference lifecycle events", async () => {`. * 🟡 (14:08) Provided diff adds extensive response-stream tests covering sparse output/content indices, reasoning summary and reasoning text lifecycle events, t…
Date: Sep 16, 2026 * 🔴 (14:08) User asserted in a code comment at line 1909 that “Sparse numeric identities can never need more address space than the” [remainder elided]. * 🔴 (14:08) User asserted in a code comment at line 1912 that “`index + 1` always changes the value.” * 🟡 (14:08) Provided code shows `accumulateResponsesSSEStream` initializes state with `opts.state ?? makeResponsesAccState…
Date: Sep 16, 2026 * 🔴 (14:07) User specified that the `response.output_text.done` handler should replace accumulated text with the final version because the final version is more reliable (line 678).
Date: Sep 16, 2026 * 🔴 (14:07) User stated that invalid usage still throws and its projection is never returned as success. * 🟡 (14:07) Principal transport failures use `const PRINCIPAL_TRANSPORT_INCOMPLETE_REASON = "gateway_transport"`. * 🟡 (14:07) Exhausted principal transport retries are recorded with `outcome: "retry_exhausted"`. * 🟡 (14:07) Upstream error handling can throw `new Error("u…
Date: Sep 16, 2026 * 🟡 (14:07) Recall continuation logic checks `if (pendingRecalls.length > 1)`. * 🟡 (14:07) Transactional buffering includes `reserveTransactionalBytes(chunk: Uint8Array): void`. * 🟡 (14:07) Recall continuation can throw `new RecallContinuationFailure("resource_limit")`. * 🟡 (14:07) Continuation event processing tracks recall output indices in `const contRecallIndices = new …
Date: Sep 16, 2026 * 🟡 (14:07) Responses streaming continuation code includes keepalive behavior matching `streamResponsesPassthrough`. * 🟡 (14:07) Recall continuation admission failure throws `new RecallContinuationFailure("depth_exhausted")`. * 🟡 (14:07) Abort handling registers `signal.addEventListener("abort", onAbort, { once: true })`. * 🟡 (14:07) Recall-budget accounting calls `recallBu…
Date: Sep 16, 2026 * 🟡 (14:07) Responses stream validation code tracks authoritative content-part values and rejects invalid deltas with `throw new Error(\`invalid Responses ${event} delta\`)`. * 🟡 (14:07) Responses reasoning-summary handling tracks `summaryState.authoritativeValueSeen`, validates `response.reasoning_summary_part.added`, requires finalized summary parts to use type `"summary_te…
Date: Sep 16, 2026 * 🟡 (14:06) `/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/package.json` defines `@loreai/gateway` version `0.40.0`, `"type": "module"`, license `FSL-1.1-Apache-2.0`, description `"Lore as a transparent LLM proxy — context management for any AI coding client"`, and Node engine requirement `>=22.15`. * 🟡 (14:06) `@loreai/gateway` package entry points are…
Date: Sep 16, 2026 * 🔴 (14:05) User directed that response events must always accumulate into the internal state for `postResponse`. * 🟡 (14:05) Candidate `packages/gateway/src/pipeline.ts` changes introduce `maxSSEFrames = opts.maxSSEFrames ?? DEFAULT_MAX_SSE_FRAMES` and bound sparse indices with `Math.min(maxSSEFrames, DEFAULT_MAX_SSE_FRAMES)`. * 🟡 (14:05) Candidate `packages/gateway/src/pip…
Date: Sep 16, 2026 * 🔴 (14:05) User stated response handling must “never forwards response-side item_reference lifecycle events.” * 🔴 (14:05) User stated recall handling must “never executes recall from an incomplete principal.” * 🟡 (14:05) Candidate test changes in `packages/gateway/test/openai-responses-recall-aware-stream.test.ts` add a `response.reasoning_summary_text.done` event for reaso…
Date: Sep 16, 2026 * 🔴 (14:04) User stated `jj` never fails on merge conflict; conflicts are recorded in the resulting commit and must be detected with `jj st` and resolved manually rather than with interactive `jj resolve`. * 🔴 (14:04) User’s `jj` workflow rules: use `jj`, not `git`, for mutations when `.jj/` exists; never use interactive flags; always pass `-m "msg"` when describing/committin…
Date: Sep 16, 2026 * 🔴 [requested-review] (14:03) User requested an independent read-only security/privacy/pentest review of the immutable accumulation candidate in `/home/byk/Code/opencode-lore-responses-accumulation`. * 🔴 (14:03) User specified base `main@origin` at exact commit `2cbf40060c67df229731cf1b9e34d5bf22ec2145` and candidate stable change `tklkqxytmpkzzryqlolnpvxouropxznp` at exact …