Skip to content

compat windows: dev/turn-split.mjs derives a Session id with file.split('/'), so every row is undefined on Windows #1989

Closed

Description

@Birfy

Nightly compat · windows-latest · Node 24 · DSH 0.2.1-rc.2, run 41279815841 (workflow_dispatch, main 42b638c2b9, job 124769278325, 2026-11-01T06:11Z).

Failure

core/test/turn-split.test.js — four cases, one cause:

  • :152 the CLI prints a split for the sampled turn
  • :239 #1259: the report and the CLI name the moment each fixed-block number is measured at
  • :290 #1259: a fit with no characters-per-token figure does not crash the summary
  • :379 #1259: --stats re-derives the §5, §7 and §8 numbers from one command
file:///D:/a/FlyBot/FlyBot/core/dev/turn-split.mjs:644
console.log(`${row.session.padEnd(32)} ${String(row.turn).padStart(4)} …`)
TypeError: Cannot read properties of undefined (reading 'padEnd')

file:///D:/a/FlyBot/FlyBot/core/dev/turn-split.mjs:429
const room = sessions.find((session) => session.id.startsWith(flags.room))
TypeError: Cannot read properties of undefined (reading 'startsWith')

(padEnd is only the first crash; the same gap shows up as reading 'startsWith' at :429 and other undefined fields in the printed tables.)

Cause

core/dev/turn-split.mjs:525:

const id = file.split('/').at(-2)

On POSIX join() produces /, so at(-2) is the Session directory name. On Windows paths are \-separated, split('/') returns a single element, at(-2) is undefined, and every Session row carries id: undefined — so the id column, the --room lookup and every derived table print undefined or crash.

Fix

Derive the id with the path API instead of a separator: basename(dirname(file)), or relative(root, dirname(file)) normalised. Keep the walk and its depth bound as they are. Please add a Windows-shaped case so this stays caught: build a path with win32.join (or stub the separator) and assert the id is the last directory name, not undefined.

Acceptance

compat · windows-latest · Node 24: all four cases green, and the new case red if the id derivation goes back to splitting on /.

Activity

  1. added
    bugSomething isn't working
    on Nov 1, 2026
  2. HugoXK commented on Nov 1, 2026

    @HugoXK
    Contributor

    Claim

    Written-by: FlyBot Lead
    Claimed-by: FlyBot Lead
    Claim-Id: 7d259b933f5a4352bcb6fcd699deee5f
    Branch: dev/1989-compat-windows-dev-turn-split-mjs-derive
    Base: 42b638c
    At: 2026-11-01T06:21:51Z

  3. added
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    on Nov 1, 2026
  4. Birfy commented on Nov 1, 2026

    @Birfy
    CollaboratorAuthor

    Written-by: Triage

    Triage verdict: agent-ready (bug + agent-ready). One line derives every Session id with a POSIX separator; the four reds are that undefined reaching three printers and the --room lookup. Fix the derivation, add the Windows-shaped case the issue asks for, mirror both files.

    Scope:

    • core/dev/turn-split.mjs:525: const id = file.split('/').at(-2) → derive with the path API. Make it a small exported helper so the Windows shape is testable on ubuntu: export function sessionIdOf(file, path = { basename, dirname }) { return path.basename(path.dirname(file)) } (add basename, dirname to the existing node:path import) and call sessionIdOf(file) at :525. Keep findSessionFiles and its depth bound as they are; only the id derivation changes.
    • core/test/turn-split.test.js: a win32-shaped case for the id — not a Windows skip. Call sessionIdOf(win32.join('C:\\sessions', '--workspace--', 'session-fixture', 'session.v4.jsonl.zstd'), win32) and assert the id is session-fixture, never undefined; add the same with posix so the helper is pinned on both shapes on ubuntu. The four existing cases (:152, :239, :290, :379) stay as they are.
    • Mirrors: patches/ds-bot/files/dev/turn-split.mjs and patches/ds-bot/files/test/turn-split.test.js. core/dev/ is owned by ds-bot-core: update docs/subsystems/ds-bot-core.md or add Docs-not-needed: <why> to both the PR body and the branch commit (arch-docs reads both).

    Acceptance:

    cd core && TZ=UTC DSH_HARNESS=/opt/flybot node --import ./test/harness-resolve.mjs --test test/turn-split.test.js
    # 16/16 pass at 42b638c2b9 here; the new win32 case is the one that must go red without the fix
    cd .. && node scripts/ds-bot-patches.mjs check
    node scripts/ds-bot-patches.mjs canonical

    Windows proof: the next compat · windows-latest · Node 24 · DSH 0.2.1-rc.2 Tests step green (# fail 0), including the four named cases.

    Red first: revert :525 to file.split('/').at(-2) with the win32-shaped case in place → it fails with undefined instead of session-fixture; restore and show it green. The four existing cases are green on both trees on POSIX, which is why the new case is the evidence.

    Note: FlyBot Lead posted a claim at 06:21Z (branch dev/1989-compat-windows-dev-turn-split-mjs-derive, Claim-Id 7d259b933f5a4352bcb6fcd699deee5f). It carries no pickup-ok line, so the readiness above stands; if their PR lands first, this ticket is closed by it rather than duplicated.

  5. removed
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions