feat: certify codegen chat drafts through loop

This commit is contained in:
thanhnv
2026-07-08 23:20:54 +09:00
parent 780fe86273
commit b3b0544ba8
15 changed files with 359 additions and 24 deletions
+5 -2
View File
@@ -57,7 +57,7 @@ Approval inbox / HITL:
or supplied `approvalJwt` is verified by harness `approval-verify.sh`; approved
settings proposals apply through `control-plane-settings.py`.
Governed Chat (Plan-18 MVP-0/1 + MVP-2 Track 4, Operator Track 5/6, and Track 8.1-8.4):
Governed Chat (Plan-18 MVP-0/1/2):
- `POST /api/v1/chat/ask` — Ask CASAN endpoint. The API only wraps harness
`chat-turn.py`; router verdicts, H4 input/output scan, action-gate decisions,
@@ -76,9 +76,12 @@ Governed Chat (Plan-18 MVP-0/1 + MVP-2 Track 4, Operator Track 5/6, and Track 8.
by chat audit/replay evidence, loop ticker rows, and token budget gauge.
- Delegation escalation returns `ESCALATED` and creates a pending `chat.escalate`
proposal in the approval inbox.
- CODEGEN requests are draft-only: `codegen-draft` outputs a state artifact, runs
`artifact-scan.sh` + `tool-output-scan.sh`, certifies through Plan-17 loop-run,
and never writes to the source tree.
- `/chat` UI shows actor/role scope, `mode/risk/decision` badges, certified answer,
evidence sources, registered operator actions, agent binding, loop certification,
action-gate status, router details, and audit hash. Side-effect requests outside
codegen draft scan status, action-gate status, router details, and audit hash. Side-effect requests outside
registered actions return governed `BLOCK` or `NOT_SUPPORTED` responses; operator
side effects are held until the loop draft is certified.
- `/command` UI renders the Chat/Loop widget in the existing evidence drawer flow.
@@ -134,6 +134,11 @@ export interface ChatAnswer {
trace_verify?: { ok: boolean; output: string };
replay?: { ok: boolean; output: string };
};
codegen?: {
artifact?: string;
artifact_scan?: { ok: boolean; output: string };
tool_output_scan?: { ok: boolean; output: string };
};
actor: SettingsActor;
}
@@ -247,6 +247,16 @@ export function Chat() {
</div>
</div>
)}
{last.codegen && (
<div className="rounded border border-gray-200 p-3">
<div className="text-xs font-semibold uppercase text-gray-400">Codegen draft</div>
<div className="mt-1 font-medium text-gray-800 break-all">{last.codegen.artifact ?? 'n/a'}</div>
<div className="mt-2 flex flex-wrap gap-2">
<StatusBadge value={last.codegen.artifact_scan?.ok ? 'artifact scan ok' : 'artifact scan held'} />
<StatusBadge value={last.codegen.tool_output_scan?.ok ? 'output scan ok' : 'output scan held'} />
</div>
</div>
)}
<div>
<div className="text-xs font-semibold uppercase text-gray-400">Matched rules</div>
<div className="mt-1 flex flex-wrap gap-2">