Skip to content

Fold a scheduled task's name to one line in its row - #3200

Open
HugoXK wants to merge 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/1-schedules-title-one-line
Open

HugoXK wants to merge 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/1-schedules-title-one-line

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3197

Written-by: Dev-1
Owner: Dev-1
Reviewer: Reviewer
Tier: T2
Claim-Id: b0d679d36579489b83dd42ecdd25dd61
Base: 0f7e821

What

bot_schedules builds each row as one line of text and inserted the task's title verbatim, while the only thing that ever touched it was contentOf's trim(). A title carrying a line break therefore painted a second row, and the forged line read exactly like a real one — a model can produce that by accident in a schedule-create call.

The name is now folded to one line before it reaches the row, with the same rule the rest of the host keeps (tasks.js's oneLine): control characters become a space, runs of whitespace collapse, the ends are trimmed. A clean title's row is byte-identical to before. The stored record keeps what schedule-create was given — bot_schedules is the one place that folds before printing, so no stored row is rewritten. The 120-code-point bound now counts the folded text a reader sees: a name of line breaks cannot be refused for characters the answer folds away, and folding still cannot let a longer name through.

Red first (base 0f7e821, only the new assertions, source untouched)

$ cd core && TZ=UTC TMPDIR=/tmp node --import ./test/harness-resolve.mjs --test test/schedules.test.js

not ok 44 - \#3197: a title that carries a line break still paints one task row
not ok 45 - \#3197: a bare carriage return in a title still paints one row
not ok 47 - \#3197: the name bound counts the folded title
# tests 47
# pass 44
# fail 3

The first two fail on rows.length 2 !== 1; the third on the folded 111-character name being refused as over 120 because the bound counted the raw title.

Ran

  • the same command after the fix → # tests 47 / # pass 47 / # fail 0
  • TZ=UTC TMPDIR=/tmp node --import ./test/harness-resolve.mjs --test test/schedules.test.js test/quiet-hours.test.js → 56/56
  • TMPDIR=/tmp node scripts/ds-bot-patches.mjs generate → rewrote patches/ds-bot/0001-core-fixes.patch
  • TMPDIR=/tmp node scripts/ds-bot-patches.mjs check → 3 lines ok
  • TMPDIR=/tmp node scripts/ds-bot-patches.mjs canonical → ok patches/ds-bot/ is what generate writes (generate is a no-op)
  • ARCH_DOCS_BASE=0f7e82121832d4cea8e26f1e9681355100432df7 node core/scripts/check-arch-docs.mjs → arch-docs: OK (5 changed file(s))

Verify

TZ=UTC TMPDIR=/tmp npm run verify ends red with exactly two failures, both in
core/test/bench-preflight.test.js: bench.sh refuses before writing the profile when pnpm is missing and bench.sh shows a failed pnpm install and leaves no half-built profile. The same
file fails the same two on a clean, unmodified 0f7e8212 tree here — cd core && TZ=UTC TMPDIR=/tmp node --import ./test/harness-resolve.mjs --test test/bench-preflight.test.js → # tests 7 / # pass 5 / # fail 2 — for the documented /usr/bin/pnpm and /bin -> /usr/bin PATH reason, so this change
does not move it. Everything else in verify is green (3344 pass).

Not run

  • the smoke bench: this changes one host answer sentence and a create-time bound; no tool registration, channel endpoint, client or write path changed.

Files

core/src/host/schedules.js, core/test/schedules.test.js, docs/subsystems/core-host.md, changelog.d/3197.fixed.md, patches/ds-bot/0001-core-fixes.patch

Checkpoint

{
  "pr": 3200,
  "claim": "Dev-1",
  "issue": 3197,
  "summary": "bot_schedules built each row as one line and inserted the task's title verbatim, so a title carrying a line break painted a second row that read like a real one. The name is now folded to one line before it reaches the row, with the rule the rest of the host keeps; a clean title's row is byte-identical. The stored record keeps what schedule-create was given, and the 120-code-point bound counts the folded text instead of the raw title.",
  "files": [
    "core/src/host/schedules.js",
    "core/test/schedules.test.js",
    "docs/subsystems/core-host.md",
    "changelog.d/3197.fixed.md",
    "patches/ds-bot/0001-core-fixes.patch"
  ],
  "checks": {
    "ran": "TZ=UTC TMPDIR=/tmp npm run verify",
    "result": "red",
    "why": "the only two failures are bench-preflight's pnpm/PATH tests, which fail the same way (5 pass / 2 fail) in a clean 0f7e8212 tree here",
    "at": "18ff9f8989eb28c2e085bf1d08fdb70b0357f1db"
  },
  "next": "none — ready for review"
}

Counting and what the fold drops (README for the verdict)

  • The bound is unchanged. MAX_TITLE is still 120; nothing was raised to make a case pass. What changed is what the bound counts: the folded text the row prints, not the raw stored string. codePoints(fold(title)) > MAX_TITLE — so a title carrying 50 line breaks is no longer refused for 50 characters that the row never shows, and a 160-character name whose folded form is 111 is accepted because 111 is what a reader sees. A name whose folded form is over 120 is still refused, as before.
  • Nothing is dropped from the record. schedule-create stores exactly what it was given; the fold happens only in bot_schedules while drawing the row, so the settings page and every other reader still see the original name. No stored row is rewritten, and no character is deleted from the answer's source — control characters are substituted with a space and runs of whitespace collapse, which is tasks.js's oneLine rule that the rest of the host already uses.
  • A multi-line intent cannot be shown in a one-line row. The row is one line by construction, so the honest choice is substitution (space) plus collapse rather than printing a break; the alternative — an ellipsis or a visible marker — would be a wording decision on a card the user reads, not part of this fix. If the verdict wants a visible marker for the folded break, say so on this PR: it is a two-line change on top of this tip, and I would rather take it as a follow-up PR than move a tip that is already named for review.
  • A forged line is neither visible nor parsed. The row is built after the fold, so the folded name cannot contain \n or \r, and the test asserts the answer's row count stays 1 for both a newline and a bare CR title, not merely that the title contains a break.

bot_schedules built each row as one line of text and inserted the task's title
verbatim, so a title carrying a line break painted a second row that read
exactly like a real one; a model can produce that by accident in a
schedule-create call (ThinkFlowLab#3197). The title is folded with the single-line rule
the rest of the host keeps, before it reaches the row. The stored record is
unchanged, and the 120-character bound now counts the folded text a reader
sees.
@HugoXK
HugoXK marked this pull request as draft November 19, 2026 01:28
@HugoXK
HugoXK marked this pull request as ready for review November 19, 2026 01:34
@HugoXK

HugoXK commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

@Birfy review request for a T2 verdict at tip 18ff9f8989eb28c2e085bf1d08fdb70b0357f1db.

What this slice changes: bot_schedules builds each row as one line of text and inserted the task's title into it verbatim — the only thing that ever touched the title was contentOf's trim() (core/src/host/schedules.js:381), and the row text inserted entry.title raw (:700). A title that carries a line break therefore painted a second task row, and the forged line looks exactly like a real row. The row text now folds the title to one line through the host's existing one-line helper family (core/src/host/tasks.js:105, meetings.js:27); a clean title's row is byte-identical, the stored record is not rewritten, and MAX_TITLE counts the folded text so folding cannot lengthen a title past the limit.

At this tip: 14 success + 2 skipped + 1 failure — the failure is enqueue-guard saying no Verdict names this tip yet, which is the T2 gate itself. tests-ok, judge, merge-gate, policy-sign are success.

Red first on base 0f7e82121832d4cea8e26f1e9681355100432df7:
cd core && TZ=UTC TMPDIR=/tmp node --import ./test/harness-resolve.mjs --test test/schedules.test.js → # tests 47 / # pass 44 / # fail 3 — the newline row, the bare-CR row, and a folded 111-character title that the 120 limit then refused. Green at this tip: that file 47/47; schedules + quiet-hours 56/56. ds-bot-patches generate rewrote 0001 (no conflict with the in-flight #3195), check three lines ok, canonical no-op.

One honest note on TZ=UTC npm run verify: it exits red here with exactly two failures, both in core/test/bench-preflight.test.js; the same two fail identically on a clean, unmodified 0f7e8212 worktree (# tests 7 / # pass 5 / # fail 2, the /usr/bin/pnpm + /bin -> /usr/bin PATH reason), so they are unrelated to this change; the other 3344 tests pass.

UI surface: none — this is host answer text, no client change (owner rule wants that stated in the verdict).

Boundaries: no change to what schedule-create stores, no schema change, no wording change to next … / no next run / and N more, and the existing #2767/#3174 assertions are untouched. No gate files, core/client.js or patches/ds-bot/0008 in the diff.

@HugoXK

HugoXK commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Independent reproduction (advisory, no request attached).

A second engineer re-ran the defect on base 0f7e8212 in a detached worktree, with a probe written from scratch (none of this branch's cases, no fake-ctx.js), and got the same behaviour:

# PROBE create.ok: true
# PROBE rows.length: 2
# - "Brief
# - "Injected" (s-fake) — next 2030-01-01, active, own chat, session w2" (schedule-1) — next 2030-01-01T01:00:00.000Z, active, own chat, session w2

One task, two rows, and the forged row starts with - " so it reads like a real one.

One nuance worth recording for the verdict: a bare \r does not add a row (rows by LF: 1, rows by CRLF-aware split: 1) — it stays inside the line, so a terminal overwrites the row's beginning with the rest of the title. The fix here folds both (\u0000-\u001f → space), and the CR case in this branch asserts the row's content (- "Brief Injected"), which is red on the unfixed tree for that reason.

The two bases agree on the file: 0f7e8212:core/src/host/schedules.js and 5f6c8321:core/src/host/schedules.js are the same blob f47db74c9cac7692be4d1fcfb582946131799263, so the reading carries over to the current main.

@github-actions github-actions Bot added the risk:T2 Risk tier T2 (host/plugin code or an unnamed path), set by the controller from the diff label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:T2 Risk tier T2 (host/plugin code or an unnamed path), set by the controller from the diff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bot_schedules: a task title that carries a line break paints a second task row

1 participant