NB. ============================================================================= NB. Synthetic David — WorkItem / AgentResult sparse execution (PURE J) NB. Locale: david. Selected agents only — no swarm fan-out. NB. Product path: Prolog selected-set → dispatch_selected; EvidenceBundle only. NB. Python ../execution stays smoke harness only. NB. ============================================================================= cocurrent 'david' NB. Evidence row (boxed fields): NB. 0 evidence_id 1 source_id 2 source_type 3 content_hash 4 authority NB. NB. WorkItem (boxed fields): NB. 0 request_id 1 work_id 2 agent_id 3 task NB. 4 evidence_rows 5 required_outputs 6 permissions 7 deadline 8 risk_policy NB. NB. AgentResult (boxed fields): NB. 0 agent_id 1 status 2 conclusions 3 evidence_refs 4 provenance_root openscalar =: 3 : 0 v =. y while. (32 = 3!:0 v) *. (0 = # $ v) do. v =. > v end. v ) field =: 4 : 'openscalar x { y' NB. Non-empty character / open content nonempty =: 3 : 0 v =. openscalar y if. 32 = 3!:0 v do. 0 return. end. 0 < # v ) NB. One evidence row is ok iff evidence_id, source_id, content_hash are non-empty. NB. Bare text alone is never enough. evidence_row_ok =: 3 : 0 r =. y if. 3 > # r do. 0 return. end. (nonempty 0 { r) *. (nonempty 1 { r) *. (nonempty 3 { r) ) NB. Bundle = list of boxed evidence rows; empty bundle is not ok for dispatch. bundle_ok =: 3 : 0 rows =. y if. 0 = # rows do. 0 return. end. i =. 0 ok =. 1 while. i < # rows do. ok =. ok *. evidence_row_ok openscalar i { rows i =. i + 1 end. ok ) uniqseq =: 3 : 0 if. 0 = # y do. 0 $ a: return. end. ys =. boxopen y out =. 0 $ a: i =. 0 while. i < # ys do. v =. openscalar i { ys if. -. (< v) e. out do. out =. out , < v end. i =. i + 1 end. out ) fields =: 4 : 0 rows =. y i =. 0 out =. 0 $ a: while. i < # rows do. row =. openscalar i { rows out =. out , < x field row i =. i + 1 end. out ) NB. Load selected agent ids from a text file (one id per line). NB. Product handoff from Prolog / Spec J→swipl writer. load_selected =: 3 : 0 if. 0 = # (1!:0 < y) do. 0 $ a: return. end. raw =. 1!:1 < y lines =. <;._2 raw , LF out =. 0 $ a: i =. 0 while. i < # lines do. s =. openscalar i { lines NB. drop CR if present (Windows handoff) if. (2 = 3!:0 s) *. (0 < # s) do. if. 13 = {: s do. s =. }: s end. end. if. (2 = 3!:0 s) *. (0 < # s) do. out =. out , < s end. i =. i + 1 end. uniqseq out ) NB. Evidence ids from validated bundle rows bundle_ids =: 3 : 0 rows =. y out =. 0 $ a: i =. 0 while. i < # rows do. r =. openscalar i { rows out =. out , < 0 field r i =. i + 1 end. out ) NB. x = request: request_id ; task ; evidence_bundle ; required_outputs ; permissions ; risk_policy ; deadline NB. y = selected agent_id list (from Prolog) NB. Fails assert if bundle is not EvidenceBundle-ok (no bare text). build_work_items =: 4 : 0 bundle =. 2 field x NB. field peels the outer box; bundle is a list of evidence rows if. (32 = 3!:0 bundle) *. (0 = # $ bundle) do. bundle =. , < openscalar bundle end. assert. bundle_ok bundle aids =. uniqseq y rid =. 0 field x task =. 1 field x outs =. boxopen 3 field x perms =. boxopen 4 field x rpol =. 5 field x dl =. 6 field x wis =. 0 $ a: i =. 0 while. i < # aids do. aid =. openscalar i { aids wid =. rid , ':' , aid wi =. (