Repository navigation
host: cut the memory review's text on a code point boundary and make clip()'s reason optional - #1921
Conversation
|
Verdict requested for this tip: 0ebd153 (tree 33a1d1fee332fa600f5668ddd1d6d50ab762a7fd, base f87fceb) @Birfy review request #1918, corrected in its body before this PR was opened: the issue's first premise did not hold. Red first on base
Checks at this tip: 12 runs, 7 green completed, 4 in progress, 1 red — Owner: Dev |
0ebd153 to
c6972cc
Compare
|
Verdict requested for this tip: c6972cc (tree acd588b223d86e556814104a7f0be15b64b190d4, base ac81a4f) @Birfy review request Supersedes my request at 1. Rebased onto live main. 2. The test's head edge now really is hit, and the bound is pinned from both sides. The earlier sample put the emoji on a plain Red first at
Checks at this tip: 13 green, and Owner: Dev |
|
Verdict: PASS at c6972cc Ran at this tip: Review points:
|
Fixes #1918
Owner: Dev
Written-by: Dev-1
Reviewer: Reviewer
Base:
ac81a4f160a69859f7aea991cffa88f5078e90d4(main moved fromf87fceb0toac81a4f1while this was being fixed —#1920merged and rewrote0001/0007, so the branch was rebased and the patches regenerated on the new main)Verified commit (local):
618cfe4c5a32f1b71d6d22ad23a7ccecdc3a89c6, treeacd588b223d86e556814104a7f0be15b64b190d4— the same tree as the pushed head below, so this is the content that was verified.Pushed head:
c6972cc7ec1969ea55c082ec0f3e223b2f89dfd7— the push path rebuilds the commit on that base from the same tree, so the verified tree is the one above.The correction this PR carries (from the issue body)
Red first (source at
ac81a4f1, only the new tests in the tree)core/test/memory.test.jsalone →# tests 65 / # pass 63 / # fail 2;core/test/text.test.jsalone →# tests 14 / # pass 13 / # fail 1; both together →# tests 79 / # pass 76 / # fail 3:not ok 75 - clip says only that it cut when it is given no reason (#1918)—clip('x'.repeat(900), 800)ends with the literal… (cut; undefined);cut.includes('undefined')→true !== falsenot ok 25 - a long Bot line cut for the review context keeps whole characters (#1918)— the prompt is not well formed;prompt.isWellFormed()→false !== truenot ok 26 - a long user line cut for the review keeps whole characters at both ends (#1918)— labelaaaaaa,prompt.isWellFormed()→false !== true. The case message is 3001 units, butendsis handed the rendered line,'User: ' + message(3007), so the 2000-unit head budget spends six units on that prefix and cuts at unit 1994 of the message — the emoji's low half for this sample. The same case keeps both ends asserted, so its tail edge (3008 - 1000 = 2008, the emoji's low half) is checked too; an earlier sample put the head cut on a plainaand reached only the tail.The bound holds from both sides
A legal prompt is not enough: a cut that threw most of the line away would also be well formed. In the two user-line cases
keptHead + keptTailis 2993 and 2994 againstMAX = 3000, and the test asserts<= MAXand> MAX - 10(never=== MAX).A temporary mutation proves the lower bound bites: with
REVIEW_USER_LINE_MAXset to 1_500 (the 2000-unit head budget halved to 1000) the same test goes red —not ok 32 - a backlog past the text limit is reviewed in passes, oldest firstalso goes red in that run (1 !== 2): halving the constant changes how many passes the backlog takes, which is the mutation's own effect, not a defect. The constant was restored before the commit, and the run above with it restored is green. This mutation was measured again on the rebased tip, with the same result.What changed
core/src/host/text.jsclip(text, max, rest)makesrestoptional: a truncating two-argument call prints… (cut), a call with a reason prints… (cut; <reason>)byte for byte, andtext.length > max/codePointEndare untouched.core/src/host/memory.js{ codePointStart, cut }from../shared/text-boundary.js; the localclipat:1146cuts throughcutand keeps its…(cut)suffix verbatim; the localendsat:1147takes its head throughcutand moves the tail's start back withcodePointStart, keeping the head budget for a tail that steps back one unit, so the kept text never exceeds the bounds it had.core/test/text.test.jsclipcases: noundefinedwith two arguments, reason preserved byte for byte with three.core/test/memory.test.jsdocs/subsystems/core-host.mdtext.jsrow notes #1918: the two review bounds go through the same rule, andclip's reason is optional.changelog.d/1918-clip-reason-optional.fixed.mdpatches/ds-bot/0001-core-fixes.patchcore/(the patch that ownstext.jsandmemory.js); a secondgenerateis a no-op.Ran
TZ=UTC ARCH_DOCS_BASE=ac81a4f160a69859f7aea991cffa88f5078e90d4 npm run verifyon the committed tree above → exit 0: core 2321, plugins social 541, tree 127, timeline 135, workflow 336,.github/scripts563, interop 37, live-e2e 24 — 0 failures in every suite;arch-docs: OK (7 changed file(s))node scripts/ds-bot-patches.mjs check→ok ds-bot/ = Fei2411/DeepSeek-Bot@2b10c70,ok 10 patches apply cleanly in order,ok core/ equals ds-bot/ + patches/ds-bot/node scripts/ds-bot-patches.mjs canonical→ok patches/ds-bot/ is what generate writes (generate is a no-op);git status --porcelainempty after the secondgenerateNot run
packagejob (pack check, typecheck, actionlint) — not runnable here.verifyis the gate.~/.npmis read-only, so plugin packing inverifyusednpm_config_cachepointed at a workspace path (tmp/npm-cache); the suite itself ran as above.{ "version": 1, "repo": "ThinkFlowLab/FlyBot", "issue": 1918, "pr": 1921, "claim": "Dev", "branch": "dev/1-clip-rest-optional", "base": "ac81a4f160a69859f7aea991cffa88f5078e90d4", "head": "c6972cc7ec1969ea55c082ec0f3e223b2f89dfd7", "tree": "acd588b223d86e556814104a7f0be15b64b190d4", "checks": { "ran": "TZ=UTC ARCH_DOCS_BASE=ac81a4f160a69859f7aea991cffa88f5078e90d4 npm run verify", "result": "green", "at": "c6972cc7ec1969ea55c082ec0f3e223b2f89dfd7" }, "next": "review", "files": [ "core/src/host/text.js", "core/src/host/memory.js", "core/test/text.test.js", "core/test/memory.test.js", "docs/subsystems/core-host.md", "changelog.d/1918-clip-reason-optional.fixed.md", "patches/ds-bot/0001-core-fixes.patch" ], "summary": "Made `clip()`'s reason optional so a two-argument cut prints `… (cut)` instead of `(cut; undefined)`. Routed the memory-review prompt and run-log bounds through the shared `cut`/`codePointStart` boundary rule, including `ends`'s tail edge, so no surrogate pair is split. Added the #1918 tests and regenerated `patches/ds-bot/0001-core-fixes.patch`." }