Skip to content

OpenConceptLab/ocl_issues#3068 | Send a project's log only once its saved log has loaded - #137

Merged
snyaggarwal merged 10 commits into
mainfrom
issues#3068
Nov 24, 2026
Merged

snyaggarwal merged 10 commits into
mainfrom
issues#3068

Conversation

@paynejd

@paynejd paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member

Closes OpenConceptLab/ocl_issues#3068.

The API replaces a project's saved log with the one the Mapper sends (MapProjectLogsView.create). The Mapper sent the whole log from projectLog (a download, for example) and from every save, without waiting for the saved log to load. So a download or a save soon after opening a project, or any save after the log read had failed, replaced the project's history with only what that page had logged.

What changes

  • projectLogSync.js (new):
    • createProjectLogsLoader holds the project's log until the saved one has loaded. canSend(url) is true once it has. Otherwise it starts a read, and the entry goes out with the saved log once that loads.
    • mergeSavedLogs puts the page's entries above the saved ones, per row and for the project. Row logs the API kept as a list are kept by index.
  • Reading the saved log: it now goes through requestWithCapacityRetry, like the log's POST, so a 429 or a 502–504 settles or is retried instead of hanging or throwing. A failed read is read again the next time the page wants to send. While an entry waits, it's also retried after 10 s, 30 s, 90 s, then every 2 minutes, 10 times in all.
  • One page per project: a page left behind (the project reopened in the same tab) stops its read and sends nothing, so its older copy can't replace the newer page's.
    • A reopen by the same route stops it as soon as the new page mounts.
    • A reopen by another route to the same project stops it once the new page has the project's URL from the API, going by the order the pages opened.
    • A page left before its log loaded still reads and sends what it held back, as a save on leave does, if the project isn't open again.
  • Opened: it's added when the saved log loads, as before. The merged log is posted on load only if an entry was held back. Before this change, Opened never went out by itself (it ran where project was still null), so a plain open still sends nothing.

Tests

  • __tests__/projectLogSync.test.js drives the loader with a fake read and POST:
    • a download before the read returns;
    • a save before it returns;
    • a failed read, read again on the next entry;
    • a failed read retried while an entry waits, and the retries running out;
    • one read at a time;
    • a page left behind, by the same route and by another route, and an old page whose details come back late;
    • a page left before its log loaded;
    • a new project;
    • merging empty and list-shaped saved logs.
  • Source checks on MapProject.jsx: both log POSTs go through the loader's check, the page marks when it opens, and the saved log is read only through the loader.
  • npm run test:all: 736 unit and 13 integration tests pass, after merging main with Mapper: with a bridge algorithm, the bridge probe re-reads the mapped-sources list on every project change, and the target's read repeats it ocl_issues#3064. ESLint is clean.

Checked in a real browser against a local mock API (no outside requests): the dev build of this branch and of main, headless, with the log read held 8 s. The saved log had two project entries and two row entries.

