Commit Graph
19 Commits
Author SHA1 Message Date
DongHyeonkaandClaude Opus 5.5 d76653bfcd fix(browser-files): observe dismissals as DISMISSED instead of SUCCEEDED (02-06)
A cancelled save dialog and a browser handoff were both recorded as
DOWNLOAD SUCCEEDED, so the cancel rate hid inside the handoff success rate.
BrowserDataObservation.outcome gains DISMISSED (additive).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 00:20:17 +09:00
DongHyeonkaandClaude Opus 5.5 0b41cb38af fix(browser-files): report exhausted object URL leases as retryable (02-04)
Preview and download share one lease registry and download leases stay for a
30 s grace, so running out of slots clears on its own. Only a Blob above the
single-lease ceiling stays LIMIT_EXCEEDED without retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 00:08:33 +09:00
DongHyeonkaandClaude Opus 5.5 c9be8d65e4 fix(browser-files): return ABORTED instead of a leaked preview lease after a same-turn abort (02-01)
create() checked the signal only before resolving the file, so an abort in
the same turn still produced a lease the caller never released. Each leak
used one of the 16 object URL slots shared with downloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 23:57:04 +09:00
DongHyeonkaandClaude Opus 5.5 a58197844b perf(browser-files): wait on picker aborts through the kernel operation (R3-2)
The native-input wait and the system-picker wait no longer add their own
abort listeners; both use createAbortableOperation, and dispose closes the
operation. Results stay ABORTED for caller abort and for dispose. Adds a
characterization test for dispose while the enhanced picker is pending.
Hand-rolled abort ratchet 16 -> 15.

