Skip to content

OpenConceptLab/ocl_issues#3064 | Read each version's mapped-sources list once - #135

Open
paynejd wants to merge 6 commits into
mainfrom
issues#3064
Open

paynejd wants to merge 6 commits into
mainfrom
issues#3064

Conversation

@paynejd

@paynejd paynejd commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Closes OpenConceptLab/ocl_issues#3064.

On a project with a bridge algorithm (its own, or the one the API offers), the Mapper read the same mapped-sources/ list several times per page load and once more per save: the bridge-probe effect ran again on every project change, and the target version read the list again when the bridge resolved to the same version. That list can be slow to answer, so each repeat adds server load.

What changes

  • mappedSources.js (new): createMappedSourcesReader keeps each page's request for the open project, keyed by version and page. The bridge probe and the target version read through the one reader, so they share a request in flight and reuse a finished one.
    • Version URLs are compared as given, apart from the trailing slash, and a repository's HEAD has one key at <repository>/ and at <repository>/HEAD/. A version id the API encodes in its URL (@, + and the like) is read separately by the bridge and the target, as before: the server can read the bare and encoded forms differently.
    • Pages are read in APIService's raw mode, so a failed or throttled read settles. A page that fails isn't kept, so the next ask reads it again.
    • A network error or a 5xx is tried again twice (about 3 s and 12 s later, with the existing retryWithBackoff), only while a read still waits for that page.
    • A read can be stopped, so a slower read of an earlier target version no longer overwrites the current version's list. Leaving the project stops the target's read.
  • probeBridgeMappedSources (new): the bridge probe's logic, moved out of the effect so it can be tested. A bridge algorithm with a version reads that version. One without a version resolves it with $resolveReference in the effective namespace, then reads the result. A selected algorithm still pins its resolved version. New: a network error or a 5xx on $resolveReference is tried again twice, and a probe stopped before its version resolves pins, reads and retries nothing.
  • MapProject.jsx: the probe effect's dependencies are now the inputs it uses: the bridge algorithm's id, repository and version, bridgeEnabled, and the effective namespace (namespace || project.owner_url || owner). It no longer depends on the whole project. Requests stay the same (excludeSelf=false&brief=true, 25 per page).

Tests

  • __tests__/mappedSources.test.js counts reads with a fake API:
    • the probe and the target share one read of each page;
    • a version already read isn't read again;
    • another version is read on its own;
    • HEAD shares one read at both of its URLs, and an encoded version id is read apart from the bare id;
    • a failed page is read again;
    • a throttled page is read again;
    • a transient failure is retried at most twice;
    • a page isn't retried once no read waits for it;
    • a stopped read gives nothing more;
    • the probe resolves, retries a transient failure, pins only when selected, and does nothing once stopped.
  • Source checks on MapProject.jsx, as in usageRouteProject.test.js:
    • the probe effect's exact dependency list (no project);
    • only the shared reader reads the list, in raw mode;
    • the unmount cleanup, and the versions answer's guard.
  • npm run test:all: 719 unit and 13 integration tests pass. 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. The project had a CIEL target, the API offered a CIEL bridge algorithm with no version, and the list had 50 sources (2 pages).

main this branch
Open the project: first-page reads 2 1
Then 2 saves: list reads / $resolveReference calls 2 / 2 0 / 0
Same, with the bridge algorithm selected: first-page reads on open 5 1
Then 2 saves: list reads 2 0
Saved bridge algorithm keeps its resolved version yes yes

With the mock's first list read answering 503, this branch tried it again 3.8 s later and the list loaded.

Not changed: with the bridge algorithm selected, opening the project still resolves the bridge version twice (once for the offered algorithm, then for the selected one). That's one small POST each, and they don't repeat on saves.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AaZ4qVXohXhqMLGigP4RHV

paynejd and others added 2 commits November 23, 2026 16:48
…urces list once, shared by the bridge probe and the target