Before the read returns main: saved log afterwards this branch
Download → Download CSV ["downloaded"], row logs {} ["Opened", "downloaded", "Saved", "Created"], rows kept
Save ["Updated"], row logs {} ["Opened", "Updated", "Saved", "Created"], rows kept
First read answers 500, then Download (dev build: the read's callback throws) read again at the Download; full history kept

Left for the server (OpenConceptLab/ocl_online#751): because each POST replaces the whole log, a few entries made in a narrow window can still be lost. That covers leaving and reopening a project in the same tab before its log loads (the left page's held entries aren't handed over), a reload in that window, and an old page's POST still retrying after a reopen. None of these can replace the saved history with one page's entries. An endpoint that appends entries removes them.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AaZ4qVXohXhqMLGigP4RHV

paynejd and others added 9 commits November 23, 2026 17:54
…e its saved log has loaded

The API replaces a project's saved log with the one the Mapper sends. A
download or a save before the saved log had loaded, or any save after the
log read failed, sent only what the page had logged, and the project's
history was gone. Now the page sends nothing until the saved log loads.
Entries made before then stay on the page and go with the saved log once it
loads. The read settles a throttled or failed answer, and a failed read is
read again when the page next wants to send the log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVXohXhqMLGigP4RHV
…ry waits, send nothing from a page the project has been reopened past, and keep row logs saved as a list

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVXohXhqMLGigP4RHV
…it opens, and a waiting entry keeps the read retrying

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVXohXhqMLGigP4RHV
…ver the URL wrote it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVXohXhqMLGigP4RHV
…to the download test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVXohXhqMLGigP4RHV
…tten, less leading zeros

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVXohXhqMLGigP4RHV
…ject URL and the order pages opened

A page's place now comes from when it mounted and the project URL the API
returns, so any URL form that reaches the same project shares one key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVXohXhqMLGigP4RHV
… page left behind at once; other routes to the project stop it when their details arrive

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVXohXhqMLGigP4RHV
@paynejd

paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 1 (codex-cli 0.169.0, commit 5c84326)

Verdict: findings (4 finding(s)).

  • F1.1 P1 src/components/map-projects/MapProject.jsx:1933: A log read that finishes after unmount can overwrite entries from the reopened project.
  • F1.2 P1 src/components/map-projects/projectLogSync.js:45: A failed read can leave an already queued log entry unsent indefinitely.
  • F1.3 P1 src/components/map-projects/MapProject.jsx:1921: Unmount cancels the log read needed to record a successful autosave on leave.
  • F1.4 P2 src/components/map-projects/projectLogSync.js:10: The merge discards saved row history stored as a nonempty array.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "full",
  "commit": "5c84326c0e259b92b2b594d44c6bd10534689403",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "F1.1",
      "severity": "P1",
      "tag": null,
      "file": "src/components/map-projects/MapProject.jsx",
      "line": 1933,
      "claim": "A log read that finishes after unmount can overwrite entries from the reopened project.",
      "scenario": "Download while the first log GET is pending, leave, reopen the same project, and download again. If the reopened page posts its log before the old GET returns its earlier snapshot, the unmounted page still posts that snapshot with its own queued download. The server replaces the log and erases the reopened page's download entry.",
      "action": "Coordinate log reads and writes across mounts of the same project so queued entries are merged into the active history before a replacement POST.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.2",
      "severity": "P1",
      "tag": null,
      "file": "src/components/map-projects/projectLogSync.js",
      "line": 45,
      "claim": "A failed read can leave an already queued log entry unsent indefinitely.",
      "scenario": "Download once while the initial log GET is pending. If that GET returns a transient 500, the loader leaves the download queued and starts no retry. The download stays absent from the saved history even after the server recovers, unless the user takes another action that sends a log.",
      "action": "Schedule a retry with backoff when a failed read leaves a pending write. Test a failure that arrives after the download has already been queued.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.3",
      "severity": "P1",
      "tag": null,
      "file": "src/components/map-projects/MapProject.jsx",
      "line": 1921,
      "claim": "Unmount cancels the log read needed to record a successful autosave on leave.",
      "scenario": "Edit a row while the initial log GET is backing off after a 503, then navigate away before autosave fires. The project data saves on leave, but unmount cancels the read and prevents the save from starting another one. The row's audit entry and the Auto Saved entry never reach the server.",
      "action": "Keep the leave-save entries in project-level log sync until they can be merged and posted, even if the page has unmounted.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.4",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/projectLogSync.js",
      "line": 10,
      "claim": "The merge discards saved row history stored as a nonempty array.",
      "scenario": "A project has `row_logs` stored as `[[{\"action\":\"approved\"}]]` through the logs API. The previous Mapper displayed and preserved row 0's history. This merge turns it into `{}`, and the next download or save replaces the stored row history with the empty object.",
      "action": "Preserve populated array entries by row index when normalizing saved row logs. Add a test with a nonempty array.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

Replies

Pass 1 replies (fixes in 132f5f7)

  • F1.1 P1, fixed. The loader keeps, per project URL, the page that last opened it. A page left behind whose project has been opened again in this tab stops its read and sends nothing, so its older copy can't replace the newer page's log. Test: "a page left behind sends nothing once the project is open in a newer page".
  • F1.2 P1, fixed. A failed read with an entry waiting is read again after 10 s, 30 s and 90 s; after those, the next entry starts them again. Tests: "a read that fails while an entry waits is read again after a wait", and the one about running out of waits.
  • F1.3 P1, fixed. The read is no longer cancelled when the page unmounts, only when the project is opened again. A save on leave before the log loaded still reads, merges and sends its entries. Test: "a page left before its log loaded still sends what it held back, if the project isn't open again".
  • F1.4 P2, fixed. Saved row logs kept as a list are kept by row index, as the old code's object spread did. Covered in the mergeSavedLogs test.

@paynejd

paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 2 (codex-cli 0.169.0, commit 132f5f7)

Verdict: findings (5 finding(s)).

  • Prior F1.1: regressed
  • Prior F1.2: unresolved
  • Prior F1.3: resolved
  • Prior F1.4: resolved
  • F2.1 P1 src/components/map-projects/projectLogSync.js:71: A late response from an old page can disable logging on the current page.
  • F2.2 P1 src/components/map-projects/projectLogSync.js:49: Reopening a project discards its queued audit entries.
  • F2.3 P1 src/components/map-projects/MapProject.jsx:1947: A deferred log write can still overwrite history from the reopened page.
  • F2.4 P1 src/components/map-projects/projectLogSync.js:56: The loader can stop retrying before the API recovers and leave the history blank or queued entries unsent.
  • F2.5 P1 src/components/map-projects/MapProject.jsx:468: Reloading after a successful save can silently drop the queued audit entries.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "verify",
  "commit": "132f5f7890dcd1907310cc0c4026a6778b5e61b7",
  "verdict": "findings",
  "prior": [
    {
      "id": "F1.1",
      "status": "regressed"
    },
    {
      "id": "F1.2",
      "status": "unresolved"
    },
    {
      "id": "F1.3",
      "status": "resolved"
    },
    {
      "id": "F1.4",
      "status": "resolved"
    }
  ],
  "findings": [
    {
      "id": "F2.1",
      "severity": "P1",
      "tag": null,
      "file": "src/components/map-projects/projectLogSync.js",
      "line": 71,
      "claim": "A late response from an old page can disable logging on the current page.",
      "scenario": "Open a project, leave while its detail request is pending, then reopen it. If the reopened page starts its log read before the original detail request returns, the original page registers itself as the latest. The reopened page discards its log response and never sends audit entries for subsequent downloads or saves.",
      "action": "Determine which page is latest from navigation order. Prevent an older page's detail response from replacing the current page's registration.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.2",
      "severity": "P1",
      "tag": null,
      "file": "src/components/map-projects/projectLogSync.js",
      "line": 49,
      "claim": "Reopening a project discards its queued audit entries.",
      "scenario": "Approve a row while the log read is pending, leave to trigger autosave, then reopen the project. The reopen waits for the data save and shows the approved row. If the old log read is still pending, the replacement page takes over without inheriting the approval or Auto Saved entries. Both entries are lost.",
      "action": "Hand unsent entries to the reopened page and merge them with its successful log read. Test that the reopened page persists the entries from the leave save.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.3",
      "severity": "P1",
      "tag": null,
      "file": "src/components/map-projects/MapProject.jsx",
      "line": 1947,
      "claim": "A deferred log write can still overwrite history from the reopened page.",
      "scenario": "Download while the log read is pending, then leave. The read finishes and the old page's merged POST gets a transient 503. During its retry wait, reopen the project and download again. The new page saves its entry. The old page then retries its whole-log payload and erases the new download from the saved history.",
      "action": "Coordinate log reads and writes per project across page instances. Ensure the reopened page reads after any earlier write settles, and carry forward entries from a write that failed.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.4",
      "severity": "P1",
      "tag": null,
      "file": "src/components/map-projects/projectLogSync.js",
      "line": 56,
      "claim": "The loader can stop retrying before the API recovers and leave the history blank or queued entries unsent.",
      "scenario": "The first log read returns 500 and the user opens the project history. The panel stays empty after the API recovers because viewing it queues no write. If the user instead downloads during the read and the endpoint returns 500 for just over 130 seconds, all three retries run before recovery and the download remains unsent until another write.",
      "action": "Retry transient failures during a read-only visit, and keep retrying with a capped delay while entries are queued. Honor the server's retry time when it provides one.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.5",
      "severity": "P1",
      "tag": null,
      "file": "src/components/map-projects/MapProject.jsx",
      "line": 468,
      "claim": "Reloading after a successful save can silently drop the queued audit entries.",
      "scenario": "Save a row change while the log read is slow. Once the Mapper reports success, reload the tab before the log response comes back. The unload guard sees the data save as finished, so it gives no warning. The reload destroys the in-memory queue, leaving the saved row change without its audit entries.",
      "action": "Persist queued entries across reloads and clear them only after the merged log write succeeds.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

Replies

Pass 2 replies (fixes in b6ff0cf)

  • F2.1 P1, fixed (a regression from F1.1's fix). A page now takes its project's log when it mounts, so mount order, which follows navigation, decides the latest page. A late project-details answer can no longer take it back. Test: "an old page whose project details come back late doesn't take the project back".
  • F2.4 P1, fixed for queued entries. While an entry waits, a failed read is retried after 10 s, 30 s, 90 s, then every 2 minutes, 10 times in all. The next entry starts them again. requestWithCapacityRetry already honours Retry-After on 429s and retries 502–504 and network errors within each read. A visit that only reads isn't retried after a 500: before this change that read threw and the panel stayed empty too, and the shared helper doesn't retry a 500 on purpose ("retrying it only adds load").
  • F2.2, F2.3, F2.5 P1, accepted as out of scope.
    • The cases: a page left before its log loaded, then the project reopened in the same tab (F2.2); an old page's log POST still retrying after a reopen (F2.3); a reload in the window before the log loads (F2.5).
    • Each can lose the entries made in that window. None can replace the saved history with the page's entries alone, which is what the ticket fixes.
    • The API replaces the whole log on every POST, so several writers to one project can't be fully coordinated from the client: the same holds today for two tabs on one project. Handing entries between pages or persisting a queue across reloads would add a cross-page protocol for a narrow window.
    • The real fix is server-side: an endpoint that appends entries instead of replacing the log. Recommended as a follow-up ticket.

@paynejd

paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 3 (codex-cli 0.169.0, commit b6ff0cf)

Verdict: findings (2 finding(s)).

  • Prior F1.1: regressed
  • Prior F1.2: unresolved
  • Prior F1.3: resolved
  • Prior F1.4: resolved
  • Prior F2.1: resolved
  • Prior F2.2: unresolved
  • Prior F2.3: unresolved
  • Prior F2.4: unresolved
  • Prior F2.5: unresolved
  • F3.1 P2 src/components/map-projects/MapProject.jsx:348: Different URLs for the same project can let a stale log read overwrite newer history.
  • F3.2 P2 src/components/map-projects/MapProject.jsx:1927: The log loader can retry before the server's Retry-After deadline and exhaust its retry budget while still throttled.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "verify",
  "commit": "b6ff0cf34c831b1248dc2fd7bd5d1e522621795c",
  "verdict": "findings",
  "prior": [
    {
      "id": "F1.1",
      "status": "regressed"
    },
    {
      "id": "F1.2",
      "status": "unresolved"
    },
    {
      "id": "F1.3",
      "status": "resolved"
    },
    {
      "id": "F1.4",
      "status": "resolved"
    },
    {
      "id": "F2.1",
      "status": "resolved"
    },
    {
      "id": "F2.2",
      "status": "unresolved"
    },
    {
      "id": "F2.3",
      "status": "unresolved"
    },
    {
      "id": "F2.4",
      "status": "unresolved"
    },
    {
      "id": "F2.5",
      "status": "unresolved"
    }
  ],
  "findings": [
    {
      "id": "F3.1",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/MapProject.jsx",
      "line": 348,
      "claim": "Different URLs for the same project can let a stale log read overwrite newer history.",
      "scenario": "Open project 9 through a URL ending in /09/, download while the log read is pending, then reopen it through /9/ and download again. Both routes resolve to the same project, but the pages claim different keys. If the old read returns a snapshot taken before the reopened page posted, the old page can replace the log and erase the newer download.",
      "action": "Claim ownership at mount using a normalized project ID that matches the API's integer lookup, and test reopening through an equivalent URL.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F3.2",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/MapProject.jsx",
      "line": 1927,
      "claim": "The log loader can retry before the server's Retry-After deadline and exhaust its retry budget while still throttled.",
      "scenario": "A download is queued when the log GET receives a 429 asking the client to wait 20 minutes. The shared helper returns a retry time because the delay exceeds its five-minute cap. The Mapper discards that time, sends another GET after 10 seconds, and can use up all ten retries before the endpoint allows another read. The download remains unsent after recovery until another log write triggers a read.",
      "action": "Pass the helper's retry time to the loader and defer both scheduled and user-triggered reads until that deadline.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

Replies

Pass 3 replies (fix in afd07e2). No P0 or P1 open after 3 passes, so the defect passes stop here. The "unresolved" and "regressed" statuses on earlier findings refer to the cases accepted in the pass 2 replies (F2.2, F2.3, F2.5, and F2.4's read-only visit) and to F3.1 below.

  • F3.1 P2, fixed. A page takes its project's log by the numeric project id, so /09/ and /9/, or another owner URL for the same project, are one project. Source check added.
  • F3.2 P2, accepted. A 429 whose Retry-After runs past the shared helper's 5-minute cap returns early, and the loader's next tries can come before that deadline. Each is one GET that's refused again. If the ten run out, the next entry starts them again. Carrying the helper's retryAt through the loader would add state for a throttle window the log read isn't known to get.

@paynejd

paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Simplification review (Claude subagent, Sonnet 5.5, commit afd07e2)

Verdict: findings (6 finding(s)).

  • S1 None src/components/map-projects/projectLogSync.js:37: The delayMs and maxRetries options on createProjectLogsLoader are set only by tests, to shorten waits. Production never overrides them. This is injectable config nobody sets.
  • S2 None src/components/map-projects/projectLogSync.js:50: The setTimeout retry in finish() sets busy=true, then resets it inside the timer before calling load(), which sets it again.
  • S3 None src/components/map-projects/__tests__/projectLogSync.test.js:187: 'one read at a time' repeats the one-read behavior already asserted in the download-before-read and save-before-read tests.
  • S4 None src/components/map-projects/__tests__/projectLogSync.test.js:198: 'a read that throws counts as failed' overlaps the failed-read test; the try/catch plus .catch are two layers for one outcome.
  • S5 None src/components/map-projects/__tests__/projectLogSync.test.js:215: 'a new project has no saved log to wait for' only checks that loaded:true makes canSend return true.
  • S6 None src/components/map-projects/__tests__/projectLogSync.test.js:253: The three MapProject source-reading tests each pin an implementation detail.
findings.json
{
  "reviewer": "claude subagent",
  "perspective": "simplify",
  "mode": "full",
  "commit": "afd07e2cf6fd76ff8c5704f04491698e3d272778",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "S1",
      "severity": null,
      "tag": "shrink",
      "file": "src/components/map-projects/projectLogSync.js",
      "line": 37,
      "claim": "The delayMs and maxRetries options on createProjectLogsLoader are set only by tests, to shorten waits. Production never overrides them. This is injectable config nobody sets.",
      "scenario": null,
      "action": "Make the defaults module constants. In the tests, use fake timers (node:test mock.timers) instead of passing delayMs/maxRetries.",
      "lines_delta": -2,
      "confidence": "low"
    },
    {
      "id": "S2",
      "severity": null,
      "tag": "shrink",
      "file": "src/components/map-projects/projectLogSync.js",
      "line": 50,
      "claim": "The setTimeout retry in finish() sets busy=true, then resets it inside the timer before calling load(), which sets it again.",
      "scenario": null,
      "action": "Fold the retry into a helper or drop the line busy = true before the timer.",
      "lines_delta": -1,
      "confidence": "low"
    },
    {
      "id": "S3",
      "severity": null,
      "tag": "dup-test",
      "file": "src/components/map-projects/__tests__/projectLogSync.test.js",
      "line": 187,
      "claim": "'one read at a time' repeats the one-read behavior already asserted in the download-before-read and save-before-read tests.",
      "scenario": null,
      "action": "Delete the test and assert read call count === 1 in the 'a download before the log read returns' test.",
      "lines_delta": -10,
      "confidence": "medium"
    },
    {
      "id": "S4",
      "severity": null,
      "tag": "dup-test",
      "file": "src/components/map-projects/__tests__/projectLogSync.test.js",
      "line": 198,
      "claim": "'a read that throws counts as failed' overlaps the failed-read test; the try/catch plus .catch are two layers for one outcome.",
      "scenario": null,
      "action": "Drop the synchronous try/catch in load(); use Promise.resolve().then(() => read(url, isSuperseded)). Merge the throw test into the failed-read test.",
      "lines_delta": -12,
      "confidence": "medium"
    },
    {
      "id": "S5",
      "severity": null,
      "tag": "dup-test",
      "file": "src/components/map-projects/__tests__/projectLogSync.test.js",
      "line": 215,
      "claim": "'a new project has no saved log to wait for' only checks that loaded:true makes canSend return true.",
      "scenario": null,
      "action": "Delete the test.",
      "lines_delta": -5,
      "confidence": "low"
    },
    {
      "id": "S6",
      "severity": null,
      "tag": "dup-test",
      "file": "src/components/map-projects/__tests__/projectLogSync.test.js",
      "line": 253,
      "claim": "The three MapProject source-reading tests each pin an implementation detail.",
      "scenario": null,
      "action": "Merge the three source tests into one test that parses MapProject once.",
      "lines_delta": -12,
      "confidence": "low"
    }
  ]
}

Replies

Simplification review (Claude subagent, Sonnet 5.5, commit afd07e2): 6 items.

  • S1 shrink, declined: injecting the wait keeps the tests runner-agnostic, as the repo's test README asks (it avoids node:test's own mocks); fake timers would need node:test's mock.timers.
  • S2 shrink, declined: busy during the wait is what stops an entry that arrives mid-wait from starting a second read alongside the timer's.
  • S3 dup-test, applied in 013beb6: the one-read-at-a-time check is folded into the download test.
  • S4 dup-test, declined: a deferred read would start the read a microtask later, and the tests rely on it starting at once (reads counted right after the entry). The throw test covers the rejection path, the failed-read test the null answer.
  • S5 dup-test, declined: it pins that a new project never reads (read fails the test if called).
  • S6 dup-test, declined: the three source checks each name a separate contract (sends go through the check, the key, the read path).

@paynejd

paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits after pass 3 (codex-cli 0.169.0, commit 013beb6)

Verdict: findings (2 finding(s)).

  • FC.1 P2 src/components/map-projects/MapProject.jsx:349: Reopening a project through its canonical URL can discard a queued log entry from an equivalent URL.
  • FC.2 P2 src/components/map-projects/MapProject.jsx:349: Converting project IDs to JavaScript numbers can make two distinct database IDs share a loader key.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "013beb6057e2072966827431ff362ac6ac870320",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "FC.1",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/MapProject.jsx",
      "line": 349,
      "claim": "Reopening a project through its canonical URL can discard a queued log entry from an equivalent URL.",
      "scenario": "Open project 7 at `/users/alice/map-projects/007/` and download while the saved log is still loading. Return to the project list and select the same project at `/users/alice/map-projects/7/`. The new page claims the shared key, so the old page discards its successful read and the new page never receives the queued download entry.",
      "action": "Transfer buffered entries to the new loader when it takes over the project, and include them in its merged log without allowing the old loader to post a stale snapshot.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "FC.2",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/MapProject.jsx",
      "line": 349,
      "claim": "Converting project IDs to JavaScript numbers can make two distinct database IDs share a loader key.",
      "scenario": "Projects with IDs `9007199254740992` and `9007199254740993` are distinct 64-bit database IDs, but both produce the same key. If the user opens the second while the first has a queued log entry, the second cancels the first loader and that entry is lost.",
      "action": "Normalize valid decimal IDs as strings by removing leading zeros while preserving all remaining digits.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

Replies

Reply to the final check (fix in 3644226)

  • FC.1 P2, accepted: the F2.2 case (entries held back by a page left before its log loaded are dropped when the project reopens), reached through an equivalent URL. Same reason as in the pass 2 replies; the server-side fix is OpenConceptLab/ocl_online#751.
  • FC.2 P2, fixed. The key is the route's id as a string, less leading zeros, so ids past 2^53 stay distinct. The test checks the rule on 007, 7, 0 and two adjacent 64-bit ids.

@paynejd

paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Codex check of commit 3644226 (codex-cli 0.169.0)

Verdict: findings (1 finding(s)).

  • Prior FC.1: unresolved
  • Prior FC.2: regressed
  • FC2.1 P2 src/components/map-projects/MapProject.jsx:349: The new key gives an encoded-tab URL and its canonical URL separate loaders for the same project, letting the old page overwrite newer log entries.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "3644226aa118a52443a17c06b27481755049b7e6",
  "verdict": "findings",
  "prior": [
    {
      "id": "FC.1",
      "status": "unresolved"
    },
    {
      "id": "FC.2",
      "status": "regressed"
    }
  ],
  "findings": [
    {
      "id": "FC2.1",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/MapProject.jsx",
      "line": 349,
      "claim": "The new key gives an encoded-tab URL and its canonical URL separate loaders for the same project, letting the old page overwrite newer log entries.",
      "scenario": "Open project 7 at `/users/alice/map-projects/7%09` and download while its log read is pending. Reopen `/users/alice/map-projects/7` in the same tab and make another download. React Router decodes `%09` to a tab, and the browser strips it from the API request, so both pages load project 7. The old key superseded the first loader. With the new keys, if the second page posts first and the first page's stale read returns afterward, the first page replaces the saved log and erases the second download entry.",
      "action": "Strip ASCII tabs and line breaks as the browser's request URL parser does before removing leading zeros. Keep the ID as a string and test that reopening via the canonical URL supersedes the old loader.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

Replies

Reply to the second final check (fix in 23efcf4)

  • FC2.1 P2, fixed by changing the key. Normalizing the route's id can't cover every URL form that reaches one project. The loader now keys the latest page by the project URL the API returns, and decides which page is newer by the order pages mounted (opened() in a mount effect). A page registers when its project details arrive, unless a page opened later already holds the project. This keeps F2.1's fix (a late old page can't take the project back) and covers F3.1, FC.2 and FC2.1 together. The route-id key and its normalization are gone.
  • FC.1 P2: still accepted, as before.

@paynejd

paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Codex check of commit 23efcf4 (codex-cli 0.169.0)

Verdict: findings (1 finding(s)).

  • Prior FC2.1: regressed
  • FC3.1 P1 src/components/map-projects/projectLogSync.js:73: Waiting for project details to supersede the old page lets its stale log overwrite entries saved by the reopened page.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "23efcf436a61aa646dcb6168b87e7ab80f42ad99",
  "verdict": "findings",
  "prior": [
    {
      "id": "FC2.1",
      "status": "regressed"
    }
  ],
  "findings": [
    {
      "id": "FC3.1",
      "severity": "P1",
      "tag": null,
      "file": "src/components/map-projects/projectLogSync.js",
      "line": 73,
      "claim": "Waiting for project details to supersede the old page lets its stale log overwrite entries saved by the reopened page.",
      "scenario": "Download from a saved project while its log read is pending, then leave and reopen the same project in the same tab. If the old log read finishes before the reopened page receives its project details, the old page starts a full-log POST. If that POST is delayed until after the reopened page has read the log and saved a new entry, the API replaces the newer log and drops that entry. In 3644226, the reopened page claimed the project at mount and prevented the old POST in this sequence.",
      "action": "Restore mount-time supersession using a project ID key that normalizes API-equivalent route spellings without losing precision. Add a test where the old log read finishes after the new page mounts but before it receives project details.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

Replies

Reply to the third final check (fix in b8666e9)

  • FC3.1 P1, fixed. The page takes both: its route when it mounts, so a reopen by the same route stops the page left behind at once, before the new page has its project details; and the API's project URL when its details arrive, by mount order, for any other route to the same project. Tests: "a reopen stops the page left behind at once, before the new page has its project details" and "a reopen by another route to the same project stops the page left behind once its details arrive".
  • Where this stops. Every POST replaces the whole log, so two pages on one project, or two tabs as today, can still race in some order and drop a few entries from a narrow window. The saved history is never replaced with one page's entries alone. Closing the rest needs the server-side append, OpenConceptLab/ocl_online#751. After this check, further ordering cases of that kind go to #751, not this PR.

@paynejd

paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Codex check of commit b8666e9 (codex-cli 0.169.0)

Verdict: findings (1 finding(s)).

  • Prior FC3.1: resolved
  • FC4.1 P2 src/components/map-projects/projectLogSync.js:54: A failed reopen can permanently discard pending log entries from the previous page.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "b8666e926317de2a2586212b2c0565d210ccdbcf",
  "verdict": "findings",
  "prior": [
    {
      "id": "FC3.1",
      "status": "resolved"
    }
  ],
  "findings": [
    {
      "id": "FC4.1",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/projectLogSync.js",
      "line": 54,
      "claim": "A failed reopen can permanently discard pending log entries from the previous page.",
      "scenario": "Download while the saved-log read is pending, leave, and reopen the same route. If the reopened page's project-details request fails, the original page discards its successful log read and the download entry is lost. At 23efcf4 the original page would have sent the entry with the saved history. The reopened page never reads or posts logs in this scenario.",
      "action": "Keep the immediate pause on a same-route reopen, but retain the pending entries until the new loader can take them over. If opening fails, let the original loader resume and send them with the saved history.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

Replies

Reply to the fourth final check (no change)

  • FC3.1: resolved.
  • FC4.1 P2, accepted. A failed reopen leaves the entries held by the page left behind unsent. It's the same hand-off case as F2.2 and FC.1, in another order: passing entries between pages is left to the server-side append (OpenConceptLab/ocl_online#751). The saved history is kept.

@paynejd
paynejd requested a review from snyaggarwal November 24, 2026 11:55
@paynejd

paynejd commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Codex check of the merge with main, which brought in OpenConceptLab/ocl_issues#3064 (codex-cli 0.169.0, commit 46471c2)

Verdict: clean (0 finding(s)).

findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "46471c22a0445a364897cf1e98c8c65e634a6031",
  "verdict": "clean",
  "prior": [],
  "findings": []
}

The merge's one conflict was resolved by hand; the full test suite and ESLint pass after it.

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review of 46471c2: ready to merge. No blocking findings, four optional nits inline.

I traced the loader through MapProject.jsx, MapProjectRoute/getPageKey (one MapProject instance per project page, kept only for new to created), requestWithCapacityRetry and APIService.request:

  • Every postProjectLogs call now goes through canSend or the loader's send. A save or download before the read returns is held back and merged above the saved history, so the bug in ocl_issues#3068 (one page's entries replacing the saved log) is closed.
  • The loader is built from the first render's closures, but they only touch refs, setters and user, so nothing goes stale. The opened effect is declared before the effect that fetches the project, so the route is registered before load().
  • A new project starts as loaded, and a create followed by history.push keeps the same instance, so a new project's first logs still go out at once.
  • The page-left-behind races that remain, after load, are the ones the PR body hands to ocl_online#751.

CI passes (lint and tests).

The nits are one robustness gap (a hard 4xx on the read keeps the session's log from ever being sent, with nothing visible), one retry-counter reset that weakens the backoff during a busy run, a module comment that claims more than the code does, and brittle source-text tests. None is a reason to hold the merge.

…timer and warns once; an entry made while a retry waits keeps the backoff; comment scoped to pages left before load; MapProject checks use the syntax tree

- savedLogsFromResult (projectLogSync.js) turns a read's result into the saved log, null (a failure worth a wait) or false (a 4xx refusal). A refused read is read again only when the page next wants to send.
- The loader warns once when an entry waits on a read that was refused or ran out of waits.
- canSend resets the retry count only when no read or retry is pending.
- The MapProject source checks compare syntax-tree nodes with whitespace ignored, and tie the opened() route to the URL fetchAndSetProject reads.

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

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving at 6ddb360. The four nits from my earlier review are fixed in that commit, and CI (lint and tests) passes.

@snyaggarwal
snyaggarwal merged commit 7d9abe3 into main Nov 24, 2026
2 checks passed
@snyaggarwal
snyaggarwal deleted the issues#3068 branch November 24, 2026 12:46
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.

Mapper: a download or save before a project's saved log has loaded replaces the whole log

2 participants