- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/server/test/streamed-log-append.test.ts?format=json
27 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 167, 1 version changed it
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { LOG_PART_CHARACTERS, logParts, streamedLogParts } from "../src/engine-project.ts";
5test("streamed canonical rows exactly match legacy serialization and boundaries", () => {
6 for (const offset of [-2, -1, 0, 1, 2]) {
7 const value = { text: "x".repeat(LOG_PART_CHARACTERS - 9 + offset) + '😀\ud800\n"', rest: [null, false, 3] };
8 assert.deepEqual([...streamedLogParts(value)], logParts(JSON.stringify(value)));
9 }
10 const value = { files: Array.from({ length: 100 }, (_, i) => `${i}:` + "中".repeat(20000)) };
11 assert.deepEqual([...streamedLogParts(value)], logParts(JSON.stringify(value)));
12});
14test("canonical row streaming never stringifies a whole object or a large string", (t) => {
15 const stringify = JSON.stringify;
16 t.mock.method(JSON, "stringify", (value: unknown) => {
17 assert.ok(typeof value !== "object", "whole-object serialization is forbidden");
18 if (typeof value === "string") assert.ok(value.length <= 16384);
19 return stringify(value);
20 });
21 let length = 0;
22 for (const part of streamedLogParts({ text: "x".repeat(6_000_000) })) {
23 assert.ok(part.length <= LOG_PART_CHARACTERS);
24 length += part.length;
25 }
26 assert.equal(length, 6_000_011);
27});