chore: sync the frontend template from ebea300 to af3d8e6
Carries 359 template commits, tag v0.2.0 plus one documentation commit: the generator-built feature index with its app, bounded-context and feature declarations, the src/platform kernel and scale tooling, the 2026-09-24 src review fixes, and the 2026-09-25 maturity review round with its CHANGELOG [보안]/[계약] rows. 691 of the 824 template paths are applied, 85 of them merged with product changes; 127 are not carried. Product identity is unchanged: name, version 0.1.0, routes, design and the TechLog domain. Three decisions worth naming. TechLog stays composed directly, as the last two syncs recorded; its directory carries a NOT_INSTALLED marker that says so, and every installed-* composer takes the template's projection with TechLog added on top. The reference sample is no longer installed: the template now installs a feature only through feature-module.ts and context-routes.ts, which load the screens this product deleted, so its three operations, six schemas and one topic leave the registries, recorded as registry change evidence. And AppRouter mounts the platform and TechLog routes only; the template's bounded-context route gateway waits for a generator-installed feature. Required fixes: readSubject on the BFF session owner (without it every HTTP Studio session would close as integration-failed), zod through the facade in nine TechLog files, noUnusedLocals, and public/config.json written out to match the local profile. Derived baselines were recomputed after reproducing both sides' values: CI contract 101 commands / 106 references / 141 artifacts, gate shape c9adcf85; registry approval 2dc6c3a3; the runtime config schema baseline equals the schema at8210d48. Verified here: types, lint, architecture, adapter inventory, CI contract, i18n, design system, diagnostics, browser security, dev release manifest, TechLog contract and build pass; 220 component, 155 integration, 15 contract, 418 TechLog, 43 reference-feature, 18 recipe and 46 release-coherence tests pass, and 2381 of 2383 unit tests. Reproduced at8210d48first and unchanged: check:registries (byte-identical), test:runtime-schema, verify:documentation. Brought by the template and escalated rather than suppressed: check:request-fanout on TechLog's cursor pagination, check:remediation-ledger (fails upstream too), the shared-chunk hash test, and the registry-dependent sample removal and second-feature tests. Playwright suites were not run. Full record, the five open questions and the follow-ups in docs/operations/template-sync-2026-09-29.md. (cherry picked from commit b2170cf265dea45dc9cc05d3c61e627e97f31cdb)
This commit is contained in:
@@ -5,32 +5,23 @@ import type {
|
||||
PresignedUploadPartPort,
|
||||
} from "../../src/application/ports/browser-transfer/presigned-transfer.ts";
|
||||
import type {
|
||||
ResumableUploadCheckpoint,
|
||||
ResumableUploadCheckpointStore,
|
||||
ResumableUploadControlPlane,
|
||||
ResumableUploadSource,
|
||||
UploadPartExecutor,
|
||||
UploadPartReceipt,
|
||||
UploadProviderResult,
|
||||
UploadSession,
|
||||
} from "../../src/application/ports/browser-transfer/resumable-upload.ts";
|
||||
import { RESUMABLE_UPLOAD_PROTOCOL } from "../../src/application/ports/browser-transfer/resumable-upload.ts";
|
||||
import type {
|
||||
BrowserDataObservation,
|
||||
BrowserDataResult,
|
||||
} from "../../src/application/ports/browser-file-storage/shared.ts";
|
||||
import {
|
||||
browserDataFailure,
|
||||
browserDataSuccess,
|
||||
} from "../../src/adapters/browser-file-storage/result.ts";
|
||||
import { createIndexedDbResumableUploadCheckpointStore } from "../../src/adapters/browser-transfer/resumable-upload/indexeddb-checkpoint-store.ts";
|
||||
import { createPresignedUploadPartExecutor } from "../../src/adapters/browser-transfer/resumable-upload/presigned-upload-part-executor.ts";
|
||||
import { createResumableUploadRuntime } from "../../src/adapters/browser-transfer/resumable-upload/resumable-upload-runtime.ts";
|
||||
import { resolveResumableUploadRuntimePolicy } from "../../src/adapters/browser-transfer/resumable-upload/runtime-policy.ts";
|
||||
import type {
|
||||
UploadCancellationChannel,
|
||||
UploadCancellationListener,
|
||||
} from "../../src/adapters/browser-transfer/resumable-upload/upload-cancellation-channel.ts";
|
||||
import type { UploadMutationLock } from "../../src/adapters/browser-transfer/resumable-upload/upload-mutation-lock.ts";
|
||||
import { MemoryIndexedDbFactory } from "../helpers/memory-indexeddb.ts";
|
||||
|
||||
import {
|
||||
activeSignal,
|
||||
@@ -113,6 +104,42 @@ describe("production resumable upload runtime", () => {
|
||||
runtimePolicy({ maxInFlightBytes: 15 }),
|
||||
),
|
||||
).toThrow(TypeError);
|
||||
// R-1.3. partSize 4 × concurrency 4 × copyFactor 4 = 64 > 48 is refused
|
||||
// up front instead of being silently clamped to fewer workers.
|
||||
expect(() =>
|
||||
resolveResumableUploadRuntimePolicy(
|
||||
runtimePolicy({ maxConcurrency: 4 }),
|
||||
),
|
||||
).toThrow(TypeError);
|
||||
});
|
||||
|
||||
// R-1.3. The default memory budget (20 MiB / (5 MiB × 4)) runs one worker,
|
||||
// but createSession asked the server for 3.
|
||||
it("requests the concurrency the default policy can actually run", async () => {
|
||||
const harness = createControlHarness({ serverMaxConcurrency: 1 });
|
||||
const createSession = vi.spyOn(harness.control, "createSession");
|
||||
const runtime = createResumableUploadRuntime({
|
||||
controlPlane: harness.control,
|
||||
partExecutor: executorFor(harness),
|
||||
checkpoints: new MemoryCheckpointStore(),
|
||||
mutationLock: noContentionLock,
|
||||
crypto,
|
||||
// Only the capability skew differs from the default, to fit the harness.
|
||||
policy: { capabilityRefreshSkewMs: 5 },
|
||||
now: () => 1_000,
|
||||
sleep: async () => {},
|
||||
});
|
||||
const result = await runtime.upload({
|
||||
uploadKey: "upload_key_default_policy",
|
||||
purpose: "attachment",
|
||||
mediaType: "application/octet-stream",
|
||||
source: rangeSource(new Uint8Array([1, 2, 3, 4, 5])),
|
||||
signal: activeSignal,
|
||||
});
|
||||
expect(result).toMatchObject({ ok: true });
|
||||
expect(createSession).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ requestedMaxConcurrency: 1 }),
|
||||
);
|
||||
});
|
||||
|
||||
it("uploads bounded range parts, obeys the server concurrency ceiling and completes as quarantined", async () => {
|
||||
@@ -189,6 +216,61 @@ describe("production resumable upload runtime", () => {
|
||||
expect(serialized).not.toContain("etag-part");
|
||||
});
|
||||
|
||||
// Q-6.1-5. A sibling worker used to keep retrying its part until its own
|
||||
// attempt deadline; the first failure now aborts the whole transfer.
|
||||
it("aborts in-flight sibling workers as soon as one part fails", async () => {
|
||||
const harness = createControlHarness({ serverMaxConcurrency: 2 });
|
||||
let secondStarted: () => void = () => {};
|
||||
const secondRunning = new Promise<void>((resolve) => {
|
||||
secondStarted = resolve;
|
||||
});
|
||||
let siblingAborted = false;
|
||||
const runtime = createResumableUploadRuntime({
|
||||
controlPlane: harness.control,
|
||||
partExecutor: {
|
||||
async uploadPart(input) {
|
||||
if (input.part.partNumber === 1) {
|
||||
await secondRunning;
|
||||
return browserDataFailure("POLICY_REJECTED", "UPLOAD_PART");
|
||||
}
|
||||
secondStarted();
|
||||
return await new Promise((resolve) => {
|
||||
input.signal.addEventListener(
|
||||
"abort",
|
||||
() => {
|
||||
siblingAborted = true;
|
||||
resolve(browserDataFailure("ABORTED", "UPLOAD_PART"));
|
||||
},
|
||||
{ once: true },
|
||||
);
|
||||
});
|
||||
},
|
||||
},
|
||||
checkpoints: new MemoryCheckpointStore(),
|
||||
mutationLock: noContentionLock,
|
||||
crypto,
|
||||
policy: runtimePolicy({ providerAttemptTimeoutMs: 60_000 }),
|
||||
now: () => 1_000,
|
||||
random: () => 0,
|
||||
sleep: async () => {},
|
||||
});
|
||||
|
||||
const uploading = runtime.upload({
|
||||
uploadKey: "upload_key_01",
|
||||
purpose: "attachment",
|
||||
mediaType: "application/octet-stream",
|
||||
source: rangeSource(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9])),
|
||||
signal: activeSignal,
|
||||
});
|
||||
|
||||
await vi.waitFor(() => expect(siblingAborted).toBe(true));
|
||||
// The caller sees the part that failed, not the sibling's ABORTED.
|
||||
await expect(uploading).resolves.toMatchObject({
|
||||
ok: false,
|
||||
error: { code: "POLICY_REJECTED", operation: "UPLOAD_PART" },
|
||||
});
|
||||
});
|
||||
|
||||
it("supports replayable FileByteSource without retaining the whole file", async () => {
|
||||
const checkpoints = new MemoryCheckpointStore();
|
||||
const harness = createControlHarness();
|
||||
@@ -215,6 +297,36 @@ describe("production resumable upload runtime", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// R-1.4. The size check used to throw inside request validation and surface
|
||||
// as INVALID_INPUT; a file over the policy limit is LIMIT_EXCEEDED.
|
||||
it("reports a source over maxFileBytes as LIMIT_EXCEEDED", async () => {
|
||||
const harness = createControlHarness();
|
||||
const createSession = vi.spyOn(harness.control, "createSession");
|
||||
const runtime = createResumableUploadRuntime({
|
||||
controlPlane: harness.control,
|
||||
partExecutor: executorFor(harness),
|
||||
checkpoints: new MemoryCheckpointStore(),
|
||||
mutationLock: noContentionLock,
|
||||
crypto,
|
||||
// A valid policy already bounds the part count by maxFileBytes.
|
||||
policy: runtimePolicy({ maxFileBytes: 4 }),
|
||||
now: () => 1_000,
|
||||
sleep: async () => {},
|
||||
});
|
||||
const result = await runtime.upload({
|
||||
uploadKey: "upload_key_too_large",
|
||||
purpose: "attachment",
|
||||
mediaType: "application/octet-stream",
|
||||
source: byteStreamSource(new Uint8Array([1, 2, 3, 4, 5])),
|
||||
signal: activeSignal,
|
||||
});
|
||||
expect(result).toMatchObject({
|
||||
ok: false,
|
||||
error: { code: "LIMIT_EXCEEDED" },
|
||||
});
|
||||
expect(createSession).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("fails closed when server list-parts disagrees with the current source manifest", async () => {
|
||||
const checkpoints = new MemoryCheckpointStore();
|
||||
const harness = createControlHarness({
|
||||
@@ -248,12 +360,14 @@ describe("production resumable upload runtime", () => {
|
||||
source: rangeSource(new Uint8Array([1, 2, 3, 4])),
|
||||
signal: activeSignal,
|
||||
});
|
||||
// 01-05. Calling upload() again reads the same server parts, so the way
|
||||
// out is abort() and a fresh session.
|
||||
expect(result).toMatchObject({
|
||||
ok: false,
|
||||
error: {
|
||||
code: "INTEGRITY_FAILED",
|
||||
operation: "UPLOAD_RECONCILE",
|
||||
recovery: "RECONCILE",
|
||||
recovery: "RESTART",
|
||||
},
|
||||
});
|
||||
expect(partExecutor.uploadPart).not.toHaveBeenCalled();
|
||||
@@ -689,6 +803,56 @@ describe("production resumable upload runtime", () => {
|
||||
);
|
||||
});
|
||||
|
||||
// Q-6.1-6. A row this build cannot read (here a newer schemaVersion left by
|
||||
// a rolled-back release) used to fail both upload and abort with
|
||||
// CORRUPT_DATA until the whole partition was deleted.
|
||||
it("removes an unreadable checkpoint row on abort and reports ORPHANED", async () => {
|
||||
const memory = new MemoryIndexedDbFactory();
|
||||
const checkpoints = createIndexedDbResumableUploadCheckpointStore({
|
||||
scope: {
|
||||
authorityToken: "authority_token_01",
|
||||
namespaceToken: "namespace_token_01",
|
||||
partitionToken: "partition_token_01",
|
||||
},
|
||||
factory: memory.factory,
|
||||
});
|
||||
// Opens the database so the object stores exist before seeding.
|
||||
expect(await checkpoints.read("upload_key_unreadable")).toEqual({
|
||||
ok: true,
|
||||
value: null,
|
||||
});
|
||||
memory.seed("checkpoints", {
|
||||
schemaVersion: 2,
|
||||
uploadKey: "upload_key_unreadable",
|
||||
revision: 7,
|
||||
state: "PAUSED",
|
||||
});
|
||||
const harness = createControlHarness();
|
||||
const serverAbort = vi.spyOn(harness.control, "abort");
|
||||
const runtime = createResumableUploadRuntime({
|
||||
controlPlane: harness.control,
|
||||
partExecutor: executorFor(harness),
|
||||
checkpoints,
|
||||
mutationLock: noContentionLock,
|
||||
crypto,
|
||||
policy: runtimePolicy(),
|
||||
now: () => 1_000,
|
||||
sleep: async () => {},
|
||||
});
|
||||
|
||||
expect(
|
||||
await runtime.abort({
|
||||
uploadKey: "upload_key_unreadable",
|
||||
signal: activeSignal,
|
||||
}),
|
||||
).toEqual({ ok: true, value: { state: "ORPHANED" } });
|
||||
// No session id can be read from the row, so the server is not called.
|
||||
expect(serverAbort).not.toHaveBeenCalled();
|
||||
expect(memory.readRaw("checkpoints", "upload_key_unreadable")).toBe(
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
|
||||
it("interrupts a same-runtime active upload before explicit abort waits for the key lock", async () => {
|
||||
const checkpoints = new MemoryCheckpointStore();
|
||||
const harness = createControlHarness();
|
||||
@@ -910,8 +1074,10 @@ describe("production resumable upload runtime", () => {
|
||||
let forwardedUploadBinding = "";
|
||||
let forwardedSessionId = "";
|
||||
let forwardedRequestBinding = "";
|
||||
let forwardedBytes: Uint8Array | undefined;
|
||||
const port: PresignedUploadPartPort = {
|
||||
async put(input) {
|
||||
forwardedBytes = input.bytes;
|
||||
forwardedUploadBinding = input.uploadBindingSha256;
|
||||
forwardedSessionId = input.sessionId;
|
||||
forwardedRequestBinding = input.requestBindingSha256;
|
||||
@@ -942,6 +1108,7 @@ describe("production resumable upload runtime", () => {
|
||||
expectedSha256: "a".repeat(64),
|
||||
expiresAtEpochMs: 2_000,
|
||||
} as unknown as PresignedUploadPartCapability;
|
||||
const partBytes = new Uint8Array([1, 2, 3, 4]);
|
||||
const result = await executor.uploadPart({
|
||||
protocol: RESUMABLE_UPLOAD_PROTOCOL,
|
||||
capability,
|
||||
@@ -962,7 +1129,7 @@ describe("production resumable upload runtime", () => {
|
||||
byteLength: 4,
|
||||
checksumSha256: "a".repeat(64),
|
||||
},
|
||||
bytes: new Uint8Array([1, 2, 3, 4]),
|
||||
bytes: partBytes,
|
||||
idempotencyKey: "upload-part-idempotency-01",
|
||||
signal: activeSignal,
|
||||
});
|
||||
@@ -970,6 +1137,9 @@ describe("production resumable upload runtime", () => {
|
||||
ok: true,
|
||||
value: { receiptToken: "etag.response-01" },
|
||||
});
|
||||
// Q-6.1-3b. The presigned port snapshots the bytes itself, so the bridge
|
||||
// forwards the part buffer instead of adding a second copy per attempt.
|
||||
expect(forwardedBytes).toBe(partBytes);
|
||||
expect(forwardedUploadBinding).toBe("b".repeat(64));
|
||||
expect(forwardedSessionId).toBe("session_01");
|
||||
expect(forwardedRequestBinding).toBe("c".repeat(64));
|
||||
|
||||
Reference in New Issue
Block a user