Commit Graph
10 Commits
Author SHA1 Message Date
DongHyeonka 6b7b53fe01 perf(image-cdn): 같은 이미지를 동시에 resolve하면 probe를 한 번만 돌린다 (01-04)
문제: resolve()는 통과한 probe 기록(passedProbes)을 slot을 기다리기
전에만 본다. 같은 asset·preset을 동시에 5번 resolve하면 probe가 5번
돈다. probe마다 preset의 encoded 예산까지 no-store로 내려받고
decode하며, 같은 이미지가 probe slot을 차지해 다른 이미지의 probe가
밀린다.

고른 방법: asset·preset별로 "진행 중인 probe 단계"(slot 대기, probe,
통과 기록)를 promise 하나로 둔다. 뒤에 온 호출은 그 단계가 끝나기를
자기 signal로 기다린 뒤 기록된 통과를 재사용한다. probe 자체를
공유하지 않으므로 호출마다 abort가 독립이다. 앞선 probe가 실패하면
기다린 호출이 직접 probe한다(실패는 재사용하지 않는다는 기존 규칙).
X5(동시 5회, maxConcurrentProbes 2)에서 probe가 1회다.

버린 대안:
- 리뷰가 제안한 slot 획득 뒤 재확인. 넣어 보니 X5에서 probe가 3회로
  완료 기준(2회 이하)을 못 맞춘다. slot은 원시 probe가 끝날 때
  넘겨지는데(TR-RR-07), 통과 기록은 그보다 몇 microtask 뒤에 남는다.
  다음 대기자가 기록 전에 깨어난다.
- 진행 중 probe의 결과를 공유(single-flight). 호출자마다 signal이
  달라 참조 수를 세야 한다.
- slot 해제를 통과 기록 뒤로 미룬다. 해제 지점이 원시 probe 정착과
  wrapper 종료 두 곳으로 갈라진다.

위험·한계:
- 대기 뒤 재사용할 때 만료를 따로 다시 보지 않는다. 통과를 기록한
  호출이 기록 직전에 만료를 봤고, 대기자는 같은 task 안에서 이어서
  실행된다. 시작할 때의 만료 검사(기존)는 그대로다.
- 앞선 probe가 실패하면 기다리던 호출들이 각자 probe한다(slot 수로
  묶임). 실패가 반복되는 이미지는 지금과 같은 수의 probe가 돈다.
- probe 블록을 try/finally로 감싸면서 들여쓰기가 바뀌었다. 로직
  변경은 `git show -w`로 보면 짧다.
- file-transfer 레시피 번들이 55,725 → 55,856 gzip bytes가 되어 예산
  55,800을 넘었다. 다음 백 단위로 올리는 기존 규칙대로 55,900으로
  올렸다.

검증:
- RED(수정 전 코드에 새 테스트): "probes once and lets the other calls
  reuse the pass"가 "expected vi.fn() to be called 1 times, but got 5
  times"로 실패. 재확인 안(버린 대안)에서는 2회 기대에 3회로 실패.
  나머지 새 테스트 2건(앞선 probe 실패 시 대기자가 직접 probe, 대기
  중 abort가 진행 중 probe를 끊지 않음)은 새 분기를 고정한다.
- GREEN: image-cdn 단위 3파일 37건 통과.
- 회귀: browser-file·image-cdn·presigned·resumable-upload·json-schema
  단위 20파일 323건 통과. tsc app·test·recipes 통과. 바꾼 파일 eslint
  통과. check-optional-recipes(source) file-transfer 55856/55900.

Refs: docs/reviews/2026-11-01-maturity-review/01-adapters-browser-transfer.md
2026-11-01 23:14:47 +09:00
DongHyeonkaandClaude Opus 5.5 dde0d2b44e perf(browser-transfer): bound concurrent image probes and reuse a passed probe (01-11)
A PRIMARY_REQUIRED resolve() downloaded and decoded the primary candidate on
every call with no concurrency limit. Probes now wait for one of
maxConcurrentProbes slots (default 4) and a passed probe is reused for the
same asset and preset while the capability is valid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 22:44:32 +09:00
DongHyeonkaandClaude Opus 5.5 818cbd3839 fix(browser-transfer): allow a PRIMARY_REQUIRED probe only with an exact-size fit (Q-6.1-7)
The probe accepts a decode only when it matches the primary candidate's
pixel size exactly. fit inside/outside keep the source ratio, so for any
asset whose ratio differs the preset could only fail with
INTEGRITY_FAILED, and PRIVATE_SIGNED forces the probe. Per D-12 the
registry now rejects PRIMARY_REQUIRED unless fit is cover, contain or
fill; ratio-preserving fits stay allowed on presets without the probe.
README and the architecture doc state the rule.

Verified: RED test "allows a PRIMARY_REQUIRED probe only with an
exact-size fit" (inside/outside were accepted) + all gates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 13:32:37 +09:00
donghyeon-ka 5cc41467ae refactor: 프론트 템플릿 리펙토링 2026-09-18 15:16:58 +09:00
DongHyeonkaandClaude Opus 5 cc91fc6ae0 fix: settle a shared abort operation by observation, not by drain count
The primitive decided a raced outcome by draining a hard-coded four
microtasks and then asking whether the task had landed. That made the
answer depend on scheduling rather than on what was observed: a caller
abort could fix the terminal owner synchronously and a rejection later in
the same call stack still won the public result, so `race()` disagreed
with `terminal()` and the failure taxonomy a caller received depended on
microtask ordering.

Task settlement and the terminal event now share one settle-once state
machine. Whichever callback actually runs first owns the outcome; a value
that loses is compensated exactly once and a rejection that loses is
absorbed, so neither can surface late.

