diff --git a/web/README.md b/web/README.md index a859143..cb450af 100644 --- a/web/README.md +++ b/web/README.md @@ -292,6 +292,14 @@ task. Every task reports its acceptance-criterion checks, gets at most one repair pass, and leaves any unmet criteria visible while the run continues. Plans, specifications and chat use business wording rather than implementation file names or identifiers. + +Independent access-check results are separate from the coder's report. The task +panel shows candidate evidence; overview/releases use only the read-only +`Publish.runningAccessCheck` projection for the running versions. Missing or +unknown states, incomplete provenance, failed refreshes and digest mismatches +are unverified, never a retained green badge. Public-only is not a protected +access pass. The current Platform hub lacks complete serving-digest projection, +so running checks stay unverified until that operator evidence is available. Step 5 and the build preparation Q&A save the publish name and audience as draft `publishPreferences` (alongside title alignment), so a new tab skips answered preparation questions diff --git a/web/src/api/contracts/platform/app.ts b/web/src/api/contracts/platform/app.ts index feaa5b0..ae3cb02 100644 --- a/web/src/api/contracts/platform/app.ts +++ b/web/src/api/contracts/platform/app.ts @@ -61,12 +61,23 @@ export const publishAccessReader: z.ZodType = z.object({ pending: CanonicalPublishAccess.shape.pending.unwrap().pick({ reason: true }).optional(), }) +const runningAccessCheckReader = z.object({ + state: openEnum(['passed', 'failed', 'unverified', 'notApplicable']), + reason: openEnum(['AllServingVersionsPassed', 'CriterionFailed', 'NoReceipt', 'ProvenanceMismatch', 'ObservationUnavailable', 'PublicOnly']), + checkedAt: z.iso.datetime().optional(), + policyRevision: z.string().optional(), + servingVersions: z.array(z.object({ + releaseId: z.string(), artifactDigest: z.string(), commitSha: z.string().optional(), sourceDigest: z.string().optional(), + })), +}) + export const publishReader: z.ZodType = Publish.pick({ id: true, applicationId: true, branchId: true, componentId: true, publicUrl: true, tailnetUrl: true }).extend({ applicationId: dnsLabelOrEmpty, branchId: dnsLabelOrEmpty, componentId: dnsLabelOrEmpty, phase: openCanonical(PublishPhase).optional(), access: publishAccessReader.optional(), + runningAccessCheck: runningAccessCheckReader.optional(), }) export const stackReader: z.ZodType = ApplicationStack.pick({ diff --git a/web/src/api/contracts/platform/build.ts b/web/src/api/contracts/platform/build.ts index 02a8b67..5254c44 100644 --- a/web/src/api/contracts/platform/build.ts +++ b/web/src/api/contracts/platform/build.ts @@ -103,6 +103,14 @@ export const executionReader: z.ZodType = ApplicationDraftCreati export const taskReader: z.ZodType = ApplicationDraftImplementationTask.extend({ status: openCanonical(ApplicationDraftImplementationTaskStatus), failureReason: openCanonical(ApplicationDraftImplementationFailureReason).optional(), + accessCheck: z.object({ + state: openEnum(['passed', 'failed', 'unverified']), + checkedAt: z.iso.datetime(), + sourceDigest: z.string(), + artifactDigest: z.string(), + policyRevision: z.string(), + criteria: z.array(z.object({ name: z.string(), state: openEnum(['passed', 'failed', 'notObserved']) })), + }).optional(), }) // A failed run's `failure` (APT-1158) is absent on an older Platform; its `reason` is an open value. A present but diff --git a/web/src/features/app/overview-tab.tsx b/web/src/features/app/overview-tab.tsx index c7a53db..9d51f9d 100644 --- a/web/src/features/app/overview-tab.tsx +++ b/web/src/features/app/overview-tab.tsx @@ -23,6 +23,7 @@ import { isSourceBuildFailed } from './platform' import { ScreenshotStrip } from './screenshots' import { ToolsPanel } from './tools-panel' import { VoicesPanel } from './voices-panel' +import { RunningAccessCheckStatus } from './running-access-check' /** 「利用者にはこう見えます →」 (WF-05 ②): the same page drawn as a user sees it (`?as=user`, app-page.tsx). */ export function UserViewLink({ app }: { app: Pick }) { @@ -140,6 +141,7 @@ export function OverviewTab({ )} + {view.status === 'failed' ? (
diff --git a/web/src/features/app/releases-tab.tsx b/web/src/features/app/releases-tab.tsx index 1c1a480..ec500a8 100644 --- a/web/src/features/app/releases-tab.tsx +++ b/web/src/features/app/releases-tab.tsx @@ -20,6 +20,7 @@ import { Button, Card, CardBody, CardHeader, ConfirmDialog, DataTable, EmptyStat import { text } from './copy' import { webScope } from './platform' import { isUnconfirmedWrite, StaleNotice, UnconfirmedNotice, useWriteConfirmation } from './notices' +import { RunningAccessCheckStatus } from './running-access-check' /** One line of 更新履歴: a release, or a rollback candidate the release list does not carry. */ interface ReleaseRow { @@ -161,6 +162,7 @@ export function ReleasesTab({ projectId, view }: { projectId: string; view: AppV void queryClient.invalidateQueries({ queryKey: ['release-state'] }) void queryClient.invalidateQueries({ queryKey: ['releases'] }) void queryClient.invalidateQueries({ queryKey: keys.summaries(projectId) }) + void queryClient.invalidateQueries({ queryKey: keys.publishes(projectId) }) }, }) // A rollback whose answer could not be read may have started: read the release state back before offering another. @@ -253,6 +255,11 @@ export function ReleasesTab({ projectId, view }: { projectId: string; view: AppV } /> + {confirmation.unconfirmed ? ( void confirmation.confirm()} confirming={confirmation.confirming} /> ) : rollback.inFlight ? ( diff --git a/web/src/features/app/running-access-check.test.tsx b/web/src/features/app/running-access-check.test.tsx new file mode 100644 index 0000000..f76381a --- /dev/null +++ b/web/src/features/app/running-access-check.test.tsx @@ -0,0 +1,45 @@ +import { expect, test } from 'bun:test' +import { renderToStaticMarkup } from 'react-dom/server' +import { publishReader } from '../../api/contracts/platform/app' +import type { RunningAccessCheck } from '../../model/contracts/app' +import { runningAccessCheckState, RunningAccessCheckStatus } from './running-access-check' + +const artifactDigest = `sha256:${'a'.repeat(64)}` +const passed: RunningAccessCheck = { + state: { kind: 'known', value: 'passed' }, reason: { kind: 'known', value: 'AllServingVersionsPassed' }, + checkedAt: '2026-11-23T00:00:00Z', policyRevision: 'app-access/v1', + servingVersions: [{ releaseId: 'revision-one', artifactDigest, commitSha: 'b'.repeat(40), sourceDigest: `sha256:${'c'.repeat(64)}` }], +} + +test('only a nonempty complete current-policy serving proof displays passed', () => { + expect(runningAccessCheckState(passed)).toBe('passed') + for (const check of [undefined, { ...passed, servingVersions: [] }, { ...passed, checkedAt: undefined }, + { ...passed, policyRevision: 'old' }, { ...passed, state: { kind: 'unknown' } as const }, + { ...passed, reason: { kind: 'known', value: 'ProvenanceMismatch' } as const }, + { ...passed, servingVersions: [...passed.servingVersions, { releaseId: 'unverified-revision', artifactDigest: '' }] }, + ]) expect(runningAccessCheckState(check)).toBe('unverified') +}) + +test('digest mismatch and a failed refresh remove the passed display', () => { + expect(renderToStaticMarkup()).toContain('data-state="passed"') + expect(renderToStaticMarkup()).not.toContain('data-state="passed"') + expect(renderToStaticMarkup()).not.toContain('data-state="passed"') + expect(renderToStaticMarkup()).toContain('data-state="unverified"') +}) + +test('public-only is not a protected-access pass', () => { + const check: RunningAccessCheck = { state: { kind: 'known', value: 'notApplicable' }, reason: { kind: 'known', value: 'PublicOnly' }, servingVersions: [] } + expect(runningAccessCheckState(check)).toBe('notApplicable') + expect(renderToStaticMarkup()).not.toContain('data-state="passed"') +}) + +test('old API omissions and unknown states/reasons stay unverified', () => { + const publish = { id: 'web', applicationId: 'app', branchId: 'production', componentId: 'web' } + expect(publishReader.parse(publish).runningAccessCheck).toBeUndefined() + const wire = { ...passed, state: 'future-state', reason: 'future-reason' } + const check = publishReader.parse({ ...publish, runningAccessCheck: wire }).runningAccessCheck + expect(check?.state).toEqual({ kind: 'unknown' }) + expect(check?.reason).toEqual({ kind: 'unknown' }) + expect(runningAccessCheckState(check)).toBe('unverified') + expect(publishReader.safeParse({ ...publish, runningAccessCheck: { ...wire, servingVersions: null } }).success).toBe(false) +}) diff --git a/web/src/features/app/running-access-check.tsx b/web/src/features/app/running-access-check.tsx new file mode 100644 index 0000000..792e7f6 --- /dev/null +++ b/web/src/features/app/running-access-check.tsx @@ -0,0 +1,53 @@ +import type { RunningAccessCheck } from '../../model/contracts/app' +import { isOneOf } from '../../model/contracts/build' +import { localized } from '../../shell/language' + +const text = localized({ + ja: { + passed: '稼働中の版:利用者の検査に合格', + failed: '稼働中の版:利用者の検査に不合格', + unverified: '稼働中の版:利用者の検査は未確認', + notApplicable: '公開専用:利用者の検査は対象外', + }, + en: { + passed: 'Running versions: passed access check', + failed: 'Running versions: failed access check', + unverified: 'Running versions: access check unverified', + notApplicable: 'Public-only: access check not applicable', + }, +}) + +const digest = /^sha256:[0-9a-f]{64}$/ +const commit = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/ + +/** The server verifies signatures and every serving target. Never infer a pass + * from a build/task result, desired tag or an old API's missing field. An + * independently refreshed digest can only veto, not manufacture, a pass. */ +export function runningAccessCheckState(check: RunningAccessCheck | undefined, observedDigest?: string) { + if (!check) return 'unverified' + if (isOneOf(check.state, 'notApplicable') && isOneOf(check.reason, 'PublicOnly')) return 'notApplicable' + if (!check.checkedAt || check.policyRevision !== 'app-access/v1' || check.servingVersions.length === 0) return 'unverified' + const ids = new Set() + for (const version of check.servingVersions) { + if (!version.releaseId || ids.has(version.releaseId) || !digest.test(version.artifactDigest) || + !version.sourceDigest || !digest.test(version.sourceDigest) || !version.commitSha || !commit.test(version.commitSha)) return 'unverified' + ids.add(version.releaseId) + } + if (observedDigest !== undefined && !check.servingVersions.some((version) => version.artifactDigest === observedDigest)) return 'unverified' + if (isOneOf(check.state, 'passed') && isOneOf(check.reason, 'AllServingVersionsPassed')) return 'passed' + if (isOneOf(check.state, 'failed') && isOneOf(check.reason, 'CriterionFailed')) return 'failed' + return 'unverified' +} + +export function RunningAccessCheckStatus({ check, observedDigest, unavailable = false }: { + check?: RunningAccessCheck; observedDigest?: string; unavailable?: boolean +}) { + const state = runningAccessCheckState(unavailable ? undefined : check, observedDigest) + return
+

{text[state]}

+ {(state === 'passed' || state === 'failed') && check ?
+ {check.checkedAt} +
    {check.servingVersions.map((version) =>
  • {version.releaseId} · {version.artifactDigest}
  • )}
+
: null} +
+} diff --git a/web/src/features/build/implement/candidate-access-check.tsx b/web/src/features/build/implement/candidate-access-check.tsx new file mode 100644 index 0000000..8c77e10 --- /dev/null +++ b/web/src/features/build/implement/candidate-access-check.tsx @@ -0,0 +1,15 @@ +import type { CandidateAccessCheck } from '../../../model/contracts/build' +import { isOneOf } from '../../../model/contracts/build' +import { localized } from '../../../shell/language' + +const copy = localized({ + ja: { passed: '今回の変更:利用者の検査に合格(稼働中の版とは別)', failed: '今回の変更:利用者の検査に不合格', unverified: '今回の変更:利用者の検査は未確認' }, + en: { passed: 'Candidate: passed access check (not the running version)', failed: 'Candidate: failed access check', unverified: 'Candidate: access check unverified' }, +}) + +export function CandidateAccessCheckStatus({ check }: { check?: CandidateAccessCheck }) { + if (!check) return null + const complete = check.criteria.length > 0 && check.criteria.every((criterion) => isOneOf(criterion.state, 'passed')) + const state = isOneOf(check.state, 'passed') && complete ? 'passed' : isOneOf(check.state, 'failed') ? 'failed' : 'unverified' + return

{copy[state]}

+} diff --git a/web/src/features/build/implement/implement-panel.tsx b/web/src/features/build/implement/implement-panel.tsx index cf9f2ad..1088ce5 100644 --- a/web/src/features/build/implement/implement-panel.tsx +++ b/web/src/features/build/implement/implement-panel.tsx @@ -9,6 +9,7 @@ import { implementationCopy as copy } from './copy' import { PreviewDatabaseLine, type PreviewDatabaseControl } from './preview-database' import { implemented, type ImplementationState } from './state' import { text } from '../copy' +import { CandidateAccessCheckStatus } from './candidate-access-check' export function ImplementPanel({ state, preparation, released, published, changeByReply, previewNotice, previewDatabase, onOpenPreview, onRetry, onSkipTask, onConfirm }: { @@ -95,7 +96,8 @@ export function ImplementPanel({ state, preparation, released, published, change {progress.hint ?

{progress.hint}

: null}
    {progress.steps?.map((step, index) => { - const unmet = state.tasks.find((task) => task.id === step.taskId)?.verification?.criteria.filter((criterion) => !criterion.met) ?? [] + const task = state.tasks.find((task) => task.id === step.taskId) + const unmet = task?.verification?.criteria.filter((criterion) => !criterion.met) ?? [] return
  1. {{ todo: '○', doing: '●', done: '✔', failed: '✖', unknown: '?' }[step.state]}
    @@ -104,6 +106,7 @@ export function ImplementPanel({ state, preparation, released, published, change {step.expectation ? {step.expectation} : null} {step.activity ? {step.activity} : null} {step.detail ? {step.detail} : null} + {unmet.length ?
    {copy.unmetCriteria(unmet.length)}
      {unmet.map((item, criterionIndex) =>
    • {item.criterion}{item.note ? {item.note} : null}
    • )}
    diff --git a/web/src/model/contracts/app.ts b/web/src/model/contracts/app.ts index 8e53272..edf73d1 100644 --- a/web/src/model/contracts/app.ts +++ b/web/src/model/contracts/app.ts @@ -60,6 +60,15 @@ export interface AppPublish { tailnetUrl?: string phase?: OpenValue access?: PublishAccess + runningAccessCheck?: RunningAccessCheck +} + +export interface RunningAccessCheck { + state: OpenValue<'passed' | 'failed' | 'unverified' | 'notApplicable'> + reason: OpenValue<'AllServingVersionsPassed' | 'CriterionFailed' | 'NoReceipt' | 'ProvenanceMismatch' | 'ObservationUnavailable' | 'PublicOnly'> + checkedAt?: string + policyRevision?: string + servingVersions: { releaseId: string; artifactDigest: string; commitSha?: string; sourceDigest?: string }[] } /** The server's record of a failed source build on a stack. */ diff --git a/web/src/model/contracts/build.ts b/web/src/model/contracts/build.ts index 2961a18..9d3fc1d 100644 --- a/web/src/model/contracts/build.ts +++ b/web/src/model/contracts/build.ts @@ -62,7 +62,16 @@ export type BuildExecution = Omit & { status: OpenValue; failureReason?: OpenValue } +export interface CandidateAccessCheck { + state: OpenValue<'passed' | 'failed' | 'unverified'> + checkedAt: string + sourceDigest: string + artifactDigest: string + policyRevision: string + criteria: { name: string; state: OpenValue<'passed' | 'failed' | 'notObserved'> }[] +} + +export type ImplementationTask = Omit & { status: OpenValue; failureReason?: OpenValue; accessCheck?: CandidateAccessCheck } /** * The run failure reasons this console knows (Platform's documented values, APT-1158). Platform's set grows: any other