Skip to content

fix(mcp): place Railway log records by their own time in the first-load timeline - #11

Merged
timeleft-- merged 1 commit into
developfrom
claude/issue-335-timeline-order
Nov 5, 2026
Merged

timeleft-- merged 1 commit into
developfrom
claude/issue-335-timeline-order

Conversation

@timeleft--

Copy link
Copy Markdown
Member

Fixes the ordering bug in apps/mcp/scripts/first-load-timeline.mjs, the tool that joins first-load trials with server logs for iaser-ai#335.

What was wrong

railway logs --deployment --json lifts each JSON record's fields to the top level and adds its own timestamp. That is when Railway collected the line, and it collects in batches. The script saw event at the top level and overwrote the record's own at with Railway's timestamp. As a result, records were reordered, and some fell outside the trial window they belonged to.

Change

  • When a record carries a numeric at, the script uses it.
  • Railway's timestamp is now only the fallback, for lines without their own time (for example Starting Container).
  • Records wrapped in a JSON message already kept their own time; that is unchanged.

Verification

  • New test/first-load-timeline.test.ts runs the script on Railway-shaped lines:
    • Three records whose batch timestamps fall after the window and in the wrong order. It failed before the fix (the window showed none of them) and passes after.
    • A line without its own time still falls back to Railway's timestamp.
    • A record wrapped in message keeps its own time.
  • Re-ran the 30 October evidence (local, git-ignored) through the old and the new script:
    • 65 of 98 records had a batch timestamp more than 50 ms from their own time, and up to 13.2 s.
    • Records now sit at their real offsets. For example, the first trial's server/discover is at +0.73 s, not +9.96 s.
    • No per-trial finding changed, so the published Q1 findings stand.
  • pnpm mcp verify passed: 157 tests and 78 browser checks.

🤖 Generated with Claude Code

…ad timeline

`railway logs --deployment --json` lifts each JSON record's fields to the top
level and adds `timestamp`, when Railway collected the line in batches. The
timeline took that branch and replaced the record's own `at` with Railway's
`timestamp`, so records were reordered and some fell outside the trial window
they belonged to. On the 30 October evidence, 65 of 98 records were off by
more than 50 ms, and up to 13.2 s. No per-trial finding changes.

The record's own `at` now wins; `timestamp` remains the fallback for lines
without one. A test drives the script with Railway-shaped lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@yia-mw-agent yia-mw-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helmet-Review-Request: #11 (comment)

Reviewed the full merge-base-to-head diff (base develop 9d9c2ad = merge-base, 2 files) at 78bb0cc. The live head matched at start and before submitting.

No material defects.

  • apps/mcp/scripts/first-load-timeline.mjs: the raw.event branch now keeps a numeric top-level at and falls back to Railway's timestamp only when at is absent. The message-wrapped and edge-log paths are unchanged. This matches the stated cause.
  • apps/mcp/test/first-load-timeline.test.ts: the three cases cover the reordering fix, the fallback and the wrapped-message path. The assertions are specific.

Validation: node --test test/first-load-timeline.test.ts passed 3 of 3. I also ran the pre-fix script (from develop) and the PR script on a Railway-shaped fixture. The old script reported "no card read was observed". The new one placed tools/list at +1.00s and resources/read at +9.50s. I could not run the repo-wide lint and typecheck: dependencies are not installed in this worktree and pnpm is unavailable. CI was still pending when I submitted.

Non-blocking: the at check is typeof === 'number', so an at that arrives as a string would silently fall back to the batch timestamp. The application writes Date.now(), so this is not a concern today.

@timeleft--
timeleft-- merged commit 7c605bb into develop Nov 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants