Dashboard › opencode-lore › Session 0LZ8JXFdTlVG
0LZ8JXFdTlVGLQbUkStrict READ-ONLY security/privacy review in /home/byk/Code/opencode-lore-responses-accumulation. Do not edit or mutate VCS. Candidate stable change tklkqxytmpkzzryqlolnpvxouropxznp, commit ce88c614c0ae55d229cb605aa7c7369d918d3650; base literal 2cbf40060c67df229731cf1b9e34d5bf22ec2145; expected plain diff SHA-256 485238edc024cfedc7d604018d39af7bfb6ab5b9616962d0e41c2ef460b205f8; expected 3 changed paths. Verify identity/status/conflicts/scope/hash before/after. Read instructions/scripts/all changed lines and relevant stream/callback/persistence/logging paths. Attack terminal-only/done-only reasoning injection, gap/forged fields, sparse huge coordinates and shifted overflow, lifecycle-only state crossing retained limits, private callback/public output leakage, recall/nested-recall side effects before validation, sparse omission raw-coordinate collapse, large-array/CPU amplification, usage/accounting duplication, cancellation/backpressure, malformed events, retries, logs/telemetry/persistence. Check that final output_text.done remains authoritative replacement. Evaluate tests and fail-first/mutation discrimination. Focused tests allowed; exhaustive separate. Return PASS/CONCERN/MUST-FIX with exact current file:line evidence and residual risk. 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`. ...
/home/byk/Code/opencode-lore-responses-accumulation jj 0.45.1-2133040a8b99df306b3b6a199608b5ae669ae8a6 /home/byk/Code/opencode-lore-responses-accumulation 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. ...
485238edc024cfedc7d604018d39af7bfb6ab5b9616962d0e41c2ef460b205f8 - 02d06b2f84d7d2d8cfa5f22443384d12a2a9bc922ade879449de9b0b9d971d1c - 485238edc024cfedc7d604018d39af7bfb6ab5b9616962d0e41c2ef460b205f8 -
<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. ...
<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: ...
diff --git a/packages/gateway/src/pipeline.ts b/packages/gateway/src/pipeline.ts
index 004e03b3e2..635477d648 100644
--- a/packages/gateway/src/pipeline.ts
+++ b/packages/gateway/src/pipeline.ts
@@ -7971,14 +7971,75 @@
const finalizedMessageContent = (
lifecycle: OutputLifecycle,
): Array<Record<string, unknown>> =>
- Array.from(lifecycle.content)
- .sort(([left], [right]) => left - right)
- .filter(([, part]) => part.valueDone || part.partDone)
- .map(([, part]) =>
- part.kind === "refusal"
- ? { type: "refusal", refusal: part.authoritativeValue }
- : { type: "output_text", text: part.authoritativeValue },
- );
+ Array.from(lifecycle.content).reduce<Array<Record<string, unknown>>>(
+ (content, [contentIndex, part]) => {
+ if (!part.valueDone && !part.partDone) return content;
+ content[contentIndex] =
+ part.kind === "refusal"
+ ? { type: "refusal", refusal: part.authoritativeValue ...
diff --git a/packages/gateway/src/stream/openai-responses.ts b/packages/gateway/src/stream/openai-responses.ts
index 4c33c821b5..5623788876 100644
--- a/packages/gateway/src/stream/openai-responses.ts
+++ b/packages/gateway/src/stream/openai-responses.ts
@@ -824,6 +824,7 @@
if (item.type === "text") {
if (item.content) {
for (const part of item.content) {
+ if (!part) continue;
if (part.type === "output_text" && typeof part.text === "string") {
content.push({ type: "text", text: part.text });
} else {
...output truncated...
Full output saved to: /home/byk/.local/share/opencode/tool-output/tool_0aaee8e9f001nZXrMwAq7Jd3k8
+ },
+ );
+
+ const out = await drain(client);
+ const materializedItem = finalizeSpy.mock.calls
+ .map(([acc]) => acc.rawItems.get(0))
+ .find((item) => item?.encrypted_content === triggerCiphertext);
+ expect(materializedItem).toEqual(
+ expect.objectContaining({
+ id: "rs_retained_trigger",
+ status: "completed",
+ encrypted_content: triggerCiphertext,
+ summary: [{ type: "summary_text", text: "summary" }],
+ }),
+ );
+ expect(completedResponse?.content).toEqual([]);
+ expect(completedResponse?.rawOutputItems).toEqual([]);
+ expect(out.match(/^event: response\.failed$/gm)).toHaveLength(1);
+ expect(out).toContain(PUBLIC_GATEWAY_ERROR);
+ expect(out).not.toContain(PUBLIC_RECALL_ERROR);
+ expect(out).not.toContain(triggerCiphertext);
+ expect(
+ JSON.parse(/event: ...
<path>/home/byk/.local/share/opencode/tool-output/tool_0aaee8e9f001nZXrMwAq7Jd3k8</path>
<type>file</type>
<content>
1: diff --git a/packages/gateway/test/openai-responses-recall-aware-stream.test.ts b/packages/gateway/test/openai-responses-recall-aware-stream.test.ts
2: index dca2a57d78..026c9abab9 100644
3: --- a/packages/gateway/test/openai-responses-recall-aware-stream.test.ts
4: +++ b/packages/gateway/test/openai-responses-recall-aware-stream.test.ts
5: @@ -14,1 +14,1 @@
6: -import { afterEach, describe, test, expect } from "vitest";
7: +import { afterEach, describe, test, expect, vi } from "vitest";
8: @@ -33,0 +34,1 @@
9: + vi.restoreAllMocks();
10: @@ -46,0 +48,17 @@
11: +function sseDataBytes(frame: string): number {
12: + const dataStart = frame.indexOf("data: ");
13: + const dataEnd = frame.indexOf("\n\n", dataStart);
14: + if (dataStart < 0 || dataEnd < 0) throw new Error("invalid test SSE frame");
15: + return new TextEncoder().encode(frame.slice(dataStart + 6, ...
<path>/home/byk/.local/share/opencode/tool-output/tool_0aaee8e9f001nZXrMwAq7Jd3k8</path>
<type>file</type>
<content>
1101: + response: {
1102: + status: "failed",
1103: + output: [],
1104: + error: { type: "server_error", message: PUBLIC_RECALL_ERROR },
1105: + },
1106: + });
1107: + expect(outcomes).toEqual([false]);
1108: + expect(failures).toEqual(["resource_limit"]);
1109: + });
1110: +
1111: + test.each(LIFECYCLE_ONLY_EVENTS)(
1112: + "retains continuation %s state when it crosses the retained-state limit",
1113: + async (event) => {
1114: + const responsesStream = await import("../src/stream/openai-responses");
1115: + const finalizeSpy = vi.spyOn(responsesStream, "finalizeResponsesAcc");
1116: + const scenario = lifecycleLimitScenario(event, "continuation");
1117: + const principal = [
1118: + created("resp_lifecycle_continuation", "gpt-5.6-terra"),
1119: + recallCall(0, {
1120: + query: ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts:
Line 7: * temporal storage → background work scheduling.
Line 15: import { storeTurnTemporal, type TurnTemporalInput } from "./turn-temporal";
Line 20: export { storeTurnTemporal } from "./turn-temporal";
Line 45: temporal,
Line 93: temporalEmbeddingQueue,
Line 260: } from "./temporal-adapter";
Line 687: let postResponseStartObserver: (() => void) | undefined;
Line 845: postResponseStartObserver = observer;
Line 932: log.error(
Line 1011: postResponseStartObserver = undefined;
Line 1114: log.error("streaming post-response drop cleanup failed:", error);
Line 1139: log.warn("streaming post-response queue full; dropping finalizer");
Line 1164: log.error("streaming post-response processing failed:", error);
Line 1460: const persisted = loadSessionTracking(sessionID);
Line 1462: ...
Found 61 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts:
Line 205: applyResponsesEvent,
Line 206: finalizeResponsesAcc,
Line 7794: export function streamResponsesRecallAware(
Line 7932: const normalizeCodexEvent = (
Line 8089: const rollbackTransaction = (): void => {
Line 8301: const contentPosition = finalizeResponsesAcc(acc).content.findIndex(
Line 8423: const outputIndexForEvent = (
Line 8461: outputIndexForEvent(
Line 8466: applyResponsesEvent(state, "response.output_item.added", {
Line 9233: outputIndexForEvent(
Line 9238: applyResponsesEvent(acc, "response.output_item.added", {
Line 9243: const validateResponseLifecycle = (
Line 9375: const preserveStreamedReasoning = (
Line 9398: const assertTerminalReasoningMatchesLifecycle = (
Line 9536: outputIndexForEvent(
Line 9541: applyResponsesEvent(acc, "response.output_item.done", {
...
<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>
1080: state.itemIndexById.get(doneItem.id) !== outputIndex) ||
1081: (typeof doneItem.call_id === "string" &&
1082: state.callIndexById.get(doneItem.call_id) !== outputIndex)
1083: ) {
1084: malformed();
1085: }
1086: break;
1087: }
1088: case "response.content_part.added":
1089: case "response.content_part.done":
1090: if (
1091: !validOutputIndex ||
1092: !state.rawItems.has(outputIndex as number) ||
1093: !Number.isSafeInteger(parsed.content_index) ||
1094: (parsed.content_index as number) < 0 ||
1095: (parsed.content_index as number) >= maxSparseIndex ||
1096: (parsed.item_id !== undefined &&
1097: parsed.item_id !== state.rawItems.get(outputIndex as number)?.id) ||
1098: !parsed.part ||
1099: ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/stream/openai-responses.ts</path>
<type>file</type>
<content>
1700: if (
1701: event === "response.in_progress" &&
1702: response.status !== undefined &&
1703: response.status !== "in_progress"
1704: ) {
1705: malformedResponsesEvent();
1706: }
1707: }
1708:
1709: switch (event) {
1710: case "response.output_item.added":
1711: case "response.output_item.done":
1712: normalizeCodexItemEvent(state, event, parsed, maxSparseIndex);
1713: break;
1714: case "response.content_part.added":
1715: case "response.content_part.done":
1716: if (!isRecord(parsed.part)) malformedResponsesEvent();
1717: normalizeCodexDataEvent(state, event, parsed, maxSparseIndex);
1718: break;
1719: case "response.output_text.delta":
1720: if (typeof parsed.delta !== "string") malformedResponsesEvent();
1721: ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
7790: * The recall execution callback abstracts the pipeline-scope dependencies
7791: * (`executeRecall` + follow-up forwarding + recall store), so this function
7792: * stays a self-contained streamer in the Responses module.
7793: */
7794: export function streamResponsesRecallAware(
7795: upstreamResponse: Response,
7796: opts: {
7797: onComplete: (response: GatewayResponse, successful: boolean) => void;
7798: onTransactionReady?: (transaction: {
7799: commit: () => void;
7800: rollback: () => void;
7801: }) => void;
7802: sessionID?: string;
7803: /** Emergency ceiling for the request-owned recall chain. */
7804: maxRecallExecutions?: number;
7805: /** @deprecated Use `maxRecallExecutions`. */
7806: maxRecallDepth?: number;
7807: noStore?: boolean;
7808: maxDeferredBytes?: number;
7809: ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
8510: );
8511: }
8512: if (
8513: item.type === "function_call" &&
8514: item.call_id !== "" &&
8515: item.id === item.call_id
8516: ) {
8517: throw new Error("duplicate Responses identity within output item");
8518: }
8519: if (
8520: item.type === "function_call" &&
8521: item.arguments !== undefined &&
8522: typeof item.arguments !== "string"
8523: ) {
8524: throw new Error("invalid initial Responses function arguments");
8525: }
8526: if (
8527: item.type === "function_call" &&
8528: item.status !== undefined &&
8529: typeof item.status !== "string"
8530: ) {
8531: throw new Error("invalid initial Responses function status");
8532: }
8533: if (
8534: item.type === "function_call" ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
9270: }
9271: lifecycle.created = true;
9272: return;
9273: }
9274: if (!lifecycle.created && event.startsWith("response.")) {
9275: throw new Error(`Responses event before response.created: ${event}`);
9276: }
9277: if (event === "response.in_progress") {
9278: const response = parsed.response as Record<string, unknown> | undefined;
9279: if (acc.id && response?.id !== undefined && response.id !== acc.id) {
9280: throw new Error(
9281: "Responses in-progress event changed response identity",
9282: );
9283: }
9284: if (response?.status !== undefined && response.status !== "in_progress") {
9285: throw new Error("response.in_progress has invalid status");
9286: }
9287: if (
9288: response?.output !== undefined &&
9289: ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
10190: emitsOrdinaryTool = false,
10191: afterEnqueue?: () => void,
10192: ): Promise<boolean> =>
10193: safeEnqueue(chunk, () => {
10194: principalEventEmitted = true;
10195: if (emitsOrdinaryTool) ordinaryToolEmitted = true;
10196: afterEnqueue?.();
10197: });
10198: const safeClose = (): void => {
10199: cleanupAbort();
10200: if (cancelled) return;
10201: try {
10202: controller.close();
10203: } catch {
10204: // Already closed/cancelled
10205: }
10206: };
10207: const safeError = (error: unknown): void => {
10208: cleanupAbort();
10209: if (cancelled) return;
10210: try {
10211: controller.error(error);
10212: } catch ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
10940: const maximumOutputIndex = { value: -1 };
10941: for (const items of [state.rawItems, state.items]) {
10942: for (const outputIndex of items.keys()) {
10943: if (outputIndex > maximumOutputIndex.value) {
10944: maximumOutputIndex.value = outputIndex;
10945: }
10946: }
10947: }
10948: const contIndex = shiftedOutputIndex(
10949: maximumOutputIndex.value,
10950: 1,
10951: );
10952: try {
10953: for await (const {
10954: event: ce,
10955: data: cd,
10956: } ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
11870: safeClose();
11871: return;
11872: }
11873: const isAbort =
11874: err instanceof DOMException && err.name === "AbortError";
11875: if (isAbort) {
11876: log.info("openai-responses recall-aware stream aborted");
11877: if (cancelled || signal.aborted) {
11878: if (opts.signal?.aborted && !cancelled) {
11879: safeError(opts.signal.reason);
11880: } else {
11881: safeClose();
11882: }
11883: return;
11884: }
11885: } else {
11886: const category =
11887: err instanceof RecallContinuationFailure
11888: ? err.category
11889: : continuationAttempted
11890: ? (continuationFailureCategory ...
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/src/pipeline.ts</path>
<type>file</type>
<content>
18580: stopAtTerminal: true,
18581: requireCompletedTerminal: true,
18582: }),
18583: };
18584: let jsonFollowUp: Awaited<ReturnType<typeof runRecallFollowUpJSON>>;
18585: try {
18586: jsonFollowUp = followUpRequiresStream
18587: ? await runRecallFollowUpStreamAccumulated(
18588: jsonRecallCtx,
18589: currentModifiedReq,
18590: currentResp,
18591: followUpResult,
18592: recallBlock,
18593: foregroundAbort.signal,
18594: finalRecallRound,
18595: )
18596: : await runRecallFollowUpJSON(
18597: jsonRecallCtx,
18598: currentModifiedReq,
18599: currentResp,
18600: followUpResult,
18601: recallBlock,
18602: ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/cache-stability.e2e.test.ts:
Line 732: // forSession scores by confidence (no/sparse session context).
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/llm-adapter.test.ts:
Line 195: test("replacement-decodes malformed diagnostic UTF-8", async () => {
Line 212: test("replacement-decodes a multibyte code point split by the 64 KiB cap", async () => {
Line 2219: `event: response.output_text.done\ndata: ${JSON.stringify({
Line 2333: event("response.output_text.done", {
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/install-transaction-cleanup.test.ts:
Line 103: it("does not delete a replacement stage while handling publication failure", () => {
Line 105: let replacement = "";
Line 110: replacement = join(root, stage);
Line 111: renameSync(replacement, ...
Found 8 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts:
Line 2447: test("rejects recursive explicit null replacement in the terminal snapshot", async () => {
Line 3170: part: { type: "output_text", text: "sparse finalized text" },
Line 3182: part: { type: "output_text", text: "sparse finalized text" },
Line 3571: test("redacts a sparse call replaced by a terminal item reference", async () => {
Line 3822: content: [{ type: "output_text", text: "final answer" }],
Line 4293: content: [{ type: "output_text", text: "final" }],
Line 6253: ? item.replaceAll('"name":"recall"', '"name":"Read"')
Line 10034: return `<!-- lore-recall:${query.replaceAll(" ", "-")} -->`;
Found 49 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses.test.ts:
Line 1476: expect(text).toContain("event: response.output_text.done");
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-stream.test.ts:
Line 87: event: "response.output_text.done",
Line 89: type: "response.output_text.done",
Line 228: event: "response.output_text.done",
Line 230: type: "response.output_text.done",
Line 310: event: "response.output_text.done",
Line 312: type: "response.output_text.done",
Line 378: test("prefers output_text.done over accumulated deltas", async () => {
Line 405: event: "response.output_text.done",
Line 407: type: "response.output_text.done",
Line 456: event: "response.output_text.done",
Line 458: type: "response.output_text.done",
Line 2247: event: ...
tklkqxytmpkzzryqlolnpvxouropxznp ce88c614c0ae55d229cb605aa7c7369d918d3650 parents=683dff02101f15198b18e3088a0b57dade290056 desc=fix(responses): complete lifecycle reconciliation kvpmnlwnznqxomuzywlvmotqtplywzvm 683dff02101f15198b18e3088a0b57dade290056 parents=df49b0cec904a3f432a0f7f29ea398840d62fe9e desc=fix(responses): bound sparse lifecycle coordinates lplymwvllmznozzrzoroxvnnuymnusxs df49b0cec904a3f432a0f7f29ea398840d62fe9e parents=2cbf40060c67df229731cf1b9e34d5bf22ec2145 desc=fix(responses): preserve limit-crossing state pxrvwsvvkmpoxnsqmrkwrnlqvvkoltwz 2cbf40060c67df229731cf1b9e34d5bf22ec2145 parents=e977b4b1da8f8197c3238466d41de0bccd8eb054 desc=feat(cch): add seeds for Claude Code up to 2.1.272 (#1780) ce88c614c0ae55d229cb605aa7c7369d918d3650
--- tklkqxytmpkzzryqlolnpvxouropxznp ce88c614c0ae55d229cb605aa7c7369d918d3650 fix(responses): complete lifecycle reconciliation --- kvpmnlwnznqxomuzywlvmotqtplywzvm 683dff02101f15198b18e3088a0b57dade290056 fix(responses): bound sparse lifecycle coordinates --- lplymwvllmznozzrzoroxvnnuymnusxs df49b0cec904a3f432a0f7f29ea398840d62fe9e fix(responses): preserve limit-crossing state
<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>
8520: completed("resp_complete_failure"),
8521: ]),
8522: {
8523: onComplete: () => {
8524: completedCalls++;
8525: throw new Error("postResponse failed");
8526: },
8527: onRecall: async () => ({
8528: anchorText: buildAnchor("architecture"),
8529: resultText: "results",
8530: commit: () => committed++,
8531: rollback: () => rolledBack++,
8532: }),
8533: runFollowUp: async () => ({
8534: reader: streamFrom([
8535: created("resp_followup", "gpt-5.6-terra"),
8536: textItem(0, "answer", "msg_answer"),
8537: completed("resp_followup"),
8538: ]).body!.getReader(),
8539: }),
8540: },
8541: );
8542:
8543: const out = await ...
Found 5 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts:
Line 7335: "retains continuation %s state when it crosses the retained-state limit",
Line 7423: "bounds continuation $kind coordinate $coordinate before shifted sparse state mutation",
Line 7598: test("iteratively reconstructs a resource-limited continuation with 125500 content blocks", async () => {
Line 7668: test("computes the continuation offset without spreading 126000 retained item keys", async () => {
Line 7794: test("accounts for terminal Codex continuation usage once when candidate flush exceeds the transaction limit", async () => {
<path>/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts</path>
<type>file</type>
<content>
7640: },
7641: onRecall: async () => ({
7642: anchorText: buildAnchor("large continuation"),
7643: resultText: "results",
7644: commit: () => commits++,
7645: rollback: () => rollbacks++,
7646: }),
7647: runFollowUp: async () => ({ reader: followUp.body!.getReader() }),
7648: },
7649: );
7650:
7651: const out = await drain(client);
7652: const materializedItem = finalizeSpy.mock.calls
7653: .map(([acc]) => acc.rawItems.get(0))
7654: .find((item) => item?.id === "msg_large_continuation");
7655: expect(materializedItem?.content).toEqual(content);
7656: expect(completedResponse?.content).toEqual([]);
7657: expect(completedResponse?.rawOutputItems).toEqual([]);
7658: expect(out.match(/^event: ...
Found 11 matches
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/cli-entity-contract.test.ts:
Line 16: * - F-5: flag-count strings corrected to 11 (+ --json)
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/gemini-stream.test.ts:
Line 397: test("concatenates text deltas across frames + final usage/finishReason", async () => {
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/cache-warmer.test.ts:
Line 1927: test("cost ratio gives reasonable threshold (corrected formula)", () => {
/home/byk/Code/opencode-lore-responses-accumulation/packages/gateway/test/openai-responses-recall-aware-stream.test.ts:
Line 4263: test("rejects output text deltas that differ from the final text", async () => {
Line 4310: test("rejects function argument deltas that differ from the final arguments", async () => {
Line 4537: test("rejects finalized reasoning that contradicts summary 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>
4210: output_index: 0,
4211: item: { type: "reasoning", id: "rs_summary_unfinished", summary: [] },
4212: }),
4213: completed("resp_summary_unfinished"),
4214: ]),
4215: {
4216: onComplete: () => {},
4217: onRecall: async () => ({ anchorText: "", resultText: "" }),
4218: runFollowUp: async () => {
4219: throw new Error("should not run");
4220: },
4221: },
4222: );
4223:
4224: expect(await drain(client)).toContain("response.failed");
4225: });
4226:
4227: test("rejects unfinished reasoning when output_item.done omits summary", async () => {
4228: const client = streamResponsesRecallAware(
4229: streamFrom([
4230: created("resp_summary_field_omitted", "gpt-5.6-terra"),
4231: ...