Skip to content

Commit f18c5db

Browse files
wip v28
1 parent 86be960 commit f18c5db

13 files changed

Lines changed: 662 additions & 48 deletions

BITCODE_V28_QA.md

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -810,26 +810,36 @@ The row for the current user should report `terminal_prerequisite_state='ready_f
810810
If it reports `warning:ENGI_repo_not_in_inventory`, continue only if another connected repository is intentionally selected in the UI and paste that repository name with the SQL result.
811811
If wallet profile projection warnings report missing `network`, `authAddress`, or `paymentAddress` while the active wallet `user_connections` row contains those values, run `v28_qa_01b_backfill_profile_wallet_projection_from_connection` once and rerun query 01 before continuing.
812812
If it reports any `blocker:*`, stop and repair that prerequisite before Terminal write QA.
813+
If Terminal visibly reports `Failed to fetch execution history`, `/api/executions/history` is not green. Run the execution-history migration in `supabase/migrations/20260515010000_terminal_execution_history.sql`, redeploy or rerun the app against the migrated database, then refresh Terminal before recording Give.
813814
814815
Give path:
815816
816817
1. Hard refresh `/terminal` and wait for top chrome wallet state and Terminal sync to settle.
817-
2. Confirm the repository/source context is live GitHub inventory, not mock data. Prefer `engineeredsoftware/ENGI` for the first pass.
818-
3. Confirm no model picker can affect ledgerized Give/Fit/AssetPack synthesis.
819-
4. In `Give + need chain`, inspect the `give` card and capture selected source entries, artifact kinds, repository row, and profile row.
820-
5. Click `Record give posture`.
821-
6. Confirm the UI reports that give-side share posture was recorded.
822-
7. In Network, capture the `/api/executions/history` request and response. Expected status is `201`.
823-
8. Run `v28_qa_terminal_02_activity_after_write` and confirm an `executions_recent` row with `type='agentic-execution:asset-pack'`, `context_summary.source='terminal-give-need-workbench'`, `context_summary.workbench='give'`, and a non-empty `output_summary.give`.
818+
2. In the top Terminal activity area, confirm there is no visible red or amber `Failed to fetch execution history` error. Empty activity is acceptable; a 500/error banner is not.
819+
3. In `Repository supply`, confirm `Connection posture` says GitHub is connected, `Mode` is `live connection`, and `Inventory source` is `stored protocol inventory` or `live provider inventory`.
820+
4. In the repository selector, choose `engineeredsoftware/ENGI` for the first pass unless intentionally testing another `engineeredsoftware/*` repository.
821+
5. In `Give-side supply`, confirm the auth/session label and inventory cards use `engineeredsoftware/*`. If any `frontier/*`, `gh_inst_bitcode_001`, or other protocol-demo repository appears in the live staging lane, stop and classify as a V28 blocker.
822+
6. In `Give-side supply`, use the search box only to filter connected repositories. Search must not replace live inventory with protocol demo artifacts. Select/confirm one repository card; the selected card should match the `Repository supply` selector.
823+
7. Click `Record give selection`. Confirm the UI reports that selected give-side supply was recorded.
824+
8. Run `v28_qa_terminal_02_activity_after_write` and `v28_qa_terminal_03_give_repository_alignment`. Confirm query 03 reports `frontier_count=0` for current repository inventory and `frontier_reference_detected=false` for recent Terminal give activity.
825+
9. Confirm no model picker can affect ledgerized Give/Fit/AssetPack synthesis.
826+
10. In `Give + need chain`, inspect the `give` card and capture selected source entries, artifact kinds, repository row, provider account, addressing root, and auth root.
827+
11. Click `Record give posture`.
828+
12. Confirm the UI reports that give-side share posture was recorded.
829+
13. In Network, capture the `/api/executions/history` request and response. Expected status is `201`.
830+
14. Run `v28_qa_terminal_02_activity_after_write` and confirm an `executions_recent` row with `type='agentic-execution:asset-pack'`, `context_summary.source='terminal-give-need-workbench'`, `context_summary.workbench='give'`, and a non-empty `output_summary.give`.
831+
15. Rerun `v28_qa_terminal_03_give_repository_alignment`; recent Give activity must reference the connected repository and must not reference `frontier/*`.
824832
825833
Need path:
826834
827-
1. Keep the same Terminal session and the same repository/source posture used for Give.
828-
2. In `Give + need chain`, inspect the `need` card and capture the summary, scenario, parser, closure criteria count, target kinds count, and repository row.
829-
3. Click `Record need posture`.
830-
4. Confirm the UI reports that need-measurement posture was recorded.
831-
5. In Network, capture the `/api/executions/history` request and response. Expected status is `201`.
832-
6. Run `v28_qa_terminal_02_activity_after_write` and confirm an `executions_recent` row with `type='agentic-execution:need-measurement'`, `context_summary.source='terminal-need-scenario-panel'`, and the same scenario/repository shown in the UI.
835+
1. Continue only after the Give selection and Give posture rows above exist. Need/Fit QA requires an established Give/source posture first.
836+
2. Keep the same Terminal session and the same repository/source posture used for Give.
837+
3. In `Give + need chain`, inspect the `need` card and capture the summary, scenario, parser, closure criteria count, target kinds count, and repository row.
838+
4. Confirm the Need repository row matches the Give repository. If it falls back to `frontier/*`, stop before recording Need.
839+
5. Click `Record need posture`.
840+
6. Confirm the UI reports that need-measurement posture was recorded.
841+
7. In Network, capture the `/api/executions/history` request and response. Expected status is `201`.
842+
8. Run `v28_qa_terminal_02_activity_after_write` and confirm an `executions_recent` row with `type='agentic-execution:need-measurement'`, `context_summary.source='terminal-need-scenario-panel'`, and the same scenario/repository shown in the UI.
833843
834844
Fit and closure path:
835845
@@ -851,7 +861,10 @@ BTD/ledger readback:
851861
Pass criteria:
852862
853863
- Wallet/Auth/Profile/GitHub/repository prerequisites are ready in query 01.
864+
- Terminal activity history loads without a visible `/api/executions/history` error.
865+
- Live Terminal Give inventory references connected `engineeredsoftware/*` repositories, not protocol-demo `frontier/*` repositories.
854866
- Give, Need, and Fit record actions write user-scoped rows in that order and reread in query 02.
867+
- Query `v28_qa_terminal_03_give_repository_alignment` shows no `frontier_reference_detected` rows for recorded Terminal Give activity.
855868
- The Terminal activity UI shows those rows after refresh or activity reload.
856869
- Branch/settlement either progresses with explicit network and SQL evidence or fails closed with a precise blocker.
857870
- No Terminal control routes through Exchange or website Conversations.
@@ -1109,6 +1122,12 @@ Saved query name: `v28_qa_terminal_02_activity_after_write`
11091122
11101123
Use `supabase/queries/v28_qa_terminal_02_activity_after_write.sql` after every `Record give posture`, `Record need posture`, `Record fit posture`, or `Make Bitcode branch` action. This query reports optional runtime tables as missing instead of hard-erroring, so a missing `public.executions` or `public.execution_events` row becomes explicit QA evidence.
11111124
1125+
Terminal Give source alignment:
1126+
1127+
Saved query name: `v28_qa_terminal_03_give_repository_alignment`
1128+
1129+
Use `supabase/queries/v28_qa_terminal_03_give_repository_alignment.sql` after Terminal loads and after each Give recording. The query confirms live repository inventory belongs to the connected GitHub account and flags any protocol-demo `frontier/*` reference in recent Terminal Give activity.
1130+
11121131
BTD and ledger projection readback:
11131132
11141133
Saved query name: `v28_qa_terminal_03_btd_ledger_after_terminal`

supabase/DATA_HEALTH.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ reusable checks:
127127
`supabase/queries/v28_qa_terminal_02_activity_after_write.sql` checks
128128
Terminal activity, execution events, pipeline rows, stream logs, and errors
129129
after each Terminal write action.
130+
- `v28_qa_terminal_03_give_repository_alignment`:
131+
`supabase/queries/v28_qa_terminal_03_give_repository_alignment.sql` confirms
132+
the Terminal Give source is the connected GitHub repository inventory and
133+
flags any live-lane leakage from protocol demonstration `frontier/*` data.
130134
- `v28_qa_terminal_03_btd_ledger_after_terminal`:
131135
`supabase/queries/v28_qa_terminal_03_btd_ledger_after_terminal.sql` checks
132136
BTD measuremint, ranges, BTC fee receipts, Terminal journal, ledger anchors,
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
-- Terminal execution history persistence for live Give/Need/Fit QA.
2+
-- The API route reads and writes these rows through the service role, while
3+
-- authenticated owner policies keep the tables safe for future direct reads.
4+
5+
CREATE TABLE IF NOT EXISTS "public"."executions" (
6+
"id" uuid PRIMARY KEY DEFAULT "gen_random_uuid"(),
7+
"user_id" uuid NOT NULL REFERENCES "auth"."users"("id") ON DELETE CASCADE,
8+
"type" text,
9+
"status" text DEFAULT 'pending',
10+
"input" jsonb,
11+
"output" jsonb,
12+
"context" jsonb,
13+
"items" jsonb DEFAULT '[]'::jsonb,
14+
"config" jsonb,
15+
"error" jsonb,
16+
"total_tokens" integer,
17+
"total_cost" numeric,
18+
"duration_ms" integer,
19+
"deliverable_id" uuid,
20+
"pipeline_run_id" uuid,
21+
"started_at" timestamp with time zone,
22+
"completed_at" timestamp with time zone,
23+
"created_at" timestamp with time zone DEFAULT "now"(),
24+
"updated_at" timestamp with time zone DEFAULT "now"()
25+
);
26+
27+
CREATE TABLE IF NOT EXISTS "public"."execution_events" (
28+
"id" uuid PRIMARY KEY DEFAULT "gen_random_uuid"(),
29+
"run_id" uuid NOT NULL REFERENCES "public"."executions"("id") ON DELETE CASCADE,
30+
"event_type" text NOT NULL,
31+
"event_data" jsonb,
32+
"agent_name" text,
33+
"phase" text,
34+
"created_at" timestamp with time zone DEFAULT "now"()
35+
);
36+
37+
CREATE INDEX IF NOT EXISTS "idx_executions_user_created_at"
38+
ON "public"."executions" ("user_id", "created_at" DESC);
39+
40+
CREATE INDEX IF NOT EXISTS "idx_executions_user_type_created_at"
41+
ON "public"."executions" ("user_id", "type", "created_at" DESC);
42+
43+
CREATE INDEX IF NOT EXISTS "idx_execution_events_run_created_at"
44+
ON "public"."execution_events" ("run_id", "created_at");
45+
46+
CREATE OR REPLACE TRIGGER "update_executions_updated_at"
47+
BEFORE UPDATE ON "public"."executions"
48+
FOR EACH ROW
49+
EXECUTE FUNCTION "public"."update_updated_at"();
50+
51+
ALTER TABLE "public"."executions" ENABLE ROW LEVEL SECURITY;
52+
ALTER TABLE "public"."execution_events" ENABLE ROW LEVEL SECURITY;
53+
54+
DO $$
55+
BEGIN
56+
IF NOT EXISTS (
57+
SELECT 1 FROM pg_policies
58+
WHERE schemaname = 'public'
59+
AND tablename = 'executions'
60+
AND policyname = 'executions_service_role_all'
61+
) THEN
62+
CREATE POLICY "executions_service_role_all"
63+
ON "public"."executions"
64+
FOR ALL
65+
TO "service_role"
66+
USING (true)
67+
WITH CHECK (true);
68+
END IF;
69+
70+
IF NOT EXISTS (
71+
SELECT 1 FROM pg_policies
72+
WHERE schemaname = 'public'
73+
AND tablename = 'executions'
74+
AND policyname = 'executions_owner_select'
75+
) THEN
76+
CREATE POLICY "executions_owner_select"
77+
ON "public"."executions"
78+
FOR SELECT
79+
TO "authenticated"
80+
USING ("auth"."uid"() = "user_id");
81+
END IF;
82+
83+
IF NOT EXISTS (
84+
SELECT 1 FROM pg_policies
85+
WHERE schemaname = 'public'
86+
AND tablename = 'executions'
87+
AND policyname = 'executions_owner_insert'
88+
) THEN
89+
CREATE POLICY "executions_owner_insert"
90+
ON "public"."executions"
91+
FOR INSERT
92+
TO "authenticated"
93+
WITH CHECK ("auth"."uid"() = "user_id");
94+
END IF;
95+
96+
IF NOT EXISTS (
97+
SELECT 1 FROM pg_policies
98+
WHERE schemaname = 'public'
99+
AND tablename = 'executions'
100+
AND policyname = 'executions_owner_update'
101+
) THEN
102+
CREATE POLICY "executions_owner_update"
103+
ON "public"."executions"
104+
FOR UPDATE
105+
TO "authenticated"
106+
USING ("auth"."uid"() = "user_id")
107+
WITH CHECK ("auth"."uid"() = "user_id");
108+
END IF;
109+
110+
IF NOT EXISTS (
111+
SELECT 1 FROM pg_policies
112+
WHERE schemaname = 'public'
113+
AND tablename = 'execution_events'
114+
AND policyname = 'execution_events_service_role_all'
115+
) THEN
116+
CREATE POLICY "execution_events_service_role_all"
117+
ON "public"."execution_events"
118+
FOR ALL
119+
TO "service_role"
120+
USING (true)
121+
WITH CHECK (true);
122+
END IF;
123+
124+
IF NOT EXISTS (
125+
SELECT 1 FROM pg_policies
126+
WHERE schemaname = 'public'
127+
AND tablename = 'execution_events'
128+
AND policyname = 'execution_events_owner_select'
129+
) THEN
130+
CREATE POLICY "execution_events_owner_select"
131+
ON "public"."execution_events"
132+
FOR SELECT
133+
TO "authenticated"
134+
USING (
135+
EXISTS (
136+
SELECT 1
137+
FROM "public"."executions"
138+
WHERE "executions"."id" = "execution_events"."run_id"
139+
AND "executions"."user_id" = "auth"."uid"()
140+
)
141+
);
142+
END IF;
143+
END;
144+
$$;
145+
146+
GRANT SELECT, INSERT, UPDATE ON TABLE "public"."executions" TO "authenticated";
147+
GRANT ALL ON TABLE "public"."executions" TO "service_role";
148+
GRANT SELECT ON TABLE "public"."execution_events" TO "authenticated";
149+
GRANT ALL ON TABLE "public"."execution_events" TO "service_role";
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
-- Saved query name: v28_qa_terminal_03_give_repository_alignment
2+
-- Purpose: run after the Terminal page loads, and again after "Record give
3+
-- selection" or "Record give posture". It verifies live GitHub repository
4+
-- inventory is the Give source and flags any protocol-demo frontier leakage.
5+
6+
CREATE OR REPLACE FUNCTION pg_temp.v28_qa_terminal_give_repository_alignment()
7+
RETURNS TABLE(section text, rows jsonb)
8+
LANGUAGE plpgsql
9+
AS $$
10+
BEGIN
11+
RETURN QUERY
12+
WITH latest_user AS (
13+
SELECT user_id
14+
FROM public.user_connections
15+
WHERE provider = 'github' AND is_active = true
16+
ORDER BY updated_at DESC NULLS LAST
17+
LIMIT 1
18+
),
19+
repository_inventory AS (
20+
SELECT
21+
r.user_id::text,
22+
count(*) AS repository_count,
23+
count(*) FILTER (WHERE r.repo_full_name LIKE 'engineeredsoftware/%') AS engineeredsoftware_count,
24+
count(*) FILTER (WHERE r.repo_full_name LIKE 'frontier/%') AS frontier_count,
25+
jsonb_agg(
26+
jsonb_build_object(
27+
'repo_full_name', r.repo_full_name,
28+
'provider_repo_id', r.provider_repo_id,
29+
'language', r.repo_language,
30+
'default_branch', r.repo_default_branch,
31+
'private', r.repo_private,
32+
'updated_at', r.updated_at
33+
)
34+
ORDER BY (r.repo_full_name = 'engineeredsoftware/ENGI') DESC, r.repo_full_name
35+
) FILTER (WHERE r.repo_full_name IS NOT NULL) AS repositories
36+
FROM public.vcs_repositories r
37+
JOIN latest_user u ON u.user_id = r.user_id
38+
GROUP BY r.user_id
39+
)
40+
SELECT
41+
'current_repository_inventory'::text,
42+
coalesce(jsonb_agg(to_jsonb(repository_inventory)), '[]'::jsonb)
43+
FROM repository_inventory;
44+
45+
IF to_regclass('public.executions') IS NULL THEN
46+
RETURN QUERY
47+
SELECT
48+
'terminal_give_activity'::text,
49+
jsonb_build_array(
50+
jsonb_build_object(
51+
'missing_table', 'public.executions',
52+
'impact', 'Terminal Give/Need activity cannot persist until the execution-history migration runs.'
53+
)
54+
);
55+
ELSE
56+
RETURN QUERY EXECUTE $query$
57+
WITH latest_user AS (
58+
SELECT user_id
59+
FROM public.user_connections
60+
WHERE provider = 'github' AND is_active = true
61+
ORDER BY updated_at DESC NULLS LAST
62+
LIMIT 1
63+
),
64+
terminal_activity AS (
65+
SELECT
66+
e.id::text,
67+
e.user_id::text,
68+
e.type,
69+
e.status,
70+
e.created_at,
71+
e.context ->> 'source' AS source,
72+
e.context ->> 'repository' AS context_repository,
73+
e.context ->> 'repositoryFullName' AS context_repository_full_name,
74+
coalesce(e.output -> 'repo_snapshot', e.output #> '{asset_pack_completion,repoSnapshot}') AS repo_snapshot,
75+
coalesce(
76+
e.output #> '{asset_pack_completion,bitcodeActivityState,supplySelection,selectedEntries}',
77+
e.output #> '{asset_pack_completion,bitcodeActivityState,giveWorkbench,give,selectedEntries}',
78+
'[]'::jsonb
79+
) AS selected_entries,
80+
(to_jsonb(e)::text LIKE '%frontier/%') AS frontier_reference_detected,
81+
(to_jsonb(e)::text LIKE '%engineeredsoftware/%') AS engineeredsoftware_reference_detected
82+
FROM public.executions e
83+
JOIN latest_user u ON u.user_id = e.user_id
84+
WHERE e.context ->> 'source' IN (
85+
'terminal-supply-selection-panel',
86+
'terminal-give-need-workbench',
87+
'terminal-repository-context-panel'
88+
)
89+
ORDER BY e.created_at DESC
90+
LIMIT 15
91+
)
92+
SELECT
93+
'terminal_give_activity'::text,
94+
coalesce(jsonb_agg(to_jsonb(terminal_activity) ORDER BY created_at DESC), '[]'::jsonb)
95+
FROM terminal_activity;
96+
$query$;
97+
END IF;
98+
END;
99+
$$;
100+
101+
SELECT * FROM pg_temp.v28_qa_terminal_give_repository_alignment();

uapi/app/terminal/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Reusable Supabase query files for this pass live in `supabase/queries/`:
8080

8181
- `v28_qa_terminal_01_prerequisites_wallet_github_repo.sql`
8282
- `v28_qa_terminal_02_activity_after_write.sql`
83+
- `v28_qa_terminal_03_give_repository_alignment.sql`
8384
- `v28_qa_terminal_03_btd_ledger_after_terminal.sql`
8485

8586
Those queries are the operator evidence path for proving Terminal UI, API

uapi/app/terminal/TerminalPageClient.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,10 @@ export default function TerminalPageClient() {
456456
onContextChange={setRepositoryContext}
457457
onRecordActivity={handleRecordActivity}
458458
/>
459-
<TerminalSupplySelectionPanel onRecordActivity={handleRecordActivity} />
459+
<TerminalSupplySelectionPanel
460+
repositoryContext={repositoryContext}
461+
onRecordActivity={handleRecordActivity}
462+
/>
460463
<TerminalDepositComposer
461464
onRecordActivity={handleRecordActivity}
462465
repositoryAnchor={repositoryContext?.selectedRepository?.fullName || null}

0 commit comments

Comments
 (0)