The bridge probe re-ran on every project change and the target version read
the same list again. Both now read through one reader that keeps each page's
request for the open project, so a version's list is read once, and a page
that fails is read again on the next ask. The probe runs again only when the
bridge algorithm, its repository or version, whether it's selected, or the
namespace changes, and a selected bridge algorithm still pins its resolved
version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVXohXhqMLGigP4RHV
… list, and retry transient failures

Read the list pages and resolve the bridge version in APIService's raw mode,
so a throttled read settles and isn't kept. A repository's HEAD is one
version at its own URL or at HEAD/. A network error or a 5xx on a page or on
$resolveReference is tried again twice, so a passing failure no longer leaves
the bridge off until the page reloads.

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

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

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

Verdict: findings (3 finding(s)).

  • F1.1 P1 src/components/map-projects/MapProject.jsx:157: A throttled mapped-sources page stays in the cache as a promise that never settles.
  • F1.2 P2 src/components/map-projects/mappedSources.js:38: The target and bridge still read the same HEAD list twice because they use different cache keys.
  • F1.3 P2 src/components/map-projects/MapProject.jsx:890: A transient failure resolving the offered bridge leaves it disabled after the API recovers.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "full",
  "commit": "e51bd6d8441588ef83ecb54b053f84d8d40329fd",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "F1.1",
      "severity": "P1",
      "tag": null,
      "file": "src/components/map-projects/MapProject.jsx",
      "line": 157,
      "claim": "A throttled mapped-sources page stays in the cache as a promise that never settles.",
      "scenario": "The API returns HTTP 429 for a target version's first page. After the throttle expires, the user switches versions and switches back. The reader still returns the original pending promise, so the source list stays empty and no new request is sent. Before this change, reselecting the version sent a fresh request.",
      "action": "Use APIService's raw response mode for this GET so a 429 settles and the reader can evict the failed page. Add a regression test that reselects the version after throttling.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.2",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/mappedSources.js",
      "line": 38,
      "claim": "The target and bridge still read the same HEAD list twice because they use different cache keys.",
      "scenario": "A project targets the HEAD of a source with no releases, and its bridge resolves to that same HEAD. The target gets the bare source URL from the versions API, while the bridge appends `HEAD/`. Both endpoints read the same HEAD mappings, but the reader fetches every page through each URL.",
      "action": "Normalize the bare source path and its explicit `HEAD/` path to the same cache key. Add a test that passes the bare path through the target reader and resolves the bridge to HEAD.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.3",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/MapProject.jsx",
      "line": 890,
      "claim": "A transient failure resolving the offered bridge leaves it disabled after the API recovers.",
      "scenario": "The first `$resolveReference` request for an unselected bridge returns HTTP 503. The probe gets an empty version, so Bridge Match never mounts and the bridge option stays disabled. Saving the project after recovery used to retry the probe. Now a save with the same namespace leaves the option disabled until the user reloads or changes a probe input.",
      "action": "Distinguish transient HTTP failures from a successful response with no resolved version, and retry transient failures within the active probe while preserving cancellation.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Pass 1 replies (fixed in c6df4d7)

  • F1.1 P1, fixed. Confirmed: on a 429, APIService without raw mode returns a promise that never settles, and the reader would have kept it. The page reads and $resolveReference now use raw mode, so a throttled or failed read settles and its page is dropped. Test: "a throttled page is read again when the version is chosen again", plus a source check that both calls pass raw.
  • F1.2 P2, fixed. Confirmed on the live API: HEAD's version_url is the repository URL (/orgs/CIEL/sources/CIEL/), while a bridge resolved to HEAD asks for …/HEAD/. The reader now keys <repository>/HEAD/ as <repository>/. Test: "a repository's HEAD is one version, at its own URL or at HEAD/".
  • F1.3 P2, fixed. A network error or a 5xx on $resolveReference or on a page read is now tried again twice (about 3 s and 12 s later, with the existing retryWithBackoff). A stopped probe doesn't retry. Other failures (404, 429) aren't retried, but the next ask reads them again. Tests cover the resolve retry, the page retry, at most two retries, and a stopped probe. Checked in the browser against a local mock: the first list read answered 503, was retried 3.8 s later, and the list loaded.

