Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions web/src/api/contracts/platform/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,23 @@ export const publishAccessReader: z.ZodType<PublishAccess> = 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<AppPublish> = 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<AppStack> = ApplicationStack.pick({
Expand Down
8 changes: 8 additions & 0 deletions web/src/api/contracts/platform/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ export const executionReader: z.ZodType<BuildExecution> = ApplicationDraftCreati
export const taskReader: z.ZodType<ImplementationTask> = 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
Expand Down
2 changes: 2 additions & 0 deletions web/src/features/app/overview-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<BusinessApp, 'group' | 'slug'> }) {
Expand Down Expand Up @@ -140,6 +141,7 @@ export function OverviewTab({
</div>
</div>
)}
<RunningAccessCheckStatus check={view.platform?.publish?.runningAccessCheck} unavailable={queryClient.getQueryState(keys.publishes(projectId))?.status === 'error'} />

{view.status === 'failed' ? (
<div className="mt-5 border-t border-stone-100 pt-4">
Expand Down
7 changes: 7 additions & 0 deletions web/src/features/app/releases-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -253,6 +255,11 @@ export function ReleasesTab({ projectId, view }: { projectId: string; view: AppV
}
/>
<CardBody className="space-y-4">
<RunningAccessCheckStatus
check={platform.publish?.runningAccessCheck}
observedDigest={releaseState.data?.targetImageDigest}
unavailable={releaseState.isError || overview.isError || releaseState.isFetching || rollback.inFlight || mutation.isPending || queryClient.getQueryState(keys.publishes(projectId))?.status === 'error'}
/>
{confirmation.unconfirmed ? (
<UnconfirmedNotice onConfirm={() => void confirmation.confirm()} confirming={confirmation.confirming} />
) : rollback.inFlight ? (
Expand Down
45 changes: 45 additions & 0 deletions web/src/features/app/running-access-check.test.tsx
Original file line number Diff line number Diff line change
@@ -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(<RunningAccessCheckStatus check={passed} observedDigest={artifactDigest} />)).toContain('data-state="passed"')
expect(renderToStaticMarkup(<RunningAccessCheckStatus check={passed} observedDigest={`sha256:${'d'.repeat(64)}`} />)).not.toContain('data-state="passed"')
expect(renderToStaticMarkup(<RunningAccessCheckStatus check={passed} unavailable />)).not.toContain('data-state="passed"')
expect(renderToStaticMarkup(<RunningAccessCheckStatus />)).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(<RunningAccessCheckStatus check={check} />)).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)
})
53 changes: 53 additions & 0 deletions web/src/features/app/running-access-check.tsx
Original file line number Diff line number Diff line change
@@ -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<string>()
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 <div className="mt-3 text-sm text-stone-600" data-testid="running-access-check" data-state={state}>
<p>{text[state]}</p>
{(state === 'passed' || state === 'failed') && check ? <details className="mt-1 text-xs">
<summary>{check.checkedAt}</summary>
<ul>{check.servingVersions.map((version) => <li key={version.releaseId} className="break-all font-mono">{version.releaseId} · {version.artifactDigest}</li>)}</ul>
</details> : null}
</div>
}
15 changes: 15 additions & 0 deletions web/src/features/build/implement/candidate-access-check.tsx
Original file line number Diff line number Diff line change
@@ -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 <p className="mt-1 text-xs text-stone-600" data-testid="candidate-access-check">{copy[state]}</p>
}
5 changes: 4 additions & 1 deletion web/src/features/build/implement/implement-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }: {
Expand Down Expand Up @@ -95,7 +96,8 @@ export function ImplementPanel({ state, preparation, released, published, change
{progress.hint ? <p className="mt-2 text-sm text-stone-600">{progress.hint}</p> : null}
<ol aria-label={text.implement.steps} className="mt-4 space-y-3 text-sm">
{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 <li key={step.taskId ?? index} aria-current={step.state === 'doing' ? 'step' : undefined} className="flex gap-3">
<span aria-label={text.artifact.states[step.state]} className={step.state === 'failed' ? 'text-bad-ink' : step.state === 'doing' ? 'text-accent' : 'text-stone-400'}>{{ todo: '○', doing: '●', done: '✔', failed: '✖', unknown: '?' }[step.state]}</span>
<div className="min-w-0 flex-1">
Expand All @@ -104,6 +106,7 @@ export function ImplementPanel({ state, preparation, released, published, change
{step.expectation ? <span className="block text-xs text-stone-500">{step.expectation}</span> : null}
{step.activity ? <span aria-label={buildCopy.progress.observe.activity} className="block text-xs text-stone-600">{step.activity}</span> : null}
{step.detail ? <span className="block text-xs text-bad-ink">{step.detail}</span> : null}
<CandidateAccessCheckStatus check={task?.accessCheck} />
{unmet.length ? <details className="mt-1 text-xs text-amber-800" open>
<summary className="cursor-pointer">{copy.unmetCriteria(unmet.length)}</summary>
<ul className="mt-1 list-disc space-y-1 pl-4">{unmet.map((item, criterionIndex) => <li key={criterionIndex}>{item.criterion}{item.note ? <span className="block text-stone-500">{item.note}</span> : null}</li>)}</ul>
Expand Down
9 changes: 9 additions & 0 deletions web/src/model/contracts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ export interface AppPublish {
tailnetUrl?: string
phase?: OpenValue<PublishPhase>
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. */
Expand Down
11 changes: 10 additions & 1 deletion web/src/model/contracts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,16 @@ export type BuildExecution = Omit<CanonicalExecution, 'status' | 'steps' | 'appr
approval?: CreationApproval
approvalUnreadable?: true
}
export type ImplementationTask = Omit<CanonicalTask, 'status' | 'failureReason'> & { status: OpenValue<TaskStatus>; failureReason?: OpenValue<ImplementationFailureReason> }
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<CanonicalTask, 'status' | 'failureReason' | 'accessCheck'> & { status: OpenValue<TaskStatus>; failureReason?: OpenValue<ImplementationFailureReason>; accessCheck?: CandidateAccessCheck }

/**
* The run failure reasons this console knows (Platform's documented values, APT-1158). Platform's set grows: any other
Expand Down