Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

[finding] normaliseClientError's first CONCURRENT_UPDATE guard is subsumed by the line under it — the httpStatus === 409 half decides nothing #6375

Closed

Description

@os-support-ai

Observation-class finding, spotted while reading the boundary for objectui#5902. Not touched by that PR — its dispatch scoped packages/data-objectstack out (the boundary work from objectui#5901 is done and merged), so this is recorded rather than edited.

What

packages/data-objectstack/src/index.ts, the tail of normaliseClientError:

if (e.code !== 'CONCURRENT_UPDATE' && e.httpStatus !== 409) return error;
if (e.code !== 'CONCURRENT_UPDATE') return error;
return new ConcurrentUpdateError({ ... });

The second line's condition is strictly weaker than the first's, so the first line can never be the one that decides an outcome:

code httpStatus line 1 line 2 outcome
≠ CONCURRENT_UPDATE ≠ 409 returns would also return passthrough
≠ CONCURRENT_UPDATE 409 falls through returns passthrough
CONCURRENT_UPDATE any falls through falls through typed error

Delete line 1 and every input keeps its current answer. The httpStatus !== 409 half in particular reads as if a bare 409 could still be re-wrapped; it cannot.

Why it is worth a card rather than a silent cleanup

It is dead code, not a behaviour bug — the effective rule is "the wire code is the discriminator", which is a reasonable rule and the one the function's own doc comment describes. What makes it worth recording is that the line advertises a second acceptance path that does not exist, on a function whose whole job is deciding which errors get re-wrapped. A reader adding a shape here has to re-derive the truth table to find out that half of the first guard is inert.

There is a related asymmetry worth deciding at the same time: the exported isConcurrentUpdateError in the same file accepts name === 'ConcurrentUpdateError' as well as the code, while normaliseClientError accepts only the code. Consumers duck-typing through the exported predicate and consumers relying on the re-wrap therefore disagree about one shape.

Severity

Low, and deliberately filed flat rather than pre-graded — no user-visible symptom, no test moves either way. Triage decides whether it is worth a patch at all or whether the right move is a one-line comment naming the code as the sole discriminator.

Where

  • packages/data-objectstack/src/index.ts — normaliseClientError, the two guards immediately before return new ConcurrentUpdateError(...)
  • packages/data-objectstack/src/index.ts — isConcurrentUpdateError, for the asymmetry above

Found from: objectui#5902 (drag-write surfaces reading the producer-marked userMessage).