…id, and retry a page only while a read waits for it

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

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

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

Verdict: findings (3 finding(s)).

  • Prior F1.1: resolved
  • Prior F1.2: resolved
  • Prior F1.3: unresolved
  • F2.1 P2 src/components/map-projects/mappedSources.js:89: The offered bridge stays disabled if the resolver recovers after the retry window.
  • F2.2 P2 src/components/map-projects/mappedSources.js:81: The target and bridge still fetch the same version twice when its ID is percent-encoded in the API URL.
  • F2.3 P2 src/components/map-projects/mappedSources.js:43: A mapped-sources page can retry after its last caller has stopped.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "verify",
  "commit": "c6df4d7a6958a0f4c4698cdc6e6e7dd71b0898e9",
  "verdict": "findings",
  "prior": [
    {
      "id": "F1.1",
      "status": "resolved"
    },
    {
      "id": "F1.2",
      "status": "resolved"
    },
    {
      "id": "F1.3",
      "status": "unresolved"
    }
  ],
  "findings": [
    {
      "id": "F2.1",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/mappedSources.js",
      "line": 89,
      "claim": "The offered bridge stays disabled if the resolver recovers after the retry window.",
      "scenario": "A 30-second API outage makes the initial $resolveReference call and both retries return 503. After recovery, saving the project with the same bridge inputs no longer retries the probe. The bridge option stays disabled until the user reloads or changes a probe input.",
      "action": "Give a failed bridge probe a retry path that works with unchanged inputs, while keeping successful probes independent of saves.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.2",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/mappedSources.js",
      "line": 81,
      "claim": "The target and bridge still fetch the same version twice when its ID is percent-encoded in the API URL.",
      "scenario": "A source has a version named v1@build. The target uses the encoded version_url from the API, while the bridge builds a path from the raw version ID. Both paths address the same version, but the reader treats them as different keys and requests every page twice.",
      "action": "Use the API's canonical version URL for bridge reads or key both callers by repository identity and version ID. Cover both resolved and pinned bridges.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.3",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/mappedSources.js",
      "line": 43,
      "claim": "A mapped-sources page can retry after its last caller has stopped.",
      "scenario": "A bridge page returns 503 and the user opens another project before the retry timer fires. The old project's retry still runs. If it receives 429, the global throttle overlay blocks the new project even though it never requested that page.",
      "action": "Stop page retries when no active caller still needs the page, and stop the target's read when the project unmounts.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Pass 2 replies (fixes in 43cdd28)

  • F1.3 / F2.1 P2, accepted. After two retries over about 15 s, an outage that outlasts them leaves the offered bridge off until the page reloads or a probe input changes. Retrying on saves again would tie the probe back to project changes, which is what this ticket removes; the target's own read has never retried on save either. Passing failures are covered by the retries.
  • F2.2 P2, fixed. The reader keys a version by its decoded URL, so v1%40build from the API and v1@build from the bridge share one read. Test: "a version id the API encodes in its URL is the same version as the bare id".
  • F2.3 P2, fixed. A page is tried again only while a read still waits for it, and leaving the project stops the target's read (an unmount cleanup). Test: "a page isn't tried again once no read waits for it", plus a source check for the cleanup.

… bare id, and start no read from a versions answer after leaving

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

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

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

Verdict: findings (2 finding(s)).

  • Prior F1.1: resolved
  • Prior F1.2: resolved
  • Prior F1.3: unresolved
  • Prior F2.1: unresolved
  • Prior F2.2: unresolved
  • Prior F2.3: unresolved
  • F3.1 P2 src/components/map-projects/mappedSources.js:39: The target and bridge still fetch the same version twice when OCL returns a double-encoded version URL.
  • F3.2 P2 src/components/map-projects/MapProject.jsx:3034: A late versions response can restart mapped-sources retries after the project has unmounted.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "verify",
  "commit": "43cdd28af21bba4329a25fa345f7d5509ce269be",
  "verdict": "findings",
  "prior": [
    {
      "id": "F1.1",
      "status": "resolved"
    },
    {
      "id": "F1.2",
      "status": "resolved"
    },
    {
      "id": "F1.3",
      "status": "unresolved"
    },
    {
      "id": "F2.1",
      "status": "unresolved"
    },
    {
      "id": "F2.2",
      "status": "unresolved"
    },
    {
      "id": "F2.3",
      "status": "unresolved"
    }
  ],
  "findings": [
    {
      "id": "F3.1",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/mappedSources.js",
      "line": 39,
      "claim": "The target and bridge still fetch the same version twice when OCL returns a double-encoded version URL.",
      "scenario": "The target and bridge both use version `v1@build`. OCL returns `v1%2540build` in `version_url`, while the bridge builds its path from `v1@build`. One decode leaves the target key as `v1%40build`, so both callers fetch every page. The new test supplies the single-encoded URL and misses this case.",
      "action": "Use the API's version URL for both reads, including for pinned bridge versions, and test with the double-encoded URL OCL returns.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F3.2",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/MapProject.jsx",
      "line": 3034,
      "claim": "A late versions response can restart mapped-sources retries after the project has unmounted.",
      "scenario": "A bridge page returns 503 while the target's versions request is pending. The user opens another project, and cleanup removes the bridge waiter. If the old versions response arrives before the retry timer fires, it registers a target waiter after cleanup. The old page retries, and a 429 can open the global throttle overlay over the new project.",
      "action": "Check the existing mounted ref in the versions callback before starting a target read. Test a versions response that arrives after unmount while a shared page is waiting to retry.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Pass 3 replies (fixes in d39cd64). No P0 or P1 open after 3 passes, so the defect passes stop here. Pass 3 lists F2.2 and F2.3 as unresolved because F3.1 and F3.2 found a case each that their fixes missed. Both are fixed below.

  • F2.1 P2: still accepted, for the reason in the pass 2 replies.
  • F3.1 P2, fixed. Confirmed in oclapi2: core/common/utils.py encodes the version id with quote, and Django's reverse() encodes the % again, giving v1%2540build. The reader now decodes the key until it stops changing (at most 3 times), so all three forms share one read. The test now includes the twice-encoded URL.
  • F3.2 P2, fixed. fetchVersions ignores an answer that lands after the project unmounts (isMountedRef), so it can't start a target read. Covered by a source check next to the unmount cleanup's.

…ersion-id decoding

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

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Simplification review (Claude subagent, Sonnet 5.5, commit d39cd64): 3 items.

  • S1 shrink, applied in 812147c: withRetry took isCancelled out of its options only to put it back.
  • S2 shrink, applied in 812147c: the version-id decoding is a plain two-step decode. It keeps the last value that decoded.
  • S3 dup-test, declined: the source checks for the effective namespace, the probe getting the shared reader, and the single mapped-sources/ call pin acceptance criteria 1 and 2 in MapProject.jsx, which the module's own tests can't see. The raw-mode checks pin the F1.1 P1 fix.

Tests rerun after the cuts: 719 unit and 13 integration pass, ESLint clean.

simplify.json
{
    "reviewer": "claude subagent",
    "perspective": "simplify",
    "mode": "full",
    "commit": "d39cd6407c7c9201c1b3f39ef40f772fe1129968",
    "verdict": "findings",
    "prior": [],
    "findings": [
        {
            "id": "S1",
            "severity": null,
            "tag": "shrink",
            "file": "src/components/map-projects/mappedSources.js",
            "line": 16,
            "claim": "withRetry destructures isCancelled out of its options and then puts it back, so the destructure does nothing.",
            "action": "Write `const withRetry = (request, options) => retryWithBackoff(() => Promise.resolve(request()).then(...), {...options, isRetryable: isTransientFailure}).catch(() => null)`.",
            "lines_delta": -1,
            "confidence": "high"
        },
        {
            "id": "S2",
            "severity": null,
            "tag": "shrink",
            "file": "src/components/map-projects/mappedSources.js",
            "line": 24,
            "claim": "The decoded() loop has a try/catch, a next-equals-value check and a counter capped at 3. Pass 3 (F3.1) only needs it to decode twice-encoded ids.",
            "action": "Loop with a plain `try { for(let i=0;i<2;i++) value = decodeURIComponent(value) } catch {}`. Decoding an already-decoded value with no '%' is a no-op, so the equality break isn't needed.",
            "lines_delta": -6,
            "confidence": "medium"
        },
        {
            "id": "S3",
            "severity": null,
            "tag": "dup-test",
            "file": "src/components/map-projects/__tests__/mappedSources.test.js",
            "line": 300,
            "claim": "The last test is a block of source-text regex asserts. Several only restate code: the `bridgeNamespace` const line, `readMappedSources,\\n`, the single mapped-sources appendToUrl count, and the raw-mode `, true)` regexes. They break on formatting changes and add little beyond the dependency-list test. The `isMountedRef` and unmount-cleanup asserts are the ones that pin the pass 2 and 3 fixes, so keep those.",
            "action": "Keep the createMappedSourcesReader and readMappedSources call-site checks plus the isMountedRef and unmount-effect regexes. Drop the bridgeNamespace line regex, the `readMappedSources,\\n` regex and the appendToUrl count regex.",
            "lines_delta": -4,
            "confidence": "low"
        }
    ]
}

… encoded id never shares a read with the bare id

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

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits 43cdd28..812147c (codex-cli 0.169.0, commit 812147c)

Verdict: findings (1 finding(s)).

  • FC.1 P2 src/components/map-projects/mappedSources.js:33: Decoding twice gives the raw bridge URL and the canonical target URL the same cache key even when OCL resolves them to different versions.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "812147c891c264363ab0a1152125a011fe796cf3",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "FC.1",
      "severity": "P2",
      "tag": null,
      "file": "src/components/map-projects/mappedSources.js",
      "line": 33,
      "claim": "Decoding twice gives the raw bridge URL and the canonical target URL the same cache key even when OCL resolves them to different versions.",
      "scenario": "Select version `1.2.3+build.1` for both the bridge and the target. If the bridge requests the raw `+` URL first and the target joins while it is pending, OCL interprets the raw `+` as a space. When that version is absent, both callers receive an empty mapped-sources list after the bridge's 404. At 43cdd28 the target issued its own request using `%252B` and received the correct list.",
      "action": "Use the API's canonical version URL for bridge reads before sharing cache entries. Add a regression test with a `+` build suffix and the bridge request starting first.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

Reply (fixed in 1117b0d)

  • FC.1 P2, fixed by narrowing F2.2/F3.1. Decoding version ids let the bridge's raw URL and the API's encoded URL share a read, though the server can read them as different versions. The reader now compares version URLs as given, apart from the trailing slash and HEAD. A version id the API encodes (rare: @, + and the like) is read once by the bridge and once by the target, as before this PR, and neither can get the other's failed read. The F2.2 and F3.1 cases are accepted on that basis. The test is now "a version id the API encodes in its URL is read apart from the bare id", using 1.2.3+build.1.

@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Codex check of commit 1117b0d (codex-cli 0.169.0, commit 1117b0d)

Verdict: clean (0 finding(s)).

  • Prior FC.1: resolved
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "1117b0d0aaab1c636f1615215d94371ccfcaea45",
  "verdict": "clean",
  "prior": [
    {
      "id": "FC.1",
      "status": "resolved"
    }
  ],
  "findings": []
}

This branch has not been deployed

No deployments
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: with a bridge algorithm, the bridge probe re-reads the mapped-sources list on every project change, and the target's read repeats it

1 participant