Merge remote-tracking branch 'origin/main' into fix/r9-precache-bound-diagnostics
frontend-quality-gates / merge / static checks (pull_request) Successful in 1m44s
frontend-quality-gates / merge / tests (pull_request) Successful in 17m15s
frontend-quality-gates / merge / browser tests (pull_request) Successful in 6m19s
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Skipped
frontend-quality-gates / main / self-tests and removal drills (pull_request) Skipped
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Skipped
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Skipped
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Skipped
frontend-quality-gates / external-vulnerability-provider (pull_request) Skipped
frontend-quality-gates / external-provenance-provider (pull_request) Skipped
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Skipped
frontend-quality-gates / deploy-promoted-release (pull_request) Skipped
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Skipped
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Skipped
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Skipped
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Skipped
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Skipped
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Skipped
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Skipped

This commit is contained in:
DongHyeonka
2026-11-13 15:04:13 +09:00
47 changed files with 1825 additions and 217 deletions
+68 -5
View File
@@ -4,6 +4,7 @@ import path from "node:path";
import { z } from "zod";
import { DEPENDENCY_ADVISORIES_RECORD_PATH } from "../lib/dependency-advisories.ts";
import { selectRepositoryPaths } from "../lib/repository-layout.ts";
import { PROMOTION_FORMULA } from "../lib/promotion-readiness.ts";
import {
RELEASE_CANDIDATE_EVIDENCE_PATHS,
@@ -39,6 +40,7 @@ const ciActionRegistrySchema = z
setupNode: ciActionRegistrationSchema,
uploadArtifact: ciActionRegistrationSchema,
downloadArtifact: ciActionRegistrationSchema,
cache: ciActionRegistrationSchema,
})
.strict()
.readonly();
@@ -78,6 +80,12 @@ export const CI_ACTION_REGISTRY = parseCiActionRegistry({
revision: "75635f32b4c1c41c4b3d64e8f85210112ed4c9c7",
version: "v4 branch",
},
// The same pin as the paired backend's JDK, Gradle and Trivy caches.
cache: {
repository: "https://github.com/actions/cache",
revision: "0057852bfaa89a56745cba8c7296529d2fc39830",
version: "v4.3.0",
},
});
const actionIdByStepKind = Object.freeze({
@@ -85,6 +93,7 @@ const actionIdByStepKind = Object.freeze({
"setup-node": "setupNode",
upload: "uploadArtifact",
download: "downloadArtifact",
"dependency-cache": "cache",
} as const satisfies Readonly<Record<string, CiActionId>>);
export function resolveCiActionUses(actionId: CiActionId): string {
@@ -93,6 +102,42 @@ export function resolveCiActionUses(actionId: CiActionId): string {
return `${action.repository}@${action.revision}`;
}
/** An action a registered repository holds below its root (`actions/cache/restore`), at the same pin. */
export function resolveCiSubActionUses(actionId: CiActionId, subpath: "restore"): string {
const action = CI_ACTION_REGISTRY[actionId];
if (!action) throw new TypeError(`unknown CI action: ${String(actionId)}`);
return `${action.repository}/${subpath}@${action.revision}`;
}
/**
* Decision (2026-11-13, lead): the dependency cache is for the merge jobs
* only; the jobs that produce supply-chain evidence install fresh every time
* (docs/work/reference/decisions.md). A merge job restores the Node toolcache, the corepack
* download and pnpm's store and metadata cache (with its record of the
* lockfile's supply-chain verification) before setup-node, keyed by
* `.nvmrc` and the lockfile. Only a run on main saves an entry, the paired
* backend's rule for its caches: an entry is trusted input to the next run
* (the verification record lets pnpm skip the check), so a branch must not
* write one. The frozen install always runs after it: a missing or damaged
* entry only makes pnpm download what it lacks, and node_modules is the same
* (desktop, 2026-11-13: cold 13.9 s, warm 1.6 s, 40 broken store and 40
* broken metadata files 3.6 s with 27 packages fetched again; the same tree
* hash in all five installs).
*/
export const DEPENDENCY_CACHE = Object.freeze({
keyPrefix: "fe-dependencies-${{ runner.os }}-${{ runner.arch }}-",
// `.nvmrc` and `pnpm-lock.yaml` (config/repository-layout.json).
keyInputs: selectRepositoryPaths("dependency-cache-key"),
paths: Object.freeze(["/opt/hostedtoolcache/node", "/tmp/fe-dependency-cache"] as const),
environment: Object.freeze([
Object.freeze({ name: "COREPACK_HOME", value: "/tmp/fe-dependency-cache/corepack" }),
Object.freeze({ name: "PNPM_CONFIG_STORE_DIR", value: "/tmp/fe-dependency-cache/pnpm-store" }),
Object.freeze({ name: "PNPM_CONFIG_CACHE_DIR", value: "/tmp/fe-dependency-cache/pnpm-cache" }),
]),
/** The jobs that may hold the step: the three merge jobs. */
jobIds: Object.freeze(["merge_static", "merge_test", "merge_browser"] as const),
});
export function resolveCiStepActionUses(stepKind: string): string | null {
const actionId = actionIdByStepKind[stepKind as keyof typeof actionIdByStepKind];
return actionId ? resolveCiActionUses(actionId) : null;
@@ -333,6 +378,7 @@ const environmentBindingSchema = z
const checkoutStep = z.object({ kind: z.literal("checkout") }).strict();
const setupNodeStep = z.object({ kind: z.literal("setup-node") }).strict();
const frozenInstallStep = z.object({ kind: z.literal("frozen-install") }).strict();
const dependencyCacheStep = z.object({ kind: z.literal("dependency-cache") }).strict();
/**
* `image`: the job runs in Playwright's own image for the pinned
* @playwright/test version, which already holds the browsers and their OS
@@ -405,6 +451,7 @@ const deployStep = z
const jobStepSchema = z.discriminatedUnion("kind", [
checkoutStep,
dependencyCacheStep,
setupNodeStep,
frozenInstallStep,
browserInstallStep,
@@ -817,6 +864,16 @@ function validateContractSemantics(
}
}
validateJobStepKinds(job, issue);
if (job.steps.some(({ kind }) => kind === "dependency-cache")) {
if (!(DEPENDENCY_CACHE.jobIds as readonly string[]).includes(job.id)) {
issue(`the dependency cache is for the merge jobs only: ${job.id}`);
}
for (const { name } of DEPENDENCY_CACHE.environment) {
if (job.environment.some((binding) => binding.name === name)) {
issue(`job ${job.id} binds ${name}, which its dependency cache sets`);
}
}
}
for (const step of job.steps) {
const uses = resolveCiStepActionUses(step.kind);
if (uses && !/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+@[0-9a-f]{40}$/u.test(uses)) {
@@ -910,9 +967,9 @@ function validateContractSemantics(
}
}
const expectedStepKinds: Readonly<Record<string, readonly CiWorkflowStep["kind"][]>> = {
merge_static: ["checkout", "setup-node", "frozen-install", "run-gate", "upload"],
merge_test: ["checkout", "setup-node", "frozen-install", "run-gate", "upload"],
merge_browser: ["checkout", "setup-node", "frozen-install", "browser-install", "run-gate", "upload"],
merge_static: ["checkout", "dependency-cache", "setup-node", "frozen-install", "run-gate", "upload"],
merge_test: ["checkout", "dependency-cache", "setup-node", "frozen-install", "run-gate", "upload"],
merge_browser: ["checkout", "dependency-cache", "setup-node", "frozen-install", "browser-install", "run-gate", "upload"],
release_gate: ["checkout", "setup-node", "frozen-install", "browser-install", "run-gate", "upload"],
immutable_build: ["checkout", "setup-node", "frozen-install", "run-gate", "archive-candidate", "upload", "upload"],
vulnerability_provider: ["checkout", "setup-node", "frozen-install", "download", "run-provider", "validate-provider-evidence", "upload"],
@@ -934,7 +991,13 @@ function validateContractSemantics(
merge_static: [],
merge_test: [],
merge_browser: [],
release_gate: [],
release_gate: [
// 1112/05-01 (R9-D7, release tag). FE-GATE-028 compares each signed
// record's Release ID with the tag being released. A run that is not a
// tag run (a release stage dispatched on a branch) gets an empty value,
// and run-ci-gate.ts fails the gate on it.
{ name: "RELEASE_TAG", value: "${{ startsWith(gitea.ref, 'refs/tags/v') && gitea.ref_name || '' }}" },
],
immutable_build: [
// FE-GATE-027 admits the built artifact to a named environment, so both
// the profile it was built from and the destination it is claimed for are
@@ -1324,7 +1387,7 @@ function validateJobStepKinds(
): void {
const allowed: Readonly<Record<z.infer<typeof jobSchema>["kind"], ReadonlySet<string>>> = {
"gate-matrix": new Set(["checkout", "setup-node", "frozen-install", "browser-install", "download", "extract", "run-gate", "upload"]),
"gate-sequence": new Set(["checkout", "setup-node", "frozen-install", "browser-install", "run-gate", "upload"]),
"gate-sequence": new Set(["checkout", "dependency-cache", "setup-node", "frozen-install", "browser-install", "run-gate", "upload"]),
"gate-single": new Set(["checkout", "setup-node", "frozen-install", "run-gate", "upload"]),
immutable: new Set(["checkout", "setup-node", "frozen-install", "run-gate", "archive-candidate", "upload"]),
provider: new Set(["checkout", "setup-node", "frozen-install", "download", "extract", "run-provider", "validate-provider-evidence", "upload"]),
+25 -81
View File
@@ -589,26 +589,21 @@ export default function ${pascal}DetailPage() {
export function renderCreatePage({ names, routeId, write }: SliceShape): string {
const { base, camel, pascal, upper } = names;
return `import { useCallback, useEffect, useRef } from "react";
import { Link, useNavigate } from "react-router-dom";
return `import { Link, useNavigate } from "react-router-dom";
import type { Result } from "../../../contracts/result.ts";
import {
AsyncSurface,
Button,
DirtyNavigationDialog,
ErrorSummary,
Form,
FormActions,
FormFailureStatus,
FormField,
FormPage,
FormSaveFeedback,
useAppForm,
useDirtyNavigationGuard,
} from "../../../presentation/design-system/index.ts";
import { useLocale } from "../../../presentation/i18n/index.ts";
import type { ${pascal}CreateCommand } from "../application/${base}-feature-api.ts";
import type { ${pascal}ItemView } from "../contracts/${base}-mapper.ts";
import {
${upper}_FORM_DEFAULTS,
${camel}FormSchema,
@@ -634,63 +629,29 @@ export default function ${pascal}CreatePage() {
name: message("${camel}.form.name"),
} satisfies Record<keyof ${pascal}FormValues, string>;
const mutation = use${pascal}Create();
// A save outlives this page when the user leaves while it runs. Ending
// then, it does not take them to its item or the list (1106/08-02).
const mounted = useRef(false);
useEffect(() => {
mounted.current = true;
return () => {
mounted.current = false;
};
}, []);
const openSaved = useCallback(
(outcome: Result<${pascal}ItemView> | null) => {
if (outcome?.ok && mounted.current) {
void navigate(
${camel}RouteUrl("${write.detail.routeId}", {
params: { ${write.idParam}: outcome.value.itemId },
}),
);
}
return outcome;
},
[navigate],
);
const submit = useCallback(
async (command: ${pascal}CreateCommand) => {
const outcome = await mutation.submit(command);
openSaved(outcome);
return outcome;
},
[mutation, openSaved],
);
// The form holds the rules of a save through the mutation: no new save
// while one is unknown or another runs, confirm and resend of an unknown
// one, and what the page does after a save only while it is still open
// (useAppForm \`mutation\` and \`onSaved\`, FormSaveFeedback).
const form = useAppForm({
schema: ${camel}FormSchema,
defaultValues: ${upper}_FORM_DEFAULTS,
allowedServerFields: ["name"],
mapToCommand: to${pascal}CreateCommand,
submit,
submit: mutation.submit,
mutation,
onSaved: (item) => {
void navigate(
${camel}RouteUrl("${write.detail.routeId}", {
params: { ${write.idParam}: item.itemId },
}),
);
},
});
const effectUnknown = mutation.state.indicator === "mutation-effect-unknown";
const blocked = effectUnknown || mutation.state.indicator === "mutation-pending";
// A save this form did not start holds the coordinator (one left running
// when the user came back, or the check behind "confirm applied"): the save
// is off and the feedback says a save is running (1105/08-04).
const otherSaveRunning = mutation.state.indicator === "mutation-pending" && !form.pending;
const guard = useDirtyNavigationGuard(form.dirty && !form.pending);
return (
<Form
id={form.formId}
pending={form.pending}
onSubmit={(event) => {
if (blocked) {
event.preventDefault();
return;
}
void form.submitForm(event);
}}
>
<Form id={form.formId} pending={form.pending} onSubmit={(event) => void form.submitForm(event)}>
<FormPage
feedbackId={form.feedbackId}
breadcrumb={<Link to={${camel}RouteUrl("${routeId}")}>{message("${camel}.list.title")}</Link>}
@@ -715,38 +676,21 @@ export default function ${pascal}CreatePage() {
type="submit"
pending={form.pending}
pendingLabel={message("${camel}.form.saving")}
disabled={effectUnknown || otherSaveRunning}
disabled={form.effectUnknown || form.otherSaveRunning}
>
{message("${camel}.form.save")}
</Button>
</FormActions>
}
feedback={
form.failure ? (
<FormFailureStatus
failure={form.failure}
onAction={form.result === "retry-later" ? () => void form.submitForm() : undefined}
/>
) : effectUnknown ? (
<AsyncSurface
state={mutation.state}
supportReference={form.supportReference}
// The list shows whether the item is there; the form alone
// would show nothing but an emptied input (1105/08-02).
onReconcileUnknownEffect={(resolution) => {
void mutation.reconcileUnknownEffect(resolution).then(() => {
form.settleApplied();
if (mounted.current) void navigate(${camel}RouteUrl("${routeId}"));
});
}}
// Drawn only for a request with a key (a KEYED command).
onResendUnknownEffect={() => {
void form.resendUnknown(async () => openSaved(await mutation.resendUnknownEffect()));
}}
/>
) : otherSaveRunning && form.result !== "effect-unknown" ? (
<AsyncSurface state={mutation.state} />
) : null
<FormSaveFeedback
form={form}
// The list shows whether the item is there; the form alone
// would show nothing but an emptied input (1105/08-02).
onConfirmed={() => {
void navigate(${camel}RouteUrl("${routeId}"));
}}
/>
}
guard={<DirtyNavigationDialog guard={guard} />}
/>
+33 -1
View File
@@ -11,9 +11,11 @@ import { fileURLToPath } from "node:url";
import path from "node:path";
import {
DEPENDENCY_CACHE,
indexCiGateContract,
loadCiGateContract,
resolveCiStepActionUses,
resolveCiSubActionUses,
type CiGateContract,
type CiWorkflowJob,
type CiWorkflowStep,
@@ -234,9 +236,16 @@ function renderJob(
const jobEnvironment = job.environment.filter((binding) => !isStepScopedSecret(job, binding));
// The build records the image it ran in (scripts/lib/build-environment.ts):
// a job in its own image names that one, not the runner label's.
// Every pnpm and corepack call of the job reads the cached directories, the
// install and the system container's own install alike.
const cacheEnvironment = job.steps.some(({ kind }) => kind === "dependency-cache")
? DEPENDENCY_CACHE.environment
: [];
const environmentLines = [
...(image ? [` CI_RUNNER_IMAGE: ${yamlScalar(image)}`] : []),
...jobEnvironment.map((binding) => ` ${binding.name}: ${yamlScalar(binding.value)}`),
...[...cacheEnvironment, ...jobEnvironment].map(
(binding) => ` ${binding.name}: ${yamlScalar(binding.value)}`,
),
];
if (environmentLines.length > 0) lines.push(" env:", ...environmentLines);
if (job.kind === "gate-matrix") {
@@ -316,6 +325,29 @@ function renderStep(
" with:",
" node-version-file: .nvmrc",
];
case "dependency-cache": {
// DEPENDENCY_CACHE: main restores and saves, every other ref restores.
// The frozen install after it runs either way.
const inputs = DEPENDENCY_CACHE.keyInputs.map((file) => `'${file}'`).join(", ");
const cache = [
" with:",
" path: |",
...DEPENDENCY_CACHE.paths.map((cachePath) => ` ${cachePath}`),
` key: ${DEPENDENCY_CACHE.keyPrefix}\${{ hashFiles(${inputs}) }}`,
" restore-keys: |",
` ${DEPENDENCY_CACHE.keyPrefix}`,
];
return [
" - name: Restore and save the dependency cache",
" if: ${{ gitea.ref == 'refs/heads/main' }}",
` uses: ${requiredStepActionUses(step.kind)}`,
...cache,
" - name: Restore the dependency cache",
" if: ${{ gitea.ref != 'refs/heads/main' }}",
` uses: ${resolveCiSubActionUses("cache", "restore")}`,
...cache,
];
}
case "frozen-install":
return [
" - name: Frozen install",
+1
View File
@@ -32,6 +32,7 @@ export const REPOSITORY_LAYOUT_SETS = Object.freeze([
"feature-typecheck",
"product-typecheck",
"app-typecheck",
"dependency-cache-key",
] as const);
export type RepositoryLayoutSet = (typeof REPOSITORY_LAYOUT_SETS)[number];
+13
View File
@@ -25,6 +25,15 @@ node_root=$(dirname "$(dirname "$(command -v node)")")
corepack_home=${COREPACK_HOME:-$HOME/.cache/node/corepack}
# The environment the gate reads (scripts/verify.sh ci_env, the workflow's global env).
pass_env=(CI VITE_BUILD_ID VITE_COMMIT_SHA RELEASE_ID CI_RUNNER_IMAGE SOURCE_DATE_EPOCH APP_PROFILE RELEASE_TARGET)
# A merge job's dependency cache (scripts/contracts/ci-gates.ts DEPENDENCY_CACHE): pnpm's store and metadata
# cache go in at the same paths, so the install in here reuses what the job's install fetched.
pnpm_dirs=()
for name in PNPM_CONFIG_STORE_DIR PNPM_CONFIG_CACHE_DIR; do
if [ -n "${!name:-}" ] && [ -d "${!name}" ]; then
pass_env+=("$name")
pnpm_dirs+=("${!name}")
fi
done
say() { echo "system-container: $*" >&2; }
fail() { say "$*"; exit 3; }
@@ -68,6 +77,10 @@ else
fi
tar -C "$node_root" -cf - . | $docker exec -i "$cid" sh -c 'mkdir -p /opt/node && tar -C /opt/node --no-same-owner -xf -' \
|| fail "copying node failed"
for dir in "${pnpm_dirs[@]}"; do
tar -C "$dir" -cf - . | $docker exec -i "$cid" sh -c "mkdir -p '$dir' && tar -C '$dir' --no-same-owner -xf -" \
|| fail "copying $dir failed"
done
if [ -d "$corepack_home" ]; then
tar -C "$corepack_home" -cf - . | $docker exec -i "$cid" sh -c 'mkdir -p /opt/corepack && tar -C /opt/corepack --no-same-owner -xf -' \
|| fail "copying the corepack cache failed"