@@ -36,22 +36,34 @@ BEGIN
3636 e .created_at ,
3737 e .context - >> ' source' AS source,
3838 e .context - >> ' workbench' AS workbench,
39- CASE
40- WHEN e .context - >> ' source' = ' terminal-deposit-composer'
41- OR (e .context - >> ' source' = ' terminal-deposit-read-workbench' AND e .context - >> ' workbench' = ' deposit' )
42- OR e .output ? ' deposit'
43- OR e .output ? ' asset'
44- THEN ' deposit'
39+ CASE
40+ WHEN e .context - >> ' source' = ' terminal-deposit-composer'
41+ OR (e .context - >> ' source' = ' terminal-deposit-read-workbench' AND e .context - >> ' workbench' = ' deposit' )
42+ OR e .output ? ' deposit'
43+ OR e .output ? ' deposit_asset'
44+ OR e .output ? ' asset'
45+ THEN ' deposit'
4546 WHEN e .context - >> ' source' = ' terminal-read-scenario-panel'
4647 OR e .type IN (' agentic-execution:read-measurement' , ' pipeline:measure' )
4748 OR e .output ? ' readMeasurement'
4849 THEN ' read'
4950 WHEN e .type IN (' agentic-execution:proof-refresh' , ' pipeline:proof-refresh' )
5051 OR (e .context - >> ' source' = ' terminal-deposit-read-workbench' AND e .context - >> ' workbench' = ' fit' )
5152 OR e .output ? ' fit'
52- THEN ' fit'
53- ELSE ' other'
54- END AS activity_class,
53+ THEN ' fit'
54+ ELSE ' other'
55+ END AS activity_class,
56+ CASE
57+ WHEN e .context - >> ' source' = ' terminal-deposit-composer'
58+ OR e .output ? ' deposit_asset'
59+ OR e .output ? ' asset'
60+ OR nullif(e .context - >> ' candidateAssetId' , ' ' ) IS NOT NULL
61+ THEN ' submission'
62+ WHEN e .context - >> ' source' = ' terminal-deposit-read-workbench'
63+ AND e .context - >> ' workbench' = ' deposit'
64+ THEN ' posture'
65+ ELSE NULL
66+ END AS deposit_kind,
5567 coalesce(
5668 e .context - >> ' repositoryFullName' ,
5769 e .context - >> ' repositoryAnchor' ,
@@ -97,10 +109,12 @@ BEGIN
97109 e .output # >> '{readMeasurement,targetKindCount}',
98110 e .output # >> '{asset_pack_completion,bitcodeActivityState,readMeasurement,targetKindCount}'
99111 ), ' ' )::integer AS target_kind_count,
100- coalesce(
101- e .output # >> '{asset,assetId}',
102- e .context - >> ' candidateAssetId' ,
103- e .output # >> '{asset_pack_completion,bitcodeActivityState,fitWorkbench,deposit,selectedEntries,0,id}'
112+ coalesce(
113+ e .output # >> '{deposit_asset,assetId}',
114+ e .output # >> '{deposit_asset_id}',
115+ e .output # >> '{asset,assetId}',
116+ e .context - >> ' candidateAssetId' ,
117+ e .output # >> '{asset_pack_completion,bitcodeActivityState,fitWorkbench,deposit,selectedEntries,0,id}'
104118 ) AS candidate_asset_id,
105119 coalesce(
106120 e .output # >> '{fit,summary}',
@@ -116,25 +130,45 @@ BEGIN
116130 e .output ? ' fit'
117131 OR e .output # > '{asset_pack_completion,bitcodeActivityState,fitWorkbench}' IS NOT NULL
118132 ) AS has_fit_posture,
119- (
120- e .output # > '{asset,attestations}' IS NOT NULL
121- OR e .output # > '{asset,signingSurface}' IS NOT NULL
122- OR e .context - >> ' walletAuthorizationSigned' = ' true'
123- ) AS has_wallet_or_attestation_proof,
124- (
125- e .output # > '{asset,assetMeasurement}' IS NOT NULL
126- OR e .output # > '{asset,contentUnits}' IS NOT NULL
127- OR e .output # > '{asset,measurementProvenance}' IS NOT NULL
128- ) AS has_asset_measurement_evidence,
129- (to_jsonb(e)::text LIKE ' %frontier/%' ) AS frontier_reference_detected,
130- (to_jsonb(e)::text LIKE ' %mock%' ) AS mock_reference_detected,
133+ (
134+ e .output # > '{deposit_asset,attestations}' IS NOT NULL
135+ OR e .output # > '{deposit_asset,signingSurface}' IS NOT NULL
136+ OR e .output # > '{deposit_asset,identitySurface}' IS NOT NULL
137+ OR e .output # > '{deposit_asset,githubBoundary}' IS NOT NULL
138+ OR e .output # > '{deposit_asset,githubAppAuthSurface}' IS NOT NULL
139+ OR
140+ e .output # > '{asset,attestations}' IS NOT NULL
141+ OR e .output # > '{asset,signingSurface}' IS NOT NULL
142+ OR e .context - >> ' walletAuthorizationSigned' = ' true'
143+ ) AS has_wallet_or_attestation_proof,
144+ (
145+ e .output # > '{deposit_asset,assetMeasurement}' IS NOT NULL
146+ OR e .output # > '{deposit_asset,contentUnits}' IS NOT NULL
147+ OR e .output # > '{deposit_asset,measurementProvenance}' IS NOT NULL
148+ OR
149+ e .output # > '{asset,assetMeasurement}' IS NOT NULL
150+ OR e .output # > '{asset,contentUnits}' IS NOT NULL
151+ OR e .output # > '{asset,measurementProvenance}' IS NOT NULL
152+ ) AS has_asset_measurement_evidence,
153+ (
154+ coalesce(e .context - >> ' repositoryFullName' , e .context - >> ' repositoryAnchor' , ' ' ) LIKE ' frontier/%'
155+ OR coalesce(e .output # >> '{repo_snapshot,org}', e.output #>> '{asset_pack_completion,repoSnapshot,org}', '') = 'frontier'
156+ OR coalesce(e .output # >> '{readMeasurement,scenario,repo}', '') LIKE 'frontier/%'
157+ OR coalesce(e .output # >> '{asset_pack_completion,bitcodeActivityState,readMeasurement,scenario,repo}', '') LIKE 'frontier/%'
158+ OR coalesce(e .output # >> '{deposit_asset,githubBoundary,sourceRepo}', e.output #>> '{asset,githubBoundary,sourceRepo}', '') LIKE 'frontier/%'
159+ ) AS frontier_reference_detected,
160+ (
161+ lower (coalesce(e .context - >> ' provider' , ' ' )) IN (' mock' , ' demo' )
162+ OR lower (coalesce(e .context - >> ' repositoryFullName' , e .context - >> ' repositoryAnchor' , ' ' )) LIKE ' mock/%'
163+ OR lower (coalesce(e .output # >> '{deposit_asset,githubBoundary,sourceProvider}', e.output #>> '{asset,githubBoundary,sourceProvider}', '')) IN ('mock', 'demo')
164+ ) AS mock_reference_detected,
131165 jsonb_build_object(
132166 ' summary' , coalesce(e .output - >> ' summary' , e .output # >> '{asset_pack_completion,summary}'),
133167 ' repo_snapshot' , coalesce(e .output - > ' repo_snapshot' , e .output # > '{asset_pack_completion,repoSnapshot}'),
134- ' read_measurement' , coalesce(e .output - > ' readMeasurement' , e .output # > '{asset_pack_completion,bitcodeActivityState,readMeasurement}'),
135- ' fit' , coalesce(e .output - > ' fit' , e .output # > '{asset_pack_completion,bitcodeActivityState,fitWorkbench,fit}'),
136- ' deposit_asset_id' , coalesce(e .output # >> '{asset,assetId}', e.context ->> 'candidateAssetId')
137- ) AS evidence_summary
168+ ' read_measurement' , coalesce(e .output - > ' readMeasurement' , e .output # > '{asset_pack_completion,bitcodeActivityState,readMeasurement}'),
169+ ' fit' , coalesce(e .output - > ' fit' , e .output # > '{asset_pack_completion,bitcodeActivityState,fitWorkbench,fit}'),
170+ ' deposit_asset_id' , coalesce(e . output # >> '{deposit_asset,assetId}', e.output #>> '{deposit_asset_id}', e.output #>> '{asset,assetId}', e.context ->> 'candidateAssetId')
171+ ) AS evidence_summary
138172 FROM public .executions e
139173 JOIN latest_user u ON u .user_id = e .user_id
140174 WHERE
@@ -147,18 +181,63 @@ BEGIN
147181 ' pipeline:proof-refresh'
148182 )
149183 ),
150- latest AS (
151- SELECT
152- (SELECT to_jsonb(activity) FROM activity WHERE activity_class = ' deposit' ORDER BY created_at DESC LIMIT 1 ) AS deposit,
153- (SELECT to_jsonb(activity) FROM activity WHERE activity_class = ' read' ORDER BY created_at DESC LIMIT 1 ) AS read,
154- (SELECT to_jsonb(activity) FROM activity WHERE activity_class = ' fit' ORDER BY created_at DESC LIMIT 1 ) AS fit,
155- EXISTS (SELECT 1 FROM activity WHERE frontier_reference_detected) AS any_frontier_reference,
156- EXISTS (SELECT 1 FROM activity WHERE mock_reference_detected) AS any_mock_reference
157- ),
158- critical_summary AS (
159- SELECT
160- deposit - >> ' id' AS latest_deposit_id,
161- read - >> ' id' AS latest_read_id,
184+ latest_read AS (
185+ SELECT *
186+ FROM activity
187+ WHERE activity_class = ' read'
188+ ORDER BY created_at DESC
189+ LIMIT 1
190+ ),
191+ latest_fit AS (
192+ SELECT *
193+ FROM activity
194+ WHERE activity_class = ' fit'
195+ ORDER BY created_at DESC
196+ LIMIT 1
197+ ),
198+ latest_deposit_submission AS (
199+ SELECT *
200+ FROM activity
201+ WHERE activity_class = ' deposit' AND deposit_kind = ' submission'
202+ ORDER BY created_at DESC
203+ LIMIT 1
204+ ),
205+ latest_deposit_posture AS (
206+ SELECT *
207+ FROM activity
208+ WHERE activity_class = ' deposit' AND deposit_kind = ' posture'
209+ ORDER BY created_at DESC
210+ LIMIT 1
211+ ),
212+ latest AS (
213+ SELECT
214+ coalesce(
215+ (SELECT to_jsonb(latest_deposit_submission) FROM latest_deposit_submission),
216+ (SELECT to_jsonb(latest_deposit_posture) FROM latest_deposit_posture)
217+ ) AS deposit,
218+ (SELECT to_jsonb(latest_deposit_submission) FROM latest_deposit_submission) AS deposit_submission,
219+ (SELECT to_jsonb(latest_deposit_posture) FROM latest_deposit_posture) AS deposit_posture,
220+ (SELECT to_jsonb(latest_read) FROM latest_read) AS read,
221+ (SELECT to_jsonb(latest_fit) FROM latest_fit) AS fit,
222+ EXISTS (SELECT 1 FROM activity WHERE frontier_reference_detected) AS any_frontier_reference,
223+ EXISTS (SELECT 1 FROM activity WHERE mock_reference_detected) AS any_mock_reference,
224+ EXISTS (
225+ SELECT 1
226+ FROM activity d
227+ JOIN latest_read r ON true
228+ WHERE d .activity_class = ' deposit'
229+ AND d .deposit_kind = ' submission'
230+ AND d .repository_full_name = r .repository_full_name
231+ AND coalesce(d .source_branch , ' ' ) = coalesce(r .source_branch , ' ' )
232+ AND coalesce(d .source_commit , ' ' ) = coalesce(r .source_commit , ' ' )
233+ ) AS has_deposit_submission_for_read_revision
234+ ),
235+ critical_summary AS (
236+ SELECT
237+ deposit - >> ' id' AS latest_deposit_id,
238+ deposit_submission - >> ' id' AS latest_deposit_submission_id,
239+ deposit_posture - >> ' id' AS latest_deposit_posture_id,
240+ read - >> ' id' AS latest_read_id,
162241 fit - >> ' id' AS latest_fit_id,
163242 deposit - >> ' repository_full_name' AS deposit_repository,
164243 read - >> ' repository_full_name' AS read_repository,
@@ -170,12 +249,14 @@ BEGIN
170249 nullif(read - >> ' closure_criteria_count' , ' ' )::integer AS read_closure_criteria_count,
171250 nullif(read - >> ' target_kind_count' , ' ' )::integer AS read_target_kind_count,
172251 (deposit - >> ' created_at' )::timestamptz AS deposit_created_at,
173- (read - >> ' created_at' )::timestamptz AS read_created_at,
174- (fit - >> ' created_at' )::timestamptz AS fit_created_at,
175- CASE
176- WHEN deposit IS NULL THEN ' blocker:deposit_activity_missing'
177- WHEN read IS NULL THEN ' blocker:read_activity_missing'
178- WHEN fit IS NULL THEN ' blocker:fit_activity_missing'
252+ (read - >> ' created_at' )::timestamptz AS read_created_at,
253+ (fit - >> ' created_at' )::timestamptz AS fit_created_at,
254+ has_deposit_submission_for_read_revision,
255+ CASE
256+ WHEN deposit IS NULL THEN ' blocker:deposit_activity_missing'
257+ WHEN read IS NULL THEN ' blocker:read_activity_missing'
258+ WHEN NOT has_deposit_submission_for_read_revision THEN ' blocker:deposit_submission_missing_for_read_revision'
259+ WHEN fit IS NULL THEN ' blocker:fit_activity_missing'
179260 WHEN any_frontier_reference THEN ' blocker:frontier_repository_leakage'
180261 WHEN coalesce(read - >> ' repository_full_name' , fit - >> ' repository_full_name' , deposit - >> ' repository_full_name' ) <> (deposit - >> ' repository_full_name' )
181262 THEN ' blocker:read_not_bound_to_deposited_repository'
@@ -200,13 +281,15 @@ BEGIN
200281 WHEN any_mock_reference THEN ' warning:mock_reference_detected_review_context'
201282 ELSE ' no_frontier_or_mock_leakage_detected'
202283 END AS mock_frontier_state,
203- CASE
204- WHEN (deposit - >> ' has_wallet_or_attestation_proof' ) = ' true' THEN ' deposit_has_wallet_or_attestation_proof'
205- ELSE ' warning:deposit_wallet_or_attestation_proof_not_visible_in_execution_row'
206- END AS deposit_proof_state,
207- CASE
208- WHEN (deposit - >> ' has_asset_measurement_evidence' ) = ' true' THEN ' deposit_has_asset_measurement_evidence'
209- ELSE ' warning:deposit_measurement_evidence_not_visible_in_execution_row'
284+ CASE
285+ WHEN NOT has_deposit_submission_for_read_revision THEN ' blocker:deposit_submission_proof_not_available_for_read_revision'
286+ WHEN (deposit_submission - >> ' has_wallet_or_attestation_proof' ) = ' true' THEN ' deposit_has_wallet_or_attestation_proof'
287+ ELSE ' warning:deposit_wallet_or_attestation_proof_not_visible_in_execution_row'
288+ END AS deposit_proof_state,
289+ CASE
290+ WHEN NOT has_deposit_submission_for_read_revision THEN ' blocker:deposit_submission_measurement_not_available_for_read_revision'
291+ WHEN (deposit_submission - >> ' has_asset_measurement_evidence' ) = ' true' THEN ' deposit_has_asset_measurement_evidence'
292+ ELSE ' warning:deposit_measurement_evidence_not_visible_in_execution_row'
210293 END AS deposit_measurement_state,
211294 fit - >> ' fit_summary' AS latest_fit_summary
212295 FROM latest
0 commit comments