The three consumers that kept their own copies of these mechanics move
onto it. The Image probe and the Resumable fetch transport attached their
caller listener before installing the timer, so a scheduler that threw
rejected the public `probe()`/`execute()` promise natively and left the
listener on the caller's signal; both now close atomically inside their
own Result vocabulary and start no fetch. `snapshotAbortTimers` binds the
scheduler callables once at construction, so replacing a method after
composition can no longer change how work already in flight is bounded.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 01:24:53 +09:00
DongHyeonkaandClaude Opus 5 5a76f95291 fix: bound resumable teardown, image concurrency and delivery leases
TR-RR-06. dispose() now bounds its drain with a cleanupDeadlineMs from policy
and returns the result, so a non-cooperative mutation lock or provider can no
longer make teardown unbounded and an unproved drain is reported as still
CLOSING instead of closed over. The checkpoint store stays open in that case,
because something can still write to it. An abort is admitted physical work
like an upload, so it joins the tracked set rather than being stepped over.

TR-RR-07. The verification slot belongs to the raw verifier, not the wrapper.
Releasing it when the caller's wait expired let an abandoned verification keep
running while a new one was admitted, so repeated aborts produced more
concurrent physical work than the configured cap allows. The slot is now
released only once the raw tasks settle.

TR-RR-04. A presigned byte source owns a fetch reader and a capability lease and
its port requires close(); the delivery consumer never called it. The closeable
subtype is lost in the FileByteSource projection, so a holder keeps it from the
moment the lease exists and the outermost finally closes it exactly once — on
success, validation failure, writer failure and abort alike.

check:adapter-inventory now also fails if the shared abortable-operation
primitive has no production importers. It was safe to add only once the
presigned subsystems actually migrated onto it; a gate that fails CI for a
documented, unfixed defect reports the wrong thing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-14 17:22:45 +09:00
DongHyeonkaandClaude Opus 5 fb5b449031 fix: apply the recorded private Cache-Control matrix to image probes
TR-RR-09. The documented BT-IMG-02 contract requires a private response to
carry no-store and fail closed when any directive that describes cacheability
accompanies it. The probe checked only that no-store was present and public was
absent, and the suite pinned the contradictory "private, no-store" as a success.
Both now follow the recorded contract: only no-store and syntactically valid
unknown extensions are admitted, and public, private, immutable, max-age,
s-maxage, no-cache, must-revalidate and proxy-revalidate each fail closed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-14 14:14:41 +09:00
DongHyeonkaandClaude Opus 5 000a2581af fix: complete presigned capability and upload transport contracts
BT-PRE-02: add the top-level PRESIGNED_TRANSFER_V1 protocol literal to the
capability request and response. A missing, V0 or V2 envelope is closed as
POLICY_REJECTED before the vault registers anything. The server negotiates by
request shape; fields are never dual-emitted into a strict decoder, and the
nested PRESIGNED_MULTIPART_V1 binding protocol is unchanged.

BT-PRE-03: aborting a controller does not settle a fetch that ignores its
signal, so both presigned scopes now race the task, cancel a late response body
and survive a throwing scheduler without leaking the external abort listener.

BT-PRE-04: the vault owns its registration invariants, re-checking method,
href/origin/path agreement, embedded credentials, byte bounds, digest shape and
expiry, so a second issuer cannot register a weaker capability of the same type.

BT-PRE-05: decode each path segment once and require it to round-trip through
the canonical uppercase percent encoder, closing %2f, %5c, %252e%252e, mixed-case
escapes and encoded NUL while still admitting valid opaque UTF-8 segments.

BT-UP-02: inject and snapshot the upload transport clock and scheduler, so
Retry-After delta-seconds and HTTP-date resolve against the same captured now
and a clock rollback clamps to zero instead of producing a negative delay.

BT-IMG-01: make the image resolve() lifetime signal required, replacing the
hidden PRIMARY_REQUIRED preset precondition with a type-level one, and add the
negative typecheck fixture and gate that prove it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-14 02:19:00 +09:00
DongHyeonkaandClaude Opus 5 cc4e875c2d fix: bound browser transfer leases and effect reporting
BT-X-01: add the shared abortable-operation utility with golden tests for first
terminal owner, idempotent close, listener and timer cleanup under a throwing
scheduler, observed late rejection and late-handle compensation. It carries no
subsystem result taxonomy.

BT-PRE-01: make the presigned download lease lazy and single-start. open() now
validates, claims and consumes the capability without any network I/O; the
fetch, the transfer deadline and the expiry recheck happen at first stream
consumption. The source gained close(), which discards an unused lease with no
I/O and otherwise cancels the body and releases the scope exactly once.

BT-UP-01: require removeEventListener in the AbortSignal structural guard and
isolate release cleanup so a hostile facade cannot replace a typed terminal
result with a rejection.

BT-UP-03: deleteDatabase cannot be cancelled after dispatch, so a blocked
deadline now returns PENDING with effect UNKNOWN instead of a failure that reads
as NOT_APPLIED. A realm-scoped (factory, databaseName) registry prevents
recreating the partition until the native request settles.

BT-UP-04: reject non-finite and negative upload clocks as a dependency failure
instead of letting them bypass every capability expiry comparison.

BT-IMG-02: replace the naive Cache-Control quote stripping with a quote- and
escape-aware tokenizer, so max-age="60 or 60" is no longer read as 60 and a
comma inside a quoted extension is not a directive boundary.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-14 00:13:54 +09:00
donghyeon-ka 6c52cdb916 feat: 기능 추가 과정중 2026-07-30 15:58:20 +09:00