Activity

  1. os-support-ai commented on Aug 25, 2026

    @os-support-ai
    CollaboratorAuthor

    Claimed + dispatched — domain:ui @ objectui execution seat

    PM session session_011SfZeFWrhGLHmfq61xbz4q, branch claude/issue-6375-concurrent-update-guard.
    All agents share one GitHub identity, so the assignee field does not establish whose claim this
    is — this comment's session ID does.

    Pre-dispatch gate — and it turned up something that points against part of the charter

    The subsumption is real and readable straight off the tree — both guards are adjacent:

    :1150  if (e.code !== 'CONCURRENT_UPDATE' && e.httpStatus !== 409) return error;
    :1151  if (e.code !== 'CONCURRENT_UPDATE') return error;
    

    Anything reaching :1151 without code === 'CONCURRENT_UPDATE' is returned there, and anything
    with it passes both. :1150 changes no outcome. The card's truth table holds; the deletion is
    the one the charter asks for.

    ⚠️ The adjacent asymmetry — read :619 before you touch :1043

    Triage's second half says: "if no consumer depends on isConcurrentUpdateError's name ===
    acceptance for an object that lacks the wire code, align the predicate to the code-only
    discriminator the function's doc describes."

    :1040  export function isConcurrentUpdateError(error: unknown): error is ConcurrentUpdateError {
    :1043    return e.code === 'CONCURRENT_UPDATE' || e.name === 'ConcurrentUpdateError';
    

    ⭐ That name === limb is documented as deliberate, not as drift. The doc comment at
    :619 names the case it exists for: "a host that bundles this package twice" — i.e. the
    cross-realm situation where instanceof fails because there are two copies of the class, and the
    name string is the only surviving discriminator.

    So "no consumer depends on it" is the wrong measurement. An in-repo consumer census cannot see
    the case this limb was written for: a host that double-bundles the package, which is by
    construction out of tree. Removing it on a zero-consumer reading would delete a deliberate
    cross-realm guard and call it drift — the same shape as a check run against the wrong surface.

    ⛔ Do not delete the name limb on a consumer count. What I want instead:

    • If your reading agrees with mine, keep both limbs and record why beside the predicate,
      pointing at :619 so the next reader meets the reason where the code is. Triage's charter
      explicitly allows this arm ("keep both and record why beside the predicate").
    • If you find :619 does not in fact justify :1043 — that the double-bundling rationale
      belongs to something else and the name limb really is unmoored — then say so with the reading
      that shows it, and align the predicate as chartered. Stop and report rather than guessing.

    Either way the doc at :1037 and the predicate at :1043 should stop disagreeing by the end of
    this PR: one of them moves.

    Scope

    The subsumed-guard deletion is the deliverable. ⛔ Do not widen into the other error paths in this
    file — it has 8+ normaliseClientError call sites and they are not in scope. A verdict-changing
    consumer is a finding to report, not to paper over.

    Ghost-assertion guard

    If you pin the deletion, the pin must fail against unmodified origin/main — and note the trap
    here: the deletion is a no-op by construction, so a test asserting "behaviour unchanged"
    passes before and after and proves nothing. What earns its keep is the truth table exercised as
    cases: every input class through the predicate, each keeping its answer, with a case that would
    change answer if :1151 were the line deleted instead of :1150.

    Deliver a draft PR with Fixes #6375. ⛔ Do not mark ready, ⛔ do not self-merge, ⛔ do not
    enable auto-merge — the PM lands it. Report back the standard os-dev JSON.


    Generated by Claude Code

  2. claude commented on Aug 25, 2026

    @claude
    Contributor

    os-dev-report
    {
    "issue": 6375,
    "status": "done",
    "branch": "claude/issue-6375-concurrent-update-guard",
    "pr": "#6422",
    "premise_still_valid": true,
    "summary": "Re-derived the premise on my own branch (origin/main 9602dc8, lines 1150-1151) and it holds: the first CONCURRENT_UPDATE guard's condition is strictly stronger than the second's, so it can never decide an outcome. Deleted it, leaving the effective rule (the wire code is the sole discriminator) written where it sat. On the second half of the charter I took the arm triage explicitly permitted: the name === limb in isConcurrentUpdateError is DELIBERATE, so the DOC moved and the predicate did not. Evidence, strongest first: the rationale is already written in the same file above isViewConfigPermissionDeniedError and cites this very function as its precedent ('matching {@link isConcurrentUpdateError}: a host that bundles this package twice ... still gets the right verdict'), so deleting the limb would leave that doc citing a predicate that no longer does what it claims; the consumer census is the wrong measurement (the double-bundling host is out of tree by construction) and also comes back empty (no in-repo consumer imports this predicate at all -- plugin-detail imports a same-named LOCAL copy from ./ConcurrentUpdateDialog); and two sibling packages carry the same two-limb check for adapters they must not depend on, with plugin-form's own test already pinning the name limb at occSave.test.tsx:86. The doc now records both the cross-realm reason and the deliberate width difference (the predicate accepts code OR name and reads httpStatus for neither, while the re-wrap keys on the wire code alone). Also noted in the PR body, as context rather than a change: normaliseClientError is not uniformly code-only either -- its VALIDATION_FAILED branch accepts name === 'ValidationError' -- so the code-only character of the concurrent-update branch is a local fact, not a house rule.",
    "tests": "Union run on the final commit 3d85c0c (same tree as every number below). (1) Package suite: pnpm exec vitest run packages/data-objectstack/ -> 'Test Files 47 passed (47)' / 'Tests 640 passed (640)'. (2) pnpm --filter @object-ui/data-objectstack run type-check -> 'tsc --noEmit', lock verdict 'command-exit 0' (first attempt was TS6305 'has not been built from source file' for types/core -- a prerequisite, fixed by building the dep closure pnpm --workspace-concurrency=2 --filter '@object-ui/data-objectstack^...' build, not a red gate). Guarded against the excluded-tests trap: tsc --listFiles lists BOTH src/index.ts and src/occ.test.ts, so the clean typecheck really covers the edits. (3) Gates: check-control-bytes 'OK (scanned 5314 tracked text file(s))', check-changeset-presence green quoting '2 source file(s) of 1 released package(s) changed, and this change declares 1 changeset(s) ... Every one of them has an EMPTY frontmatter', check-changeset-no-major 'No changeset declares a major bump.', check-changeset-fixed OK, check-vi-mock-specifiers OK, check-shell-escape-residue OK. All verdicts quoted from each gate's own printed line, exit codes captured before any pipe. ABLATION (the load-bearing evidence, direction predicted before each run): run A = pin against UNMODIFIED origin/main source -> predicted green, got 'Tests 18 passed (18)'; run B = pin + this change -> predicted green and identical, got 'Tests 18 passed (18)'; run C = pin + THE OTHER POSSIBLE DELETION (keep the conjunction, drop the code-only line) -> predicted red on exactly the two 409-passthrough rows, got 'Tests 2 failed | 16 passed (18)' failing exactly 'passes through a 409 whose code is NOT CONCURRENT_UPDATE' and 'passes through a bare 409 carrying no code at all', nothing else moving. That asymmetry is what makes the pin about THIS deletion rather than about the function existing -- a plain 'behaviour unchanged' assertion would pass both ways and pin nothing. No dist/rebuild leg applies: the test imports './index' inside the package and vitest resolves it from source (root-config alias), so there is no dist copy a mutation could fail to reach. The mutation was proven ON DISK before the run, not from an editor exit code: injected-text grep -c = 1, removed-text grep -cx = 0, and working-tree git hash-object moved fd389f5c... -> b019a597... off the HEAD blob. Restore ran under trap ... EXIT INT TERM with ABSOLUTE paths via git checkout HEAD -- <abs path> (never bare git checkout --, which would restore the mutation out of the polluted index) and is proven by hash, not exit code: working tree back to fd389f5c974ef83138d5008495b1b14c87e3d8b7, byte-identical to the HEAD blob, git diff HEAD empty, git status --porcelain empty. TWO DECLARED NARROWINGS (measured, not skipped): (a) eslint was run on the two edited files rather than repo-wide -- pnpm lint is turbo run lint over 47 packages and CI runs it regardless; targeted result 0 errors / 123 warnings, all @typescript-eslint/no-explicit-any and all pre-existing (the two in occ.test.ts are at lines 29 and 86, in assertions that predate this branch; my added block introduces no any); the config has no type-aware linting and no formatting rules, so this diff cannot move a verdict on a file it does not touch. (b) check-readme-exports is NOT MEASURED locally rather than red -- it needs every package's dist/.d.ts and says so itself ('its type entry ./dist/index.d.ts is not on disk -- run pnpm build first'); a fresh worktree has 34 of 40 packages unbuilt. After building the one package this PR touches, every unjudged item naming packages/data-objectstack disappeared (356 -> 348 unjudged, exactly its 8 entries; judged self-imports 22 -> 30 real, 0 wrong-path, 0 fabricated); the residual 348 belong to the other 33 unbuilt packages. CI builds first and measures the rest. Note on gate derivation: scripts/pm/dispatch-gates.mjs lives only in objectstack and answers only about its own tree, so it was NOT fed objectui paths; this repo's list was derived by hand from its package.json check: scripts and .github/workflows/*.yml. All heavy commands ran through the shared lock (scripts/pm/os-verify-lock.sh -c), which queued once behind another agent's plugin-dashboard build for 87s and then granted in arrival order.",
    "open_questions": [],
    "out_of_scope_findings": [
    "filed as #6421: plugin-detail's same-named local isConcurrentUpdateError (ConcurrentUpdateDialog.tsx:223) is a type predicate narrowing to a REQUIRED code: 'CONCURRENT_UPDATE' while its name === 'ConcurrentUpdateError' limb accepts objects that carry no code -- the narrowed type is unsound for exactly the cross-realm case the limb exists for. No symptom today: the only consumer (InlineEditSaveBar.tsx:183) reads just the optional currentVersion/currentRecord, never .code. Observation-class, finding label, unassigned, no pm:queue. Dedup done first over all 240 open issues via the REST list endpoint plus local grep (no MCP list_issues/search_issues): only #6375 itself matched."
    ]
    }


    Generated by Claude Code

  3. os-support-ai commented on Aug 25, 2026

    @os-support-ai
    CollaboratorAuthor

    PM review — ACCEPT

    PR #6422, head 3d85c0cd9. domain:ui @ objectui execution seat, PM session
    session_011SfZeFWrhGLHmfq61xbz4q. Verified against a pinned ref
    (git update-ref refs/pmtmp/6375) rather than read from the report.

    Diff is three files: the guard deletion plus its replacement comment, the pin, the changeset.
    The predicate at isConcurrentUpdateError is untouched — only its doc grew. That is the arm
    triage permitted, and it is the right one.

    ⚠️ Correcting my own dispatch note — the dev's attribution is right and mine was off by one function

    My dispatch told you the double-bundling rationale was the doc of the name limb. It is not.
    :615-621 is isViewConfigPermissionDeniedError's doc, and it reads:

    Duck-checks code/name rather than using instanceof, matching {@link isConcurrentUpdateError}:
    a host that bundles this package twice (or re-throws across a worker boundary) still gets the
    right verdict.

    My conclusion held — the limb is deliberate — but the dev's version of the argument is stronger
    than the one I handed over
    : the rationale lives on a sibling that cites this function as the
    precedent it is matching, so deleting the limb would leave that sibling's doc citing a predicate
    that no longer does what it claims. Two docs falsified by one deletion, not one.

    Two pieces of evidence the dev found that I had not

    • ⭐ packages/plugin-form/src/occSave.test.tsx:86 already pins the limb:
      expect(isConcurrentUpdateError({ name: 'ConcurrentUpdateError' })).toBe(true), with
      { httpStatus: 409 } → false on the next line. Deleting the name limb would have reddened
      an existing test in a different package. That is independent confirmation the limb is
      load-bearing, from a direction neither the charter nor my dispatch pointed at.
    • ⭐ The exported predicate has zero in-repo importers — verified: outside its own
      occ.test.ts and two CHANGELOG lines, nothing in packages/ imports it, and plugin-detail
      uses a same-named local copy from ./ConcurrentUpdateDialog. So the consumer census comes
      back empty, and the dev correctly did not read empty as licence. An empty census is what the
      wrong measurement looks like when it runs cleanly.

    The ablation is the asymmetry test, and it produced the predicted result

    Three runs, direction declared before each:

    run source predicted actual
    A unmodified origin/main green Tests 18 passed (18)
    B with this change green, identical Tests 18 passed (18)
    C the other possible deletion — keep the conjunction, drop the code-only line red on exactly the two 409-passthrough rows Tests 2 failed | 16 passed (18), failing exactly passes through a 409 whose code is NOT CONCURRENT_UPDATE and passes through a bare 409 carrying no code at all

    ⭐ Run C is what makes this pin about this deletion rather than about the function existing.
    A no-op deletion is the case where "behaviour unchanged" passes both ways and pins nothing; the
    dispatch asked for the case that would change answer if the other line had gone, and that is
    what was built and what failed, with nothing else moving.

    Mutation proven on disk before reading (grep -c 1, grep -cx 0, git hash-object moved off the
    HEAD blob), restore proven by hash back to fd389f5c… with git diff HEAD empty — not by an exit
    code, and using absolute paths under a trap rather than a bare git checkout --.

    The context line that keeps the doc honest

    The dev recorded, as context rather than as a change, that normaliseClientError is not
    uniformly code-only either — its VALIDATION_FAILED branch also accepts name === 'ValidationError'.
    So the concurrent-update branch's code-only character is a local fact, not a house rule.
    ⭐ Noting the counter-example that stops the next reader over-generalising this PR into a
    convention is worth more than the deletion itself.

    Scope and housekeeping

    ⛔ No widening: the file's 8+ other normaliseClientError call sites are untouched. Two narrowings
    were declared and measured rather than skipped quietly — targeted eslint (0 errors, 123
    pre-existing no-explicit-any warnings, none introduced) and check-readme-exports reported as
    not measured locally rather than as red, with the prerequisite explained and the package's own 8
    entries shown clearing after a build.

    #6421 filed for the plugin-detail local copy — finding, unassigned, no pm:queue, no
    domain:*. ✅ Correct: observation-class, left for the triage seat's first touch, deduped against
    all 240 open issues first.

    Landing

    CI at 3d85c0cd9: 20 green, 8 still running, 0 failures. ⛔ Not enqueued — 入队资格 is every
    check green, not the required subset. It goes to the merge queue when the shards land.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

domain:uipm:dispatched

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions