Skip to content

Commit d2b843e

Browse files
wip v28
1 parent cad1f6f commit d2b843e

10 files changed

Lines changed: 256 additions & 32 deletions

BITCODE_V28_QA.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -929,9 +929,9 @@ Positive-control expectation:
929929
Terminal Deposit/Read components, repository/branch/commit source selection,
930930
execution-history persistence, wallet/GitHub readiness, saved QA SQL, BTD
931931
ledger readback, and proof/finality/admission primitives.
932-
- The Fit result must name why the selected ENGI evidence is decisive or why it
933-
is insufficient. A decorative Fit summary with no source/proof linkage is a
934-
failure.
932+
- The Fit result must name why the selected deposited source evidence is
933+
decisive or why it is insufficient. A decorative Fit summary with no
934+
source/proof linkage is a failure.
935935
- The result must produce one of two honest outcomes:
936936
- `worthy_fit`: a minimal AssetPack candidate with source revision, evidence
937937
roots, proof/dedupe/materialization posture, and settlement/finality state;
@@ -941,28 +941,31 @@ Positive-control expectation:
941941
942942
Negative controls:
943943
944-
1. Run or simulate a Read unrelated to the deposited ENGI source, such as
944+
1. Run or simulate a Read unrelated to the deposited source, such as
945945
"Find a Solana wallet settlement AssetPack." Expected: no-worthy-fit or
946-
clarification, not an ENGI AssetPack.
946+
clarification, not a confident AssetPack.
947947
2. Run or simulate an overly broad Read, such as "Make Bitcode better."
948948
Expected: clarification or blocked measurement, not a confident Fit.
949949
3. Run or simulate a Read that would require unavailable source material outside
950-
the deposited ENGI revision. Expected: no-worthy-fit or source-scope blocker.
950+
the deposited revision. Expected: no-worthy-fit or source-scope blocker.
951951
952952
Manual steps:
953953
954954
1. Hard refresh `/terminal`.
955-
2. Confirm the Activity area shows the successful ENGI Deposit row and no
955+
2. Confirm the Activity area shows the successful latest Deposit row and no
956956
execution-history error.
957957
3. Confirm the repository selector still shows the deposited repository, the
958958
selected branch, and the selected commit from the successful Deposit.
959-
4. In the Read area, select or express the commercial Read scenario above.
960-
5. Record the Read posture. Capture the `/api/executions/history` request and
961-
response; expected status is `201`.
962-
6. Accept the Read for fit search. Capture `/api/read-review`; expected response
963-
has `fitSearchAdmission.admitted=true`. If it remains blocked, the blocker
964-
must name the Read-review requirement or measurement deficiency.
965-
7. Record Fit posture. Capture the `/api/executions/history` request and
959+
4. In the Deposit + read chain, confirm the Read state panel starts at
960+
`draft` and explains that recording a Read does not mean Bitcode found a
961+
fit.
962+
5. Record the measured Read. Capture the `/api/executions/history` request and
963+
response; expected status is `201`, and the page must remain in the Read
964+
chain with a `measured` next-state message.
965+
6. Admit the measured Read for fit search. Capture the `/api/executions/history`
966+
request and response; expected status is `201` with
967+
`fitSearchAdmission.admitted=true`.
968+
7. Record Fit result posture. Capture the `/api/executions/history` request and
966969
response; expected status is `201`.
967970
8. If a branch, AssetPack, BTC fee, ledger anchor, or settlement control becomes
968971
enabled, inspect the preview first. Only click it if the preview names source
@@ -1000,7 +1003,7 @@ Commercial blockers:
10001003
- Terminal claims delivery, settlement, mint, anchor, or finality that SQL
10011004
readback cannot verify.
10021005
- Any staging-testnet Read/Fit row contains `frontier/*`, mock provider, or
1003-
protocol-demo source as if it were live deposited ENGI source.
1006+
protocol-demo source as if it were live deposited source.
10041007
10051008
## 2026-05-13 Staging Deployment Readiness Gate
10061009
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export const runtime = 'nodejs';
2+
3+
function encodeSse(payload: Record<string, unknown>) {
4+
return `data: ${JSON.stringify(payload)}\n\n`;
5+
}
6+
7+
export async function GET(request: Request) {
8+
const { searchParams } = new URL(request.url);
9+
const runId = searchParams.get('runId') || null;
10+
11+
const body = encodeSse({
12+
type: 'status',
13+
runId,
14+
step: 'history-snapshot',
15+
progress: 1,
16+
message: 'No live execution stream is attached to this persisted Bitcode activity.',
17+
detail: 'Terminal is reading the saved activity, output, proof, and posture payloads from execution history.',
18+
});
19+
20+
return new Response(body, {
21+
headers: {
22+
'Cache-Control': 'no-cache, no-transform',
23+
Connection: 'keep-alive',
24+
'Content-Type': 'text/event-stream; charset=utf-8',
25+
},
26+
});
27+
}

uapi/app/terminal/TerminalDepositReadWorkbench.tsx

Lines changed: 100 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { useMemo, useState } from 'react';
3+
import { useEffect, useMemo, useState } from 'react';
44

55
import BitcodeMetricGrid from '@/components/base/bitcode/execution/BitcodeMetricGrid';
66

@@ -9,6 +9,7 @@ import TerminalWorkspaceCard from './TerminalWorkspaceCard';
99
import {
1010
buildTerminalFitWorkbenchDraft,
1111
buildTerminalDepositWorkbenchDraft,
12+
buildTerminalReadAdmissionDraft,
1213
buildTerminalReadMeasurementDraft,
1314
type TerminalActivityRecordDraft,
1415
} from './terminal-activity-history';
@@ -30,6 +31,8 @@ function readRowValue(rows: Array<{ label: string; value: string }>, label: stri
3031
return rows.find((row) => row.label === label)?.value || '—';
3132
}
3233

34+
type ReadFitProgressState = 'draft' | 'measured' | 'admitted' | 'fit-recorded';
35+
3336
interface TerminalDepositReadWorkbenchProps {
3437
repositoryContext?: TerminalRepositoryContextState | null;
3538
onRecordActivity?: (draft: TerminalActivityRecordDraft) => Promise<unknown>;
@@ -42,8 +45,9 @@ export default function TerminalDepositReadWorkbench({
4245
showDemonstrationWorkbench = true,
4346
}: TerminalDepositReadWorkbenchProps) {
4447
const { snapshot } = useTerminalShellBridge();
45-
const [recordingKey, setRecordingKey] = useState<'deposit' | 'read' | 'fit' | null>(null);
48+
const [recordingKey, setRecordingKey] = useState<'deposit' | 'read' | 'read-admission' | 'fit' | null>(null);
4649
const [recordMessage, setRecordMessage] = useState<string | null>(null);
50+
const [readFitProgress, setReadFitProgress] = useState<ReadFitProgressState>('draft');
4751
const workbenchSnapshot = useMemo(() => {
4852
if (showDemonstrationWorkbench) return snapshot;
4953
return buildLiveTerminalDepositReadWorkbenchSnapshot(repositoryContext);
@@ -52,6 +56,11 @@ export default function TerminalDepositReadWorkbench({
5256
() => normalizeTerminalDepositReadWorkbench(workbenchSnapshot, repositoryContext),
5357
[repositoryContext, workbenchSnapshot],
5458
);
59+
const scenarioKey = workbench?.scenarioLabel || '';
60+
61+
useEffect(() => {
62+
setReadFitProgress('draft');
63+
}, [scenarioKey]);
5564

5665
const selectedEntryChips = useMemo(() => {
5766
if (!workbench?.deposit.selectedEntries.length) return [];
@@ -86,10 +95,16 @@ export default function TerminalDepositReadWorkbench({
8695
],
8796
}),
8897
);
89-
setRecordMessage('Read-measurement posture recorded into the Bitcode activity ledger.');
98+
setReadFitProgress('measured');
99+
setRecordMessage(
100+
'Measured Read recorded. Next admit it for source-bound fit search, or stop if the Read is too broad or unrelated to the deposited source.',
101+
);
90102
} else {
91103
await onRecordActivity(buildTerminalFitWorkbenchDraft(workbench));
92-
setRecordMessage('Asset-pack fit and settlement posture recorded into the Bitcode activity ledger.');
104+
setReadFitProgress('fit-recorded');
105+
setRecordMessage(
106+
'Fit posture recorded. This records current fit evidence/readiness; settlement and finality remain blocked unless a worthy fit is evidenced.',
107+
);
93108
}
94109
} catch (error) {
95110
setRecordMessage(error instanceof Error ? error.message : 'Unable to record Bitcode workbench posture.');
@@ -98,6 +113,25 @@ export default function TerminalDepositReadWorkbench({
98113
}
99114
};
100115

116+
const handleRecordReadAdmission = async () => {
117+
if (!workbench || !onRecordActivity) return;
118+
119+
setRecordingKey('read-admission');
120+
setRecordMessage(null);
121+
122+
try {
123+
await onRecordActivity(buildTerminalReadAdmissionDraft(workbench));
124+
setReadFitProgress('admitted');
125+
setRecordMessage(
126+
'Measured Read admitted for fit search. Next run or record the fit result posture as worthy_fit, no_worthy_fit, or blocked_readiness evidence.',
127+
);
128+
} catch (error) {
129+
setRecordMessage(error instanceof Error ? error.message : 'Unable to admit the measured Read for fit search.');
130+
} finally {
131+
setRecordingKey(null);
132+
}
133+
};
134+
101135
if (!workbench) {
102136
return (
103137
<TerminalWorkspaceCard
@@ -165,8 +199,8 @@ export default function TerminalDepositReadWorkbench({
165199
metrics={workbench.read.metrics}
166200
rows={workbench.read.rows}
167201
chips={workbench.read.closureCriteria.length ? workbench.read.closureCriteria : workbench.read.targetKinds}
168-
actionLabel="Focus read scenarios"
169-
actionTarget="terminalReadScenarios"
202+
actionLabel={showDemonstrationWorkbench ? 'Focus read scenarios' : 'Review measured Read'}
203+
actionTarget={showDemonstrationWorkbench ? 'terminalReadScenarios' : 'terminalReadWorkbench'}
170204
secondaryActionLabel={recordingKey === 'read' ? 'Recording…' : 'Record read posture'}
171205
secondaryActionDisabled={recordingKey !== null}
172206
onSecondaryAction={() => {
@@ -175,6 +209,65 @@ export default function TerminalDepositReadWorkbench({
175209
/>
176210
</div>
177211

212+
<section className="mt-5 rounded-[1.45rem] border border-emerald-400/16 bg-emerald-400/[0.06] px-5 py-5">
213+
<div className="flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between">
214+
<div>
215+
<p className="text-[0.66rem] uppercase tracking-[0.2em] text-emerald-200/80">read state</p>
216+
<h3 className="mt-2 text-lg font-semibold text-white">Measured Read before fit result</h3>
217+
<p className="mt-2 max-w-3xl text-sm leading-6 text-neutral-300">
218+
Recording a Read stores the measured demand frame. It does not mean Bitcode found a fit. Fit search must then return
219+
worthy_fit, no_worthy_fit, or blocked_readiness before settlement or finality can proceed.
220+
</p>
221+
</div>
222+
<span className="rounded-full border border-white/10 bg-black/20 px-3 py-2 text-[0.66rem] uppercase tracking-[0.18em] text-neutral-200">
223+
{readFitProgress.replace('-', ' ')}
224+
</span>
225+
</div>
226+
227+
<div className="mt-5 grid gap-3 md:grid-cols-4">
228+
{[
229+
{ id: 'draft', label: '1. Read framed', detail: 'Repository, branch, commit, and demand frame are visible.' },
230+
{ id: 'measured', label: '2. Read measured', detail: 'Read posture is persisted as ledger evidence.' },
231+
{ id: 'admitted', label: '3. Fit admitted', detail: 'Measured Read may enter source-bound fit search.' },
232+
{ id: 'fit-recorded', label: '4. Result recorded', detail: 'Fit result posture is reviewable before proof or settlement.' },
233+
].map((step) => {
234+
const active = step.id === readFitProgress;
235+
return (
236+
<div
237+
key={step.id}
238+
className={`rounded-[1.1rem] border px-4 py-4 text-sm ${
239+
active ? 'border-emerald-300/35 bg-emerald-300/10' : 'border-white/8 bg-black/20'
240+
}`}
241+
>
242+
<p className="font-semibold text-neutral-100">{step.label}</p>
243+
<p className="mt-2 leading-6 text-neutral-400">{step.detail}</p>
244+
</div>
245+
);
246+
})}
247+
</div>
248+
249+
<div className="mt-5 flex flex-wrap gap-3">
250+
<button
251+
type="button"
252+
disabled={recordingKey !== null || readFitProgress === 'draft'}
253+
onClick={() => {
254+
void handleRecordReadAdmission();
255+
}}
256+
className="rounded-[1.25rem] border border-emerald-400/30 bg-emerald-400/10 px-4 py-3 text-sm font-medium text-emerald-100 transition hover:border-emerald-300/50 hover:bg-emerald-400/15 disabled:cursor-not-allowed disabled:opacity-55"
257+
>
258+
{recordingKey === 'read-admission' ? 'Admitting Read…' : 'Admit measured Read for fit search'}
259+
</button>
260+
<button
261+
type="button"
262+
disabled={recordingKey !== null}
263+
onClick={() => jumpToShellSection('terminalFitWorkbench')}
264+
className="rounded-[1.25rem] border border-white/10 bg-white/5 px-4 py-3 text-sm font-medium text-neutral-100 transition hover:border-white/18 hover:bg-white/10 disabled:cursor-not-allowed disabled:opacity-55"
265+
>
266+
Review fit result posture
267+
</button>
268+
</div>
269+
</section>
270+
178271
<article
179272
id="terminalFitWorkbench"
180273
className="mt-5 rounded-[1.6rem] border border-amber-400/18 bg-amber-400/5 px-5 py-5"
@@ -199,7 +292,7 @@ export default function TerminalDepositReadWorkbench({
199292
}}
200293
className="rounded-full border border-white/10 bg-white/5 px-3 py-2 text-[0.66rem] uppercase tracking-[0.18em] text-neutral-100 transition hover:border-white/18 hover:bg-white/10 disabled:cursor-not-allowed disabled:opacity-60"
201294
>
202-
{recordingKey === 'fit' ? 'Recording…' : 'Record fit posture'}
295+
{recordingKey === 'fit' ? 'Recording…' : 'Record fit result posture'}
203296
</button>
204297
</div>
205298
<p className="mt-3 text-sm leading-6 text-neutral-300">{workbench.fit.summary}</p>

uapi/app/terminal/TerminalPageClient.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,9 @@ export default function TerminalPageClient() {
325325

326326
const nextRun = mapExecutionHistoryRunToWorkspaceRun(payload.execution);
327327
setLiveRuns((currentRuns) => upsertWorkspaceRun(currentRuns, nextRun));
328-
replaceTerminalRoute(nextRun.id, draft.detailSection || 'activity');
328+
if (draft.selectAfterRecord !== false) {
329+
replaceTerminalRoute(nextRun.id, draft.detailSection || 'activity');
330+
}
329331
void refreshLiveRuns();
330332
return nextRun;
331333
},

uapi/app/terminal/TerminalReadScenarioPanel.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ export default function TerminalReadScenarioPanel({
174174
explainer={TERMINAL_WORKSPACE_EXPLAINERS.readScenarios}
175175
>
176176
<p className="mt-4 text-sm leading-6 text-neutral-300">
177-
{showDemonstrationScenarios ? 'Loading read scenarios…' : 'Waiting for live Read scenarios after Depositing is recorded.'}
177+
{showDemonstrationScenarios
178+
? 'Loading read scenarios…'
179+
: 'Live Read measurement, admission, and fit-result controls are in the Deposit + read chain.'}
178180
</p>
179181
</TerminalWorkspaceCard>
180182
);

uapi/app/terminal/page.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Metadata } from 'next';
2-
import React from 'react';
2+
import React, { Suspense } from 'react';
33

44
import TerminalPageClient from '@/app/terminal/TerminalPageClient';
55

@@ -13,5 +13,17 @@ export const metadata: Metadata = {
1313
};
1414

1515
export default function TerminalPage() {
16-
return <TerminalPageClient />;
16+
return (
17+
<Suspense
18+
fallback={
19+
<main className="min-h-screen bg-[#02050d] px-6 pt-32 text-neutral-100">
20+
<div className="rounded-2xl border border-emerald-400/15 bg-white/5 px-5 py-5 text-sm text-neutral-300">
21+
Reading Terminal route state…
22+
</div>
23+
</main>
24+
}
25+
>
26+
<TerminalPageClient />
27+
</Suspense>
28+
);
1729
}

uapi/app/terminal/terminal-activity-history.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface TerminalActivityRecordDraft {
1616
type: string;
1717
summary: string;
1818
detailSection?: TerminalTransactionDetailSection;
19+
selectAfterRecord?: boolean;
1920
status?: string;
2021
input?: Record<string, unknown> | null;
2122
output?: Record<string, unknown> | null;
@@ -317,6 +318,7 @@ export function buildTerminalReadMeasurementDraft(
317318
return {
318319
type: 'agentic-execution:read-measurement',
319320
detailSection: 'activity',
321+
selectAfterRecord: false,
320322
summary: `Recorded read measurement for ${scenario.label}.`,
321323
output: {
322324
readMeasurement: {
@@ -341,6 +343,62 @@ export function buildTerminalReadMeasurementDraft(
341343
};
342344
}
343345

346+
export function buildTerminalReadAdmissionDraft(
347+
workbench: TerminalDepositReadWorkbench,
348+
): TerminalActivityRecordDraft {
349+
const readMeasurement = {
350+
scenario: {
351+
id: workbench.scenarioLabel,
352+
label: workbench.scenarioLabel,
353+
repo: readRowValue(workbench.read.rows, 'Repository'),
354+
profile: readRowValue(workbench.read.rows, 'Profile'),
355+
selected: true,
356+
},
357+
parserKind: readRowValue(workbench.read.rows, 'Parser'),
358+
closureCriteriaCount: workbench.read.closureCriteria.length,
359+
targetKindCount: workbench.read.targetKinds.length,
360+
};
361+
const readReview = {
362+
action: 'accept',
363+
status: 'accepted',
364+
reviewStage: 'post-measurement-pre-fit',
365+
requiredBefore: 'find-fitting-asset-pack',
366+
fitSearchAdmission: {
367+
admitted: true,
368+
admissionReason:
369+
'Measured Read is admitted for generic source-bound fit search against the selected deposited repository revision.',
370+
admittedStages: ['candidate-recall', 'fit-quality-evaluation', 'asset-pack-result-review'],
371+
blockedStages: ['settlement', 'finality', 'minting'],
372+
},
373+
nextProtocolAction: 'Run fit search and return worthy_fit, no_worthy_fit, or blocked_readiness evidence.',
374+
};
375+
376+
return {
377+
type: 'agentic-execution:read-measurement',
378+
detailSection: 'activity',
379+
selectAfterRecord: false,
380+
summary: `Accepted measured Read for fit search for ${workbench.scenarioLabel}.`,
381+
output: {
382+
readMeasurement,
383+
readReview,
384+
assetPackCompletion: {
385+
bitcodeActivityState: {
386+
readMeasurement,
387+
readReview,
388+
fitSearchAdmission: readReview.fitSearchAdmission,
389+
},
390+
},
391+
},
392+
context: {
393+
source: 'terminal-deposit-read-workbench',
394+
workbench: 'read-admission',
395+
scenarioLabel: workbench.scenarioLabel,
396+
fitSearchAdmitted: true,
397+
readResultState: 'admitted_for_fit_search',
398+
},
399+
};
400+
}
401+
344402
export function buildTerminalSupplySelectionDraft(
345403
selection: TerminalSupplySelectionState,
346404
): TerminalActivityRecordDraft {

0 commit comments

Comments
 (0)