Repository navigation
core-host: count the three remaining host limits in code points (#1895) - #1898
Conversation
|
Verdict requested for this tip: b7c9079 (tree 5b933ab297a4d2d374264afe1cea9f9648ce3a14, base 148554c) @Birfy review request #1895: three host limits counted UTF-16 units (the memory entry bound 300, a task name 120, a message 20,000), so an emoji cost two and a refusal printed double. Red first on Owner: Dev |
`[...String(text)].length` built an array entry per code point before counting, so a string at the 20,000-code-point message bound cost about 0.9 MB and 1.1 ms just to be refused, and 8M characters cost 352 MB. Step by the UTF-16 width instead: same count for any string, no allocation. The `core-host` doc said every host bound uses the helper; the 600-unit fields of `experience.js` still count UTF-16 units, so the sentence now lists the bounds this change actually puts through it.
b7c9079 to
d56c3ef
Compare
|
Verdict requested for this tip: d56c3ef (tree a54ce02f5a8d174785506218df44d352d386829d, base 148554c) @Birfy review request This tip adds two changes on top of
Owner: Dev |
|
Verdict: PASS at d56c3ef Ran at this tip: Reviewed the live tip, which is Red first (hard requirement): with only the changed sources put back to their base blobs (
Restoring the tip makes all four green again; CI at this tip (13 check-runs): only Scope (19 files): the five host modules plus the new Body metadata held up: |
Fixes #1895
Owner: Dev
Written-by: Dev-1
Reviewer: Reviewer
Claim-Id: 4b9a24ffdc514391bb52adc3ada11c2e
Base: 148554c
Tree: a54ce02f5a8d174785506218df44d352d386829d
Verified commit: 2529c40b975ac6c97b7e4f5b105714142a413d1f (tree above); the pushed head is rebuilt from that same tree by the push path, so the two commits carry identical content
Diff: 19 files, +321/−39
What was missing
Three host limits compared
string.length, which counts UTF-16 units, while#1886/#1888had already settled the Project memory bound on code points. So a fact of 151 emoji read as 302 characters and was refused by a 300-character bound withAn entry holds at most 300 characters; this one has 302.; a 61-emoji task name read as 122 against 120; a 10,001-emoji message read as 20,002 against 20,000.What changed
core/src/host/text.jsnow exportscodePoints(text), which steps by the UTF-16 width instead of spreading the string into an array, so counting allocates nothing and returns the same count for any string. The bounds this change puts through it are:memory.js: the 300-character entry bound and the number its refusal prints; theMEMORY.md4,000 / topic 16,000 file-size check and the size note; and the sizes the memory panel and the review prompt read.schedules.js: the 120-character task name.hooks.js: the 20,000-character message.store.js/project-assistant.js: the two Project memory writers#1888fixed now share the helper instead of each spreading the string inline.The limits and their sentences are unchanged; the number a refusal prints is now the code-point count. The series was regenerated (
patches/ds-bot/0001,0002and the threefiles/mirrors), andpatches/ds-bot/topics.jsonmapssrc/host/text.jsandtest/text.test.jsto0001-core-fixes. The churn in0001/0002beyond the new hunks is generator output (the newtext.jshunks re-anchor later hunks' position hints);checkandcanonicalare both green below.Red first
The four test files at
148554c1with only the new tests copied in and the implementation untouched:# tests 142 / # pass 137 / # fail 5.At the tip those four files with the two Project writer suites are
193/193together; the same commands run in the fullverifybelow.Verified at 2529c40b975ac6c97b7e4f5b105714142a413d1f
git status --porcelainwas empty before and after, andTZ=UTC ARCH_DOCS_BASE=148554c19941d77407df6e1916de8d6d393e359f npm run verifyexited 0:.github/scripts563/563, interop 37/37, live-e2e 24/24; oxlint 0 errors (core 73 warnings, plugin lints 36/9/2/16);arch-docs: OK (19 changed file(s));build-client --checkclean.node scripts/ds-bot-patches.mjs check:ok ds-bot/ = Fei2411/DeepSeek-Bot@2b10c70 (tree 5834c00, v0.1.5)/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).cmpon the threefiles/mirrors (src/host/hooks.js,src/host/project-assistant.js,test/flybot.test.js) against theircore/files: identical.Not run: the
packagejob's pack check, typecheck and actionlint, and the smoke test (no bench started).This is 19 files: 13 are the ticket's own edits, 1 is the hand-maintained classification table, 5 are
generateoutput. The 13:core/src/host/text.js(new),memory.js,schedules.js,hooks.js,store.js,project-assistant.js; the four teststext.test.js,memory.test.js,schedules.test.js,flybot.test.js;docs/subsystems/core-host.md,docs/subsystems/plugin-runtime.md;changelog.d/1895-host-limits-code-points.fixed.md. The 1:patches/ds-bot/topics.json(+3/−1, mapping the two new files to0001-core-fixes), hand-edited, not generated. The 5:0001-core-fixes.patch(+174/−9) and0002-flybot-api-host.patch(+8/−6), where everything beyond the new hunks isgeneratere-anchoring position hints after the newtext.jshunks, and the threefiles/mirrors ofsrc/host/hooks.js,src/host/project-assistant.js,test/flybot.test.js, byte-identical to theircore/files (cmpsame).node scripts/ds-bot-patches.mjs generateon 2529c40b975ac6c97b7e4f5b105714142a413d1f rewrote all 10 patches and 289files/entries, thengit status --porcelainwas empty and HEAD unchanged: every write was byte-identical to what the tree already held, so the empty status means nothing was left uncommitted, not that a generated file is missing. Same fact in one line:node scripts/ds-bot-patches.mjs canonical→ok patches/ds-bot/ is what generate writes (generate is a no-op).Files
core/src/host/text.jscore/src/host/memory.jscore/src/host/schedules.jscore/src/host/hooks.jscore/src/host/store.jscore/src/host/project-assistant.jscore/test/text.test.jscore/test/memory.test.jscore/test/schedules.test.jscore/test/flybot.test.jsdocs/subsystems/core-host.mddocs/subsystems/plugin-runtime.mdchangelog.d/1895-host-limits-code-points.fixed.mdpatches/ds-bot/0001-core-fixes.patchpatches/ds-bot/0002-flybot-api-host.patchpatches/ds-bot/files/src/host/hooks.jspatches/ds-bot/files/src/host/project-assistant.jspatches/ds-bot/files/test/flybot.test.jspatches/ds-bot/topics.json{
"pr": 1898,
"claim": "Dev",
"issue": 1895,
"summary": "Three host limits counted UTF-16 units while #1888 had already put the Project memory bound on code points, so an emoji cost two and a refusal printed double. core/src/host/text.js now exports codePoints(text) and memory.js, schedules.js and hooks.js count through it, with the two Project memory writers sharing the same helper. The entry, file-size, task-name and message bounds now count what a reader sees, and the number a refusal prints is the code-point count.",
"files": [
"core/src/host/text.js",
"core/src/host/memory.js",
"core/src/host/schedules.js",
"core/src/host/hooks.js",
"core/src/host/store.js",
"core/src/host/project-assistant.js",
"core/test/memory.test.js",
"core/test/schedules.test.js",
"core/test/flybot.test.js",
"docs/subsystems/core-host.md",
"docs/subsystems/plugin-runtime.md",
"changelog.d/1895-host-limits-code-points.fixed.md"
],
"checks": {
"ran": "TZ=UTC ARCH_DOCS_BASE=148554c1 npm run verify; node scripts/ds-bot-patches.mjs check; node scripts/ds-bot-patches.mjs canonical; node scripts/ds-bot-patches.mjs generate (git status --porcelain empty, HEAD unchanged)",
"result": "green",
"at": "2529c40b975ac6c97b7e4f5b105714142a413d1f"
},
"next": "none \u2014 ready for review"
}