문제
테스트 5개가 운영 코드의 시간 상수를 실제 시계로 기다린다.
- tests/unit/service-worker-runtime.test.ts "bounds a stream that never
produces a chunk": ACTIVATION_MARKER_READ_DEADLINE_MS(5초)를 그대로
기다린다. 10초 제한 중 5초를 쓴다.
- tests/unit/browser-rpc/browser-rpc-remediation.test.ts "keeps the
operation DRAINING when waitClosed …" 4개: 닫힘 확인이 없으면 stream
정리가 STREAM_CLEANUP_BOUND_MS(1초)를 기다린다. 각 1초.
고른 방법과 버린 대안
- SW 테스트: 이 테스트만 vi.useFakeTimers()로 돌리고 deadline을
advanceTimersByTimeAsync로 넘긴다. 마커를 여러 번 읽을 수 있어
끝날 때까지 5초씩 최대 4번 넘긴다. deadline이 없으면 활성화가 끝나지
않아 "settled" 단언에서 실패한다.
- RPC 테스트: 런타임은 이미 ClockPort를 주입받는다. 모든 대기를 30ms로
자르는 시스템 시계를 넘긴다. 작업 자체의 25ms deadline은 그 아래라
그대로다.
- SW lifecycle이 deadline을 의존성으로 받게 하는 안은 버렸다. 운영
코드에 테스트용 손잡이를 하나 더 열어야 한다.
- 상수 값(5,000·1,000)은 운영 코드 한 곳에 그대로 있다.
위험·한계
- 가짜 시계가 stream·마이크로태스크 순서와 얽히면 SW 테스트가
불안정해질 수 있다. 그때는 실제 시계로 되돌린다(1101/10-07 재검토
조건).
- 완료 기준(각 100ms 아래)은 junit 시간으로 desktop에서 본다.
검증
- desktop batch에서 확인:
node scripts/run-vitest.ts run tests/unit/service-worker-runtime.test.ts tests/unit/browser-rpc/browser-rpc-remediation.test.ts --reporter=junit --outputFile.junit=artifacts/tests/r1105-10-07.xml
- 실행 시간만 바꾼 커밋이라 RED는 없다. 두 파일이 통과하고 다섯
테스트가 각각 100ms 아래여야 한다.
Refs: 1101/10-07
문제
유일한 bearer 인증 프로필 이름이 샘플 이름 REFERENCE_EXTERNAL_BEARER다.
세션이 필요한 제품 기능은 지운 샘플의 이름을 계속 쓰거나 템플릿 소유
파일에 프로필을 더해야 한다. 샘플 제거 드릴의 잔여 검사 정규식도 이
이름을 잡지 않아 샘플을 지운 제품에 그대로 남는다. 리뷰 (2) 오류
메시지는 abf3ce5가 했고 (1) 이름 변경이 남았다.
고른 방법 (2026-11-03 결정)
- 프로필 이름을 EXTERNAL_BEARER로 바꿨다. 참조 기능의 V2 operation 3개와
V3 descriptor 3개, external-session-adapter 주석, 테스트, VD-23 문서를
새 이름으로 옮겼다.
- 옛 이름은 한 릴리스 동안 REST_AUTH_PROFILES에 별칭 한 줄로 남기고
JSDoc @deprecated를 붙였다. 레지스트리는 키와 authProfileId가 같아야
하므로 별칭은 EXTERNAL_BEARER를 펼치고 id만 옛 이름으로 둔 객체다.
그래서 옛 이름을 적은 다운스트림 operation도 같은 transport·헤더로
해석된다.
- scripts/scale의 PLATFORM_TOKENS에서 이 이름을 뺐다. 참조 기능에 더는
"REFERENCE"가 든 프로필 이름이 없어 이름 바꾸기에서 보호할 것이 없다.
- 새 테스트 두 개: 별칭이 id만 빼고 EXTERNAL_BEARER와 같게 설치되는지,
src에 옛 이름이 별칭 한 줄 외에 없는지(완료 기준).
버린 대안
- 별칭 없이 바로 바꾸기: 옛 이름을 쓰는 다운스트림 기능이 모듈 로드에서
바로 실패한다. 공개 이름을 깨는 변경은 BREAKING 결정이 있을 때만 한다.
- 조회 시점의 이름 매핑(alias 표): resolve·executor·composition 세 곳이
매핑을 알아야 한다. 프로필 항목 하나가 더 작다.
위험·한계
- 설치된 프로필이 셋이 된다. 같은 설정이 두 id로 있을 뿐 권한이 넓어지지
않는다. 별칭은 다음 minor에서 지우고 CHANGELOG [계약] 행을 남긴다.
그때 "src only on the alias line" 테스트의 기대값을 빈 목록으로 바꾼다.
- 다운스트림 문자열 id("REFERENCE_EXTERNAL_BEARER")에는 @deprecated 표시가
보이지 않는다. CHANGELOG로 알린다.
- FE-REG-API 행 3개의 authProfileId가 바뀐다. breakingFields가 아니라
behavior-change이므로 증거 없이 게이트를 통과한다. 기준선 재승인은 이번
작업 묶음 끝에서 한 번에 한다.
- 초기 JS gzip(초기 청크 파일별 gzip 합) 203,818 → 203,840 B(+22 B). 별칭
항목이 rest-profiles가 있는 초기 청크에 실린다. 참조 기능 계약은 lazy
청크라 초기 크기에 영향이 없다.
검증
- RED(수정 전): rest-profile-contract.test.ts 새 사례 2건 실패("expected
undefined to match object { transport: 'BEARER_HEADER', …(1) }",
"expected [ …(9) ] to deeply equal [ Array(1) ]").
- GREEN: 같은 파일 10/10 통과. check-registries "11 registries PASS"
(FE-REG-API authProfileId 3건 behavior-change).
- 회귀: tests/{unit,integration,features,contract,runtime-schema}
207 파일 2,366건 통과(pnpm·corepack을 띄우는 6개 제외:
http-scenario-evidence, ci-workflow-generation, lab-performance,
fixture-node-modules, deployment-admission, security-followup-archive).
tsc app·test·node rc=0, 바꾼 파일 eslint rc=0. vite build 성공.
- 미실행: check:architecture, test:sample-removal(pnpm 필요), e2e.
Refs: docs/reviews/2026-11-01-maturity-review/16-structure-patterns.md
VD-01 decision 3 hands unused diagnostics to tsc and turns off ESLint's
no-unused-vars for TS files, but tsconfig.base.json never enabled the
tsc check (D-19). The flag found 46 unused imports, types and helpers
across 22 files; none of them were read, so removing them changes no
behaviour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three gaps in the unary/stream runtime:
- A KEYED_COMMAND/NON_REPLAYABLE unary that failed after the transport
was invoked (timeout, throw, UNAVAILABLE, ...) came back retryable
with action "retry", although the server may have applied it. Every
failure of a COMMAND after send now carries effect MAYBE_APPLIED
(retryable false, contact-support). Pre-send rejections and queries
are unchanged.
- A retry did not re-check the scope generation, so after a logout the
previous user's command could be sent again. Each retry now checks
safeIsCurrent first and ends with SCOPE_GENERATION_CHANGED.
- A stream whose consumer aborted but never called return() stayed
suspended at a yield; its finally never ran and the operation stayed
RPC_STREAM_DRAINING for good. The lease is now released (cancel +
positive-close subscription) from the stream's own abort listener;
finally triggers the same path through its abort.
Verified: five new tests failed RED (no effect, second attempt sent,
cancel never called) and pass now; a pin that pre-send command failures
and query failures stay effect-free passes before and after. All lane
gates pass except the known removal-fixture test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cleanup test sets `totalDeadlineMs` and `idleDeadlineMs` to the same
25ms and then asserted `RPC_TOTAL_DEADLINE_EXCEEDED`. Which of the two the
runtime reports depends on whether the clock had crossed the total
deadline by the time the idle wait expired, so under parallel load the
assertion was a coin flip — it passed alone and failed in a 27-file run.
A test that fails for a reason unrelated to its subject teaches a reader
to ignore it, which is the failure mode this whole review pass was about.
The subject here is that a throwing `return` accessor cannot replace the
outcome the runtime already selected and that cancellation still runs
exactly once, so the assertion now pins the terminal kind and accepts
either deadline code.
Confirmed by three consecutive 485-test runs of the same 27-file set that
previously reproduced the failure.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A server stream's registration was pruned on any settled close receipt.
`waitClosed()` rejecting, throwing synchronously, or not returning a
promise at all was absorbed into a fulfilled `undefined`, so the runtime
opened a second physical stream for the same operation while the first was
still running against the server. Only a fulfilled, contract-shaped
receipt confirms closure now; every negative receipt keeps the operation
DRAINING.
Cleanup also read foreign state outside the result boundary. A throwing
iterator `return` accessor replaced the already selected timeout with a
native `TypeError` and skipped the rest of the teardown, and the exported
lease decoder threw on a hostile `Symbol.asyncIterator`. Both reads move
inside their own boundaries, and the positive-close subscription is
installed before any fallible cleanup.
Composition validated the caller's registries before snapshotting them, so
a hostile accessor ran twice during validation, and rows hiding fields
behind a prototype or a non-enumerable key installed. Transport results
were checked for allowed own keys only, so own `{ok,message,encodedBytes}`
plus a prototype `injected` was a success and a missing `message` reached
a permissive schema as `undefined`.
In Realtime the tracked task was registered after the collaborator
returned. An authority that re-entered `close()` from inside its own
invocation saw an empty registry and got `{ok:true}` while its effect was
pending. The task is now registered first and the collaborator is invoked
a microtask later. A `scheduleTimeout` that threw was worse: the caller's
own catch treated it as an apply failure and started a recovery beside the
still-running effect, and `close()` rejected with a native `TypeError`. An
uninstallable deadline now fails closed as an expired one.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
RPC-RR-01. openServerStream returned a bare AsyncIterable, which gave the
runtime no way to stop the physical stream or to learn when it actually closed:
iterator.return() is a request a non-cooperative implementation may ignore. The
runtime could therefore time out, report the call finished, and admit a second
stream for the same operation while the first was still running against the
server.
The transport now returns a lease — streamId, frames, cancel(reason) and
waitClosed() — decoded from own data descriptors before the runtime registers
it, so an accessor cannot hand the registry one object and the cancellation
path another. The runtime registers the lease the moment the physical stream
exists, cancels exactly once on exit, and keeps the entry until waitClosed()
settles. A second stream for the same operation is refused as CONFLICT /
RPC_STREAM_DRAINING while that entry stands, and the refusal never reaches the
transport.
While updating the suites this also corrected two RPC-RR-02/RPC-RR-04 stream
tests that were passing for the wrong reason: they sent an input the request
schema rejects, so they never reached the fence or the frame decoder. With the
correct input the frame test fails on a permissive decoder, as it should.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
RPC-RR-02. The server-stream path captured the generation fence outside its
protected boundary and raceWithin invoked clock.sleep outside a promise
boundary, so a synchronous throw from either escaped the Result contract and
skipped the listener and timer release. Both now run inside the boundary, and
release moved to finally.
RPC-RR-03. The runtime snapshotted its transports only after validating the
caller's raw objects, which ran their accessors first. It now decodes the
registry from own data descriptors before anything reads it — refusing an
accessor without invoking it and rejecting extra, inherited and symbol-keyed
fields — and validates that snapshot. Every installed binding registry is a
read facade over a private store instead of a frozen Map whose set, delete and
clear still worked.
RPC-RR-04. Transport results and stream frames are decoded per union variant
from own data descriptors into new frozen values. A throwing getter, an
inherited or extra field, a symbol key, an unknown failure code and an
out-of-range retryAfterMs all close as protocol failures instead of escaping.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
R-04: install the RPC contract bindings as exact immutable snapshots. Registry
and row data are copied from own data descriptors into frozen null-prototype
maps before validation, so a getter is never invoked, extra and symbol keys and
malformed descriptors are composition-time TypeErrors, and the runtime reads
only the snapshot. A post-validation mutation can no longer change replay
policy, deadlines, byte ceilings or transport selection.
R-01: bound transport stream cleanup. The generation is fenced and listeners
released immediately, and iterator.return() is awaited only within a cleanup
bound, so a non-cooperative iterator cannot keep the application generator, its
listeners or the total deadline alive. Unresolved cleanup stays observed.
R-05: reject oversized WebSocket text frames before allocating an encoded copy
and count UTF-8 bytes incrementally with an early exit, matching TextEncoder for
surrogate pairs and lone surrogates.
R-06: canonicalise clock and generation-fence failures into the closed Result
taxonomy instead of letting them escape as native rejections, with listener and
timer cleanup on every exit path.
Browser RPC remains AVAILABLE_NOT_COMPOSED; R-07 transport evidence is still
required before composition.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>