Skip to content

test(claude-web): assert which class the registry entry builds, not one spelling of it (#11421) - #11586

Closed
ntdatt812 wants to merge 2 commits into
diegosouzapw:release/v3.8.51from
ntdatt812:fix/11421-claude-web-registry-guard
Closed

ntdatt812 wants to merge 2 commits into
diegosouzapw:release/v3.8.51from
ntdatt812:fix/11421-claude-web-registry-guard

Conversation

@ntdatt812

Copy link
Copy Markdown
Contributor

The red test

Unit Tests fast-path fails on every branch:

✖ has no execution-time dependency on the standalone Turnstile solver
  AssertionError [ERR_ASSERTION]: The input did not match the regular expression
  /"claude-web": new ClaudeWebExecutor\(\)/

Cause

#11421 made the executor
registry lazy, so every entry in open-sse/executors/index.ts became a thunk:

"claude-web": () => import("./claude-web.ts").then((m) => new m.ClaudeWebExecutor()),
"cw-web":     () => import("./claude-web.ts").then((m) => new m.ClaudeWebExecutor()), // Alias

The property this test exists to guard is unchanged: each alias builds the plain
ClaudeWebExecutor, not a ClaudeWebWithAutoRefresh wrapper that would pull the
standalone Turnstile solver back into the execution path. Only the spelling of the
registry moved, and the pinned literal went red on a refactor that never touched what it
was protecting.

The fix

Read the registry entry for each alias and assert on the class it names, instead of
pinning one syntactic form of the map:

for (const alias of ["claude-web", "cw-web"]) {
  const entry = indexSource.match(new RegExp(`"${alias}":\s*(.+)`));
  assert.ok(entry, `"${alias}" must still be registered in executors/index.ts`);
  assert.match(entry[1], /\bClaudeWebExecutor\(\)/);
}

This survives the eager→lazy change and the next reshaping, and the assert.ok keeps
the guard from silently going vacuous if an alias is dropped from the registry
altogether — the old regex would just have failed with "did not match" either way,
without distinguishing "renamed" from "gone". The ClaudeWebWithAutoRefresh negative
guard and the ClaudeWebExecutor extends BaseExecutor module anchor are untouched.

Verification

# base branch
✖ has no execution-time dependency on the standalone Turnstile solver
ℹ tests 9  ℹ pass 8  ℹ fail 1

# with this change
ℹ tests 9  ℹ pass 9  ℹ fail 0

The guard still bites. I pointed the claude-web entry at the forbidden wrapper by
hand:

"claude-web": () => import("./claude-web.ts").then((m) => new m.ClaudeWebWithAutoRefresh()),

✖ has no execution-time dependency on the standalone Turnstile solver
  The input was expected to not match the regular expression /ClaudeWebWithAutoRefresh/
ℹ pass 8  ℹ fail 1
npx eslint tests/unit/claude-web-transport.test.ts   # 0 errors

prettier --check reports this file as non-conformant both before and after the change
(pre-existing on the base branch), so I left the formatting alone rather than mixing an
unrelated reformat into the diff.

Test-only; no production code touched.


Third stale artifact of #11421 that I have run into in the checks — the other two are
#11582 (the known-symbols
executor gate still calling the now-async getExecutor() synchronously, reporting all
142 aliases dead) and the extractExecutorAliases fixture folded into that same PR.
Each is independent; merge in any order.

…ne spelling of it (diegosouzapw#11421)

`Unit Tests fast-path` is red on every branch:

    ✖ has no execution-time dependency on the standalone Turnstile solver
      The input did not match the regular expression /"claude-web": new ClaudeWebExecutor\(\)/

diegosouzapw#11421 made the executor registry lazy, so every entry became a thunk:

    "claude-web": () => import("./claude-web.ts").then((m) => new m.ClaudeWebExecutor()),

The property this test guards — that the alias builds the plain executor rather than a
`ClaudeWebWithAutoRefresh` wrapper, which would drag the standalone Turnstile solver
back into the execution path — still holds exactly as before. Only the spelling of the
registry changed, and the pinned literal went red on a refactor that never touched what
it was protecting.

Read the entry for each alias and assert on the class it names, so the guard survives
the eager→lazy shape change and the next one. The `ClaudeWebWithAutoRefresh` negative
guard and the module anchor are untouched.

Third stale artifact of diegosouzapw#11421 in the checks; see also diegosouzapw#11582 (the known-symbols
executor gate calling the now-async getExecutor synchronously).
@diegosouzapw

Copy link
Copy Markdown
Owner

Obrigado — mesma causa raiz de #11585 (âncora do regex do registro lazy de executors quebrada pelo #11421) e mesma correção (âncora tolerante a espelhamento eager→lazy). Vou mergear #11585 (aberta primeiro) e fechar esta para evitar duplicidade.

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