file-transfer gzip: 54500 -> 54499

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 15:33:13 +09:00
DongHyeonkaandClaude Opus 5.5 e96f78b8e0 perf(file-transfer): fold duplicated local helpers into one per module (Q-B)
- browser-file-picker: the native and enhanced pickers carried two copies of
  the same selection observation (#finishObservation / #observe); one
  module-level observeSelection replaces both.
- indexeddb-checkpoint-store: read / compareAndSwap / remove /
  removeUnreadable each repeated acquire -> transaction -> get -> onerror;
  withCheckpointRow does that once and hands the row to the operation, still
  inside the same transaction. deleteCheckpointRow shares the delete tail.
- resumable-upload-runtime: the four checkpoint removals that remap to
  UPLOAD_RECONCILE go through removeCheckpoint.
- image-cdn-runtime: the verification deadline reuses
  combineImageRuntimeAbortSignals instead of a second listener loop; the
  verifier-coverage check throws its TypeError from one place; the registry
  id pattern is one constant instead of three inline literals.
- presigned executor / capability provider: reuse checkpoint-schema's
  SHA256_HEX and isSafeUploadReceiptToken instead of equal local patterns.

file-transfer reference runtime: 54754 -> 54562 gzip bytes (budget 54600).
Other reference runtimes unchanged.

Verified: check:architecture, check:types:app, check:types:test, lint,
test:unit, test:component, check:adapter-inventory, build,
check:optional-recipes (file-transfer 54562/54600, offline-indexeddb
35854/36000, realtime 39685/40000, service-worker-pwa 9500/10000),
test:recipes, check:types:recipes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 14:49:19 +09:00
DongHyeonkaandClaude Opus 5.5 09402478d6 perf(file-transfer): share byte-bucket, integer and control-character guards (Q-B)
Identical private copies lived in both file adapters and in five
browser-transfer modules. One copy each now lives next to isValidByteLength
in the browser-file-storage port (outside every reference-runtime source
root, so it adds no namespace export):
- byteBucket (browser-files/file-observer, presigned/http-common) ->
  browserDataByteBucket; both modules re-export it under the old name
- positiveSafeInteger / nonNegativeSafeInteger (checkpoint-schema,
  http-control-plane-adapter, runtime-policy, upload-byte-source,
  image-cdn-policy, browser-image-probe, file-policy's isPositiveSafeInteger)
  -> isPositiveSafeInteger / isNonNegativeSafeInteger
- hasControlCharacters (image-cdn-policy) and
  hasForbiddenHeaderValueCharacter (fetch-json-transport) -> hasControlCharacter

Same predicates, same results for every input.

file-transfer reference runtime: 55306 -> 55154 gzip bytes.
offline-indexeddb: 35957 -> 35951. realtime, service-worker-pwa unchanged.

Verified: check:architecture, check:types:app, check:types:test, lint,
test:unit, test:component, check:adapter-inventory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 14:49:19 +09:00
DongHyeonkaandClaude Opus 5.5 7b6fc4796e perf(file-transfer): stop exporting helpers no other module imports (Q-B)
The reference-runtime measurement exposes every export of every catalog
module through a namespace object, so an export nobody imports still costs
bytes. Made module-private (only used inside their own file, not by src,
tests or scripts):
- download-input-validation.ts: SHA256, snapshotDownloadSource,
  validPresignedCapabilityForInput, safeOpaqueId
- checkpoint-schema.ts: RECEIPT_TOKEN, isUploadPartDescriptor,
  partMatchesFingerprint

Barrel (index.ts) exports are untouched.

file-transfer reference runtime: 55382 -> 55306 gzip bytes. Other reference
runtimes unchanged.

Verified: check:architecture, check:types:app, check:types:test, lint,
test:unit, test:component, check:adapter-inventory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 14:49:19 +09:00
DongHyeonkaandClaude Opus 5.5 042427c887 refactor(browser-files): share the media-type, token and limit checks (Q-6.2-12)
The exact media-type regex lived in object-url-lease.ts,
browser-file-policy-registry.ts and the download validation;
safeOpaqueValue (vault) and safeGeneratedToken (download) were the same
regex; and five modules each defined their own positive-safe-integer check
(isPositiveByteLimit included). file-policy.ts now exports one copy of each:
EXACT_MEDIA_TYPE, isSafeGeneratedToken, isPositiveSafeInteger.
ObjectUrlLeaseRegistry.create also loses an inner revoke branch that could
never run (it required a non-empty string inside a "not a non-empty string"
guard).

cache-storage/public-cache-policy.ts keeps its private positiveSafeInteger:
adapters may not import another adapter's module.

Verified: a characterization test (unsafe reference -> UNAVAILABLE, 128-char
token accepted, empty object URL -> no revoke, fractional/zero limits and a
wildcard download media type rejected) passes on the code before and after.
Lane gates pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 13:39:59 +09:00
DongHyeonkaandClaude Opus 5.5 4093ee8fc2 refactor(cache-storage): split the cache and download codecs out of their adapters (Q-6.2-11)
public-response-cache-adapter.ts (1986 lines) and download-delivery-adapter.ts
(1491 lines) mixed the facade with codecs and validators. Moved verbatim:
- cache-storage/public-cache-codec.ts: manifest normalization and canonical
  digest input, marker/active-pointer validation, bounded control JSON,
  owned cache names, CacheValidationFailure -> Result mapping.
- cache-storage/public-cache-response-validation.ts: response admission
  (status, directives, Content-Type, Vary, bounded body, digest).
- browser-files/download-input-validation.ts: request snapshot, input/limit
  checks, presigned and browser-managed capability validation, handoff target.
The adapters drop to 1164 and 1157 lines.

Two non-verbatim edits: validateDownloadInput takes a structural
DownloadInputValidationOptions instead of DownloadDeliveryAdapterOptions (no
import cycle), and readBodyBounded races reads on the kernel
createAbortableOperation instead of its own abort listener. Moving it out of
a primitive-importing file would otherwise have raised the hand-rolled abort
ratchet to 20/19; the abort outcome (ABORTED, reader cancelled) is unchanged.

Verified: characterization tests added first and passing before the move
(cache manifest/response/control-JSON failure codes, lookup abort during a
pending body read; download input validation codes); a line diff confirms the
moved code is verbatim apart from the two edits above. Inventory 139/139,
lane gates, check:browser-file-storage-boundaries pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 13:39:59 +09:00
DongHyeonkaandClaude Opus 5.5 d67fe1ab35 perf(browser-files): truncate filenames in one pass and sanitize once (Q-6.2-10)
sanitizeSuggestedFileName dropped one code point at a time and re-encoded the
whole name each round, so a 100k-character server-supplied name took ~10^10
steps. truncateUtf8 now walks the code points once, counting UTF-8 bytes, and
cuts at the longest fitting prefix (trailing whitespace trimmed, as before).
The fallback base name uses the same helper. deliver() also sanitized the
name twice (validation, then again for use); validateDownloadInput now
returns the sanitized name and deliverActive uses it.

Verified: new unit test pins results for ASCII, Hangul, emoji and the
whitespace-trim case, and asserts a 5k-character name needs <10
TextEncoder.encode calls (RED before: 4827). Lane gates pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 13:39:59 +09:00
DongHyeonkaandClaude Opus 5.5 4c812a4213 fix(browser-files): drop the focus fallback once native cancel is seen (Q-6.2-8)
NativeInputFilePicker installed the window-focus fallback on every select,
even in engines that dispatch a native `cancel`. A provider that returns
focus first and dispatches `change` only after fetching the file (Android
cloud providers) was reported as DISMISSED after the grace window. The picker
now remembers that it observed a native `cancel` and stops installing the
focus fallback for later selections.

Verified: new unit test (cancel seen, then focus + fallback timer + late
change) returned DISMISSED before and SELECTED now. Lane gates pass
(tests/component/router.test.tsx timed out once under full-gate load and
passed on rerun).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 13:39:59 +09:00
DongHyeonkaandClaude Opus 5.5 89e90cc990 fix(browser-files): race deliveries and vault reads on the kernel owner (Q-6.2-7)
download-delivery-adapter and browser-file-vault each carried their own
combineAbortSignals/awaitWithSignal copies. Two gaps followed:
- a presigned lease that resolved after the abort but before the delivery's
  finally was seen by neither compensateLateSource (holder not yet closed) nor
  closeHeldSource (lease never adopted), so it leaked;
- a writable from handle.createWritable() that arrived after the abort was
  never aborted (Chrome keeps a .crswap file).

Each delivery and each vault stream now owns a createAbortableOperation joined
to the caller signal; dispose() closes the live owners. Every await goes
through owner.race, and late leases/writables are compensated by the race.
The hand-rolled abort ratchet drops 21 -> 19.

Verified: two new download tests (same-turn late lease, late writable) failed
before (close 0 times, no abort) and pass now; a new vault characterization
test (caller abort / dispose during a pending read) passes before and after.
All lane gates pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 13:39:59 +09:00
DongHyeonkaandClaude Opus 5.5 de954d2ebf fix(browser-files): stop binding file pickers to the options object (R-2.4)
EnhancedFilePicker and the download adapter captured showOpenFilePicker
and showSaveFilePicker with `.bind(options)`. A Window operation throws
TypeError("Illegal invocation") when `this` is not the Window, so passing
`window.showOpenFilePicker` / `window.showSaveFilePicker` as-is failed on
every call.

Both are now captured with `.bind(undefined)`. They are still captured at
construction, and Web IDL maps an undefined receiver to the global object,
so the native functions can be injected directly.

Verified: "calls an injected window picker without rebinding its
receiver" and "calls an injected window save picker without rebinding its
receiver" use a fake picker that throws "Illegal invocation" unless `this`
is undefined or globalThis. Both failed before the fix (ok:false) and pass
now. check:architecture, check:types:app, check:types:test, lint,
test:component pass. test:unit passes except removal-fixture, which needs
generated artifacts/release files that a fresh worktree lacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 12:15:58 +09:00
DongHyeonkaandClaude Opus 5.5 54abaec12a fix(browser-files): resolve bounded object URL source inside the result boundary (R-2.1)
boundedObjectUrlHandoff called resolveByteSource outside its try/finally.
When the authorized source open threw or was aborted, deliver() rejected
with an AbortError instead of returning {ok:false, ABORTED}, the observer
saw nothing, and the holder was never latched closed, so a lease that
arrived later was never closed by compensateLateSource.

Source resolution now runs inside the existing try/catch/finally, the same
shape promptAndStream already uses. The explicit closeHeldSource calls on
the early-return paths are covered by the finally.

Verified: "resolves ABORTED and closes a late lease when a bounded source
open is aborted" failed before the fix (promise rejected with AbortError)
and passes now. check:architecture, check:types:app, check:types:test,
lint, test:component pass. test:unit passes except removal-fixture, which
needs generated artifacts/release files that a fresh worktree lacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 12:15:58 +09:00
donghyeon-ka ec7f20e2ee refactor: 프론트엔드 리펙토링 2026-09-18 22:05:42 +09:00
DongHyeonkaandClaude Opus 5 39a4a973a8 fix: hold transfer inputs and raw transfer work to what was verified
The capability vault checked an issuer's registration and then read it
again to store it, including its nested header rows. A stateful issuer
could show an allowed header set to the forbidden-header check and hand
`Authorization` to the copy, so the vault stored — and the executor sent —
a credential no rule had ever seen. The registration and everything nested
in it is now snapshotted once, and only that snapshot is validated,
frozen and stored.

The upload control plane had the same shape one level down: a `sessionId`
that answered `session_01` to the regex and `../../unsafe` to the result
snapshot reached a success receipt.

Two lifetimes were also unowned. A download source lease that resolved
after the caller's abort never reached the holder, so nothing closed it
and its fetch reader and capability lease outlived the terminal result; a
compensator sharing the holder's close-once latch now closes it exactly
once. And `dispose()` proved quiescence from the wrapper registry alone,
so a provider that ignored its attempt deadline let teardown report a
drained runtime and close the checkpoint store while the provider was
still running. Raw provider promises are now their own registry and the
drain must prove both.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 01:26:01 +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 ba79060a83 fix: execute canonical browser download targets
Replace the boolean browser-managed target validator with
resolveBrowserManagedTarget, which returns the parsed canonical absolute URL,
and hand that exact value to the host. Previously the raw href was passed on,
so a relative target was re-resolved against document.baseURI and a hostile
<base> could send the navigation to an origin the policy never approved.

STO-08 stays UNVERIFIED: the capability spec does not exercise the system
picker, so the receiver-binding hypothesis is neither reproduced nor refuted
and no source change was made for it.

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