tgi-foundation 0.2.0.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. tgi/__init__.py +7 -0
  2. tgi/__main__.py +194 -0
  3. tgi/acquisition_history.py +45 -0
  4. tgi/acquisition_history_check.py +51 -0
  5. tgi/acquisition_monitor.py +66 -0
  6. tgi/acquisition_monitor_check.py +78 -0
  7. tgi/acquisition_projection.py +70 -0
  8. tgi/acquisition_projection_check.py +93 -0
  9. tgi/acquisition_role_cells.py +53 -0
  10. tgi/acquisition_role_constraints.py +13 -0
  11. tgi/acquisition_role_constraints_check.py +66 -0
  12. tgi/acquisition_snapshot.py +35 -0
  13. tgi/acquisition_stream.py +21 -0
  14. tgi/acquisition_witness.py +117 -0
  15. tgi/actuation_goal_frontier.py +117 -0
  16. tgi/actuation_goal_frontier_check.py +147 -0
  17. tgi/actuation_goal_workflow.py +159 -0
  18. tgi/actuation_sequence_feedback.py +41 -0
  19. tgi/actuation_sequence_feedback_check.py +43 -0
  20. tgi/ask_certificate.py +74 -0
  21. tgi/bands.py +59 -0
  22. tgi/capacity_graph.py +70 -0
  23. tgi/closed_actuation_goal_frontier.py +13 -0
  24. tgi/closed_actuation_goal_frontier_check.py +19 -0
  25. tgi/closed_actuation_goal_workflow.py +159 -0
  26. tgi/closure.py +202 -0
  27. tgi/compact_acquisition_map.py +68 -0
  28. tgi/compact_acquisition_map_check.py +91 -0
  29. tgi/compact_complete_role_core.py +36 -0
  30. tgi/compact_complete_role_core_check.py +62 -0
  31. tgi/compact_measured_path.py +84 -0
  32. tgi/compact_role_observation.py +13 -0
  33. tgi/compact_role_observation_check.py +66 -0
  34. tgi/compatible_joins.py +33 -0
  35. tgi/complete_role_core.py +53 -0
  36. tgi/complete_role_core_check.py +54 -0
  37. tgi/context_family_selection.py +45 -0
  38. tgi/context_family_selection_check.py +32 -0
  39. tgi/context_family_separation.py +43 -0
  40. tgi/context_family_separation_check.py +47 -0
  41. tgi/contextual_isometry.py +62 -0
  42. tgi/contextual_isometry_check.py +54 -0
  43. tgi/continuation_checkpoint.py +75 -0
  44. tgi/continuation_cycle.py +102 -0
  45. tgi/continuation_goal_frontier.py +13 -0
  46. tgi/continuation_goal_frontier_check.py +19 -0
  47. tgi/continuation_goal_workflow.py +159 -0
  48. tgi/continuation_learning.py +36 -0
  49. tgi/continuation_learning_check.py +53 -0
  50. tgi/correspondence.py +76 -0
  51. tgi/cross_action_correspondence.py +182 -0
  52. tgi/cross_action_correspondence_check.py +92 -0
  53. tgi/cross_view_identity_map.py +41 -0
  54. tgi/cross_view_identity_map_check.py +48 -0
  55. tgi/derivation.py +74 -0
  56. tgi/empirical_transport.py +74 -0
  57. tgi/empirical_transport_check.py +78 -0
  58. tgi/events.py +36 -0
  59. tgi/evidence_response.py +24 -0
  60. tgi/evidence_response_check.py +33 -0
  61. tgi/exact_field.py +101 -0
  62. tgi/experience.py +68 -0
  63. tgi/experience_cli.py +44 -0
  64. tgi/feedback_update.py +32 -0
  65. tgi/feedback_update_check.py +38 -0
  66. tgi/formation.py +74 -0
  67. tgi/frame_cli.py +26 -0
  68. tgi/frame_engine.py +214 -0
  69. tgi/functional_capacity.py +74 -0
  70. tgi/functional_capacity_check.py +110 -0
  71. tgi/functional_transition.py +40 -0
  72. tgi/functional_transition_check.py +58 -0
  73. tgi/geometry.py +143 -0
  74. tgi/grounding.py +285 -0
  75. tgi/guarded_word_closure.py +148 -0
  76. tgi/guarded_word_closure_check.py +171 -0
  77. tgi/guarded_word_goal_frontier.py +13 -0
  78. tgi/guarded_word_goal_frontier_check.py +19 -0
  79. tgi/guarded_word_goal_workflow.py +160 -0
  80. tgi/identity.py +32 -0
  81. tgi/incidence.py +155 -0
  82. tgi/incremental.py +134 -0
  83. tgi/intervention_composition.py +63 -0
  84. tgi/intervention_composition_check.py +84 -0
  85. tgi/intervention_continuity.py +43 -0
  86. tgi/intervention_continuity_check.py +56 -0
  87. tgi/intervention_correspondence.py +156 -0
  88. tgi/intervention_correspondence_check.py +80 -0
  89. tgi/intervention_edit_contrast.py +27 -0
  90. tgi/intervention_edit_contrast_check.py +41 -0
  91. tgi/intervention_experiment.py +62 -0
  92. tgi/intervention_experiment_check.py +78 -0
  93. tgi/intervention_resolution.py +45 -0
  94. tgi/intervention_resolution_check.py +70 -0
  95. tgi/intervention_roles.py +83 -0
  96. tgi/intervention_roles_check.py +91 -0
  97. tgi/intervention_scope.py +34 -0
  98. tgi/intervention_sequence_experiment.py +71 -0
  99. tgi/intervention_sequence_experiment_check.py +97 -0
  100. tgi/interventions.py +240 -0
  101. tgi/joint_correspondence.py +73 -0
  102. tgi/joint_frontier_acquisition.py +114 -0
  103. tgi/joint_frontier_acquisition_check.py +116 -0
  104. tgi/joint_goal_observation.py +49 -0
  105. tgi/joint_goal_observation_check.py +55 -0
  106. tgi/joint_goal_traversal.py +101 -0
  107. tgi/joint_goal_traversal_check.py +114 -0
  108. tgi/joint_observed_laws.py +40 -0
  109. tgi/joint_observed_laws_check.py +63 -0
  110. tgi/joint_temporal_candidates.py +40 -0
  111. tgi/joint_temporal_candidates_check.py +68 -0
  112. tgi/lineage_knowledge.py +29 -0
  113. tgi/lineage_knowledge_check.py +41 -0
  114. tgi/lineage_state.py +39 -0
  115. tgi/lineage_state_check.py +47 -0
  116. tgi/local_acquisition_ownership.py +65 -0
  117. tgi/local_acquisition_runtime.py +119 -0
  118. tgi/local_acquisition_selection.py +41 -0
  119. tgi/local_acquisition_transition.py +50 -0
  120. tgi/local_acquisition_transition_check.py +80 -0
  121. tgi/local_edit_transport_classes.py +220 -0
  122. tgi/local_edit_transport_classes_check.py +128 -0
  123. tgi/local_evidence_persistence.py +67 -0
  124. tgi/measured_actuation_transition.py +56 -0
  125. tgi/measured_actuation_transition_check.py +81 -0
  126. tgi/measured_capacity.py +61 -0
  127. tgi/measured_context.py +52 -0
  128. tgi/measured_context_check.py +65 -0
  129. tgi/measured_context_laws.py +75 -0
  130. tgi/measured_context_laws_check.py +91 -0
  131. tgi/measured_context_layout.py +49 -0
  132. tgi/measured_occurrence_path.py +70 -0
  133. tgi/momentum.py +43 -0
  134. tgi/observation_context_laws.py +32 -0
  135. tgi/observation_context_laws_check.py +40 -0
  136. tgi/observation_epochs.py +35 -0
  137. tgi/observation_epochs_check.py +51 -0
  138. tgi/observation_point.py +92 -0
  139. tgi/observation_projection.py +45 -0
  140. tgi/observation_projection_check.py +48 -0
  141. tgi/observed_actuation_cycle.py +114 -0
  142. tgi/observed_actuation_discovery.py +41 -0
  143. tgi/observed_actuation_discovery_check.py +54 -0
  144. tgi/observed_actuation_learning.py +71 -0
  145. tgi/observed_actuation_learning_check.py +73 -0
  146. tgi/observed_actuation_runtime.py +114 -0
  147. tgi/observed_context_actions.py +66 -0
  148. tgi/observed_context_actions_check.py +81 -0
  149. tgi/observed_joint_state.py +52 -0
  150. tgi/observed_joint_state_check.py +55 -0
  151. tgi/observed_refinement.py +43 -0
  152. tgi/observed_response.py +20 -0
  153. tgi/observed_response_check.py +27 -0
  154. tgi/observed_role_core.py +41 -0
  155. tgi/observed_role_core_check.py +54 -0
  156. tgi/occurrence_route.py +56 -0
  157. tgi/operator_windows.py +84 -0
  158. tgi/operator_windows_check.py +111 -0
  159. tgi/organization.py +484 -0
  160. tgi/organization_check.py +143 -0
  161. tgi/organization_cli.py +77 -0
  162. tgi/organization_inventory_check.py +82 -0
  163. tgi/organization_snapshot.py +50 -0
  164. tgi/path_isometry.py +82 -0
  165. tgi/path_temporal_feasibility.py +69 -0
  166. tgi/phase_evidence.py +100 -0
  167. tgi/port_distinction_exploration.py +37 -0
  168. tgi/port_distinction_exploration_check.py +40 -0
  169. tgi/proofcheck.py +117 -0
  170. tgi/provenance.py +19 -0
  171. tgi/recent_observation.py +145 -0
  172. tgi/relational.py +222 -0
  173. tgi/resonance.py +114 -0
  174. tgi/response_eligibility.py +46 -0
  175. tgi/response_eligibility_check.py +55 -0
  176. tgi/response_interval_order.py +59 -0
  177. tgi/response_interval_order_check.py +92 -0
  178. tgi/response_readout.py +53 -0
  179. tgi/response_readout_check.py +73 -0
  180. tgi/role_bundle.py +31 -0
  181. tgi/role_bundle_check.py +20 -0
  182. tgi/role_candidates.py +47 -0
  183. tgi/role_candidates_check.py +57 -0
  184. tgi/role_eligibility.py +34 -0
  185. tgi/role_eligibility_check.py +46 -0
  186. tgi/role_feedback.py +15 -0
  187. tgi/role_feedback_check.py +23 -0
  188. tgi/role_history.py +37 -0
  189. tgi/role_history_check.py +51 -0
  190. tgi/role_projection.py +16 -0
  191. tgi/role_projection_check.py +85 -0
  192. tgi/role_proposal.py +39 -0
  193. tgi/role_proposal_check.py +51 -0
  194. tgi/role_readout.py +31 -0
  195. tgi/role_readout_check.py +51 -0
  196. tgi/role_response.py +34 -0
  197. tgi/role_response_check.py +40 -0
  198. tgi/role_work.py +54 -0
  199. tgi/scoped_sequence_experiment.py +20 -0
  200. tgi/scoped_sequence_experiment_check.py +33 -0
  201. tgi/separation.py +74 -0
  202. tgi/separation_check.py +87 -0
  203. tgi/sequence_prefix_feedback.py +57 -0
  204. tgi/sequence_prefix_feedback_check.py +79 -0
  205. tgi/source_intervals.py +85 -0
  206. tgi/source_intervals_check.py +97 -0
  207. tgi/spatial.py +109 -0
  208. tgi/spatial_action_observation.py +88 -0
  209. tgi/spatial_action_relation.py +53 -0
  210. tgi/spatial_action_relation_check.py +45 -0
  211. tgi/spatial_action_relation_cycle.py +84 -0
  212. tgi/spatial_action_relation_migration.py +41 -0
  213. tgi/spatial_action_relation_migration_bundle.py +60 -0
  214. tgi/spatial_contextual_action_cycle.py +130 -0
  215. tgi/spatial_contextual_action_local.py +79 -0
  216. tgi/spatial_contextual_action_phase.py +81 -0
  217. tgi/spatial_contextual_action_phase_check.py +81 -0
  218. tgi/spatial_direct_action_cycle.py +98 -0
  219. tgi/spatial_direct_action_relation.py +60 -0
  220. tgi/spatial_direct_action_relation_check.py +67 -0
  221. tgi/spatial_local_action_cycle.py +62 -0
  222. tgi/spatial_local_action_relation.py +66 -0
  223. tgi/spatial_temporal_action_cycle.py +116 -0
  224. tgi/spatial_temporal_action_local.py +77 -0
  225. tgi/spatial_temporal_action_phase.py +89 -0
  226. tgi/spatial_temporal_action_phase_check.py +94 -0
  227. tgi/structural_append_closure.py +99 -0
  228. tgi/structural_append_closure_check.py +106 -0
  229. tgi/structural_continuation_closure.py +93 -0
  230. tgi/structural_continuation_closure_check.py +108 -0
  231. tgi/temporal_candidate_spectrum.py +57 -0
  232. tgi/temporal_candidate_spectrum_check.py +94 -0
  233. tgi/temporal_correspondence.py +41 -0
  234. tgi/temporal_correspondence_check.py +56 -0
  235. tgi/temporal_projection.py +41 -0
  236. tgi/temporal_projection_check.py +56 -0
  237. tgi/transport.py +294 -0
  238. tgi/transport_cli.py +27 -0
  239. tgi/unlabeled_port_classes.py +199 -0
  240. tgi/unlabeled_port_classes_check.py +113 -0
  241. tgi/unobserved_action_selection.py +47 -0
  242. tgi/unobserved_action_selection_check.py +40 -0
  243. tgi/verification.py +98 -0
  244. tgi/witness_function.py +62 -0
  245. tgi/witness_probe.py +50 -0
  246. tgi/witness_probe_feedback.py +106 -0
  247. tgi/witness_response.py +67 -0
  248. tgi_foundation-0.2.0.dev0.dist-info/METADATA +30 -0
  249. tgi_foundation-0.2.0.dev0.dist-info/RECORD +252 -0
  250. tgi_foundation-0.2.0.dev0.dist-info/WHEEL +5 -0
  251. tgi_foundation-0.2.0.dev0.dist-info/licenses/LICENSE +3 -0
  252. tgi_foundation-0.2.0.dev0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,159 @@
1
+ """Owned catalogue-aware selection, retained actual sessions and atomic recovery."""
2
+ from copy import deepcopy
3
+ from hashlib import sha256
4
+ import json,os,re,tempfile
5
+ from pathlib import Path
6
+ from .observed_actuation_runtime import ObservedActuationRuntime,raw
7
+ from .actuation_goal_frontier import certify_actuation_goal_frontier
8
+ from .actuation_goal_frontier_check import verify_actuation_goal_frontier
9
+ from .actuation_sequence_feedback import certify_actuation_sequence_feedback
10
+ from .actuation_sequence_feedback_check import verify_actuation_sequence_feedback,same_state_context
11
+ from .organization import RawOrganization
12
+ from .organization_snapshot import snapshot
13
+ from .organization_inventory_check import verify_organization_inventory
14
+ from .identity import REGISTRY_ID
15
+ from .frame_engine import canonical,unique_object
16
+ from .role_work import RoleSearchBudget
17
+ from .incremental import FormationSearchLimit
18
+ REVISION='TGI-ACTUATION-GOAL-WORKFLOW-V1'
19
+ FIELDS={'origin','frontier','selection_index','records','current','current_plan','current_frontier','feedback'}
20
+
21
+ def verify_session(s,goal,max_depth,budget):
22
+ budget.consume()
23
+ if type(s) is not dict or set(s)!=FIELDS or len(s['origin'])!=9 or len(s['current'])!=9 or type(s['records']) is not list:return False
24
+ for args in (s['origin'],s['current']):
25
+ if not verify_organization_inventory(snapshot(args[0])):return False
26
+ if not verify_actuation_goal_frontier(*s['origin'],goal,s['frontier'],max_depth=max_depth) or not verify_actuation_goal_frontier(*s['current'],goal,s['current_frontier'],max_depth=max_depth):return False
27
+ if canonical(s['current_frontier']['discovery'])!=canonical(s['current_plan']):return False
28
+ if s['selection_index'] is None:return not s['records'] and s['feedback'] is None and same_state_context(s['origin'],s['current'],budget)
29
+ return verify_actuation_sequence_feedback(s['origin'],goal,s['frontier'],s['selection_index'],s['records'],s['current'],s['current_plan'],s['feedback'],max_depth=max_depth)
30
+
31
+ def verify_sessions(archived,active,goal,max_depth,budget):
32
+ if type(archived) is not list:return False
33
+ previous=None
34
+ for s in [*archived,active]:
35
+ if not verify_session(s,goal,max_depth,budget) or (previous is not None and not same_state_context(previous,s['origin'],budget)):return False
36
+ previous=s['current']
37
+ return True
38
+
39
+ class ActuationGoalWorkflow:
40
+ def __init__(self,runtime,goal,*,max_depth=None,max_search_steps=None):
41
+ b=RoleSearchBudget(max_search_steps)
42
+ with b.scope():
43
+ b.consume();self._runtime=deepcopy(runtime);self._goal=deepcopy(goal);self._depth=max_depth;args=self._runtime.context();frontier=certify_actuation_goal_frontier(*args,goal,max_depth=max_depth)
44
+ self._active={'origin':args,'frontier':frontier,'selection_index':None,'records':[],'current':deepcopy(args),'current_plan':self._runtime.plan(),'current_frontier':deepcopy(frontier),'feedback':None};self._archived=[]
45
+ if not verify_sessions(self._archived,self._active,self._goal,self._depth,b):raise ValueError('Verified complete native goal workflow required')
46
+ def frontier(self):return deepcopy(self._active['current_frontier'])
47
+ def feedback(self):return deepcopy(self._active['feedback'])
48
+ def runtime(self):return deepcopy(self._runtime)
49
+ def sessions(self):return deepcopy([*self._archived,self._active])
50
+ def select(self,index,*,max_search_steps=None):
51
+ b=RoleSearchBudget(max_search_steps)
52
+ with b.scope():
53
+ b.consume()
54
+ if self._active['selection_index'] is not None or self._active['records']:raise ValueError('Replan before selecting another complete sequence')
55
+ obj=self.replan() if canonical(self._active['frontier'])!=canonical(self._active['current_frontier']) else deepcopy(self);obj._active['selection_index']=index;obj._active['feedback']=certify_actuation_sequence_feedback(obj._active['origin'],obj._goal,obj._active['frontier'],index,[],obj._active['current'],obj._active['current_plan'],max_depth=obj._depth)
56
+ if not verify_sessions(obj._archived,obj._active,obj._goal,obj._depth,b):raise ValueError('Independent selected workflow verification failed')
57
+ return obj
58
+ def pending(self):
59
+ s=self._active
60
+ if s['selection_index'] is None:return {'status':'SELECTION_REQUIRED','action':None,'position':0}
61
+ f=s['feedback']['result'];position=f['consumed_steps']
62
+ if f['terminal']:return {'status':f['status'],'action':None,'position':position}
63
+ choice=s['frontier']['choices'][s['selection_index']];action=choice['actions'][position];p=s['current_plan']
64
+ status='FRESH_CATALOGUE_REQUIRED' if not p['result']['catalogue_current'] else 'PLANNED_ACTION_UNAVAILABLE' if action not in p['available_actions'] else 'ACTUAL_TRANSITION_READY'
65
+ return {'status':status,'action':action,'position':position}
66
+ def _renew(self,runtime):
67
+ obj=deepcopy(self);obj._runtime=runtime;obj._active['current']=runtime.context();obj._active['current_plan']=runtime.plan();obj._active['current_frontier']=certify_actuation_goal_frontier(*obj._active['current'],obj._goal,max_depth=obj._depth)
68
+ if obj._active['selection_index'] is not None:obj._active['feedback']=certify_actuation_sequence_feedback(obj._active['origin'],obj._goal,obj._active['frontier'],obj._active['selection_index'],obj._active['records'],obj._active['current'],obj._active['current_plan'],max_depth=obj._depth)
69
+ return obj
70
+ def advance(self,acquired,groups,measurements,group_index,*,catalogue=None,catalogue_measurements=None,max_search_steps=None):
71
+ b=RoleSearchBudget(max_search_steps)
72
+ with b.scope():
73
+ b.consume();pending=self.pending()
74
+ if pending['status']!='ACTUAL_TRANSITION_READY':raise ValueError('Selected, available, current nonterminal action required')
75
+ args=self._runtime.context();p=self._runtime.plan();index=p['available_actions'].index(pending['action']);context=(*args,p,index,acquired,groups,measurements,group_index);next,c=self._runtime.advance(index,acquired,groups,measurements,group_index,catalogue=catalogue,catalogue_measurements=catalogue_measurements)
76
+ if next is None:return None,c
77
+ obj=deepcopy(self);obj._active['records'].append(deepcopy({'context':context,'after':next.context()[0],'certificate':c}));obj=obj._renew(next)
78
+ if not verify_sessions(obj._archived,obj._active,obj._goal,obj._depth,b):raise ValueError('Independent actual workflow verification failed')
79
+ return obj,c
80
+ def refresh_catalogue(self,catalogue,measurements,*,max_search_steps=None):
81
+ b=RoleSearchBudget(max_search_steps)
82
+ with b.scope():
83
+ b.consume();obj=self._renew(self._runtime.refresh_catalogue(catalogue,measurements))
84
+ if not verify_sessions(obj._archived,obj._active,obj._goal,obj._depth,b):raise ValueError('Independent catalogue refresh verification failed')
85
+ return obj
86
+ def replan(self,*,max_search_steps=None):
87
+ b=RoleSearchBudget(max_search_steps)
88
+ with b.scope():
89
+ b.consume();obj=type(self)(self._runtime,self._goal,max_depth=self._depth);obj._archived=deepcopy([*self._archived,self._active])
90
+ if not verify_sessions(obj._archived,obj._active,obj._goal,obj._depth,b):raise ValueError('Independent retained session verification failed')
91
+ return obj
92
+ def commit(self,path,*,max_search_steps=None):
93
+ b=RoleSearchBudget(max_search_steps)
94
+ with b.scope():
95
+ b.consume();archived,active=deepcopy((self._archived,self._active))
96
+ if not verify_sessions(archived,active,self._goal,self._depth,b):raise ValueError('Complete independently verified workflow required')
97
+ models=[];known={}
98
+ def model_id(m):
99
+ rows=raw(m);key=canonical(rows);b.consume_many(sum(len(f) for row in rows for f in row['frames'])+1)
100
+ if key not in known:known[key]=len(models);models.append(rows)
101
+ return {'model':known[key]}
102
+ def context(args):return [model_id(v) if i in ((0,3,7) if len(args)==9 else (0,3,7,11)) else v for i,v in enumerate(args)]
103
+ def session(s):return {**s,'origin':context(s['origin']),'current':context(s['current']),'records':[{'context':context(r['context']),'after':model_id(r['after']),'certificate':r['certificate']} for r in s['records']]}
104
+ saved_archived=[session(s) for s in archived];saved_active=session(active);payload={'revision':REVISION,'registry':REGISTRY_ID,'goal':deepcopy(self._goal),'max_depth':self._depth,'root_origin':context((archived[0] if archived else active)['origin']),'models':models,'archived':saved_archived,'active':saved_active};data=canonical({'payload':payload,'sha256':sha256(canonical(payload).encode()).hexdigest()}).encode('utf8');path=Path(path);temporary=None
105
+ try:
106
+ with tempfile.NamedTemporaryFile(mode='wb',prefix='tgi-goal-',dir=path.parent,delete=False) as f:temporary=Path(f.name);f.write(data);f.flush();os.fsync(f.fileno())
107
+ os.replace(temporary,path);temporary=None
108
+ finally:
109
+ if temporary is not None and temporary.exists():temporary.unlink()
110
+ return {'path':str(path),'sha256':sha256(data).hexdigest(),'bytes':len(data),'revision':REVISION,'raw_inventory_models':len(models),'archived_sessions':len(archived),'actual_records':sum(len(s['records']) for s in [*archived,active])}
111
+ @classmethod
112
+ def recover(cls,path,expected_sha256,*,max_search_steps=None):
113
+ b=RoleSearchBudget(max_search_steps)
114
+ with b.scope():
115
+ b.consume();data=Path(path).read_bytes()
116
+ if not isinstance(expected_sha256,str) or re.fullmatch('[0-9a-f]{64}',expected_sha256) is None or sha256(data).hexdigest()!=expected_sha256:raise ValueError('Original external workflow byte digest required')
117
+ envelope=json.loads(data.decode('utf8'),object_pairs_hook=unique_object)
118
+ if type(envelope) is not dict or set(envelope)!={'payload','sha256'}:raise ValueError('Invalid workflow envelope')
119
+ p=envelope['payload']
120
+ if type(p) is not dict or set(p)!={'revision','registry','goal','max_depth','root_origin','models','archived','active'} or p['revision']!=REVISION or p['registry']!=REGISTRY_ID or sha256(canonical(p).encode()).hexdigest()!=envelope['sha256']:raise ValueError('Invalid complete workflow payload')
121
+ if type(p['models']) is not list or not p['models']:raise ValueError('Original raw inventory pool required')
122
+ models=[];unique=set()
123
+ for rows in p['models']:
124
+ if type(rows) is not list or canonical(rows) in unique:raise ValueError('Unique complete raw inventory pool required')
125
+ unique.add(canonical(rows));m=RawOrganization()
126
+ for row in rows:
127
+ if type(row) is not dict or set(row)!={'source','frames'} or type(row['frames']) is not list:raise ValueError('Original raw episode required')
128
+ b.consume_many(sum(len(f) for f in row['frames'])+1);m.observe(row['source'],row['frames'])
129
+ limits=[];parent=b
130
+ while parent is not None:
131
+ if parent.limit is not None:limits.append(max(0,parent.limit-parent.used))
132
+ parent=getattr(parent,'parent',None)
133
+ try:m.form(max_search_steps=min(limits) if limits else None)
134
+ except FormationSearchLimit as error:b.consume_many(error.used);b.consume();raise
135
+ b.consume_many(m.formation_work['search_steps']);models.append(m)
136
+ used=set()
137
+ def model(marker):
138
+ if type(marker) is not dict or set(marker)!={'model'} or type(marker['model']) is not int or not 0<=marker['model']<len(models):raise ValueError('Exact original model slot required')
139
+ used.add(marker['model']);return models[marker['model']]
140
+ def context(args,size):
141
+ if type(args) is not list or len(args)!=size:raise ValueError('Complete original model context required')
142
+ for i in ((0,3,7) if size==9 else (0,3,7,11)):args[i]=model(args[i])
143
+ return tuple(args)
144
+ def session(s):
145
+ if type(s) is not dict or set(s)!=FIELDS or type(s['records']) is not list:raise ValueError('Complete original session required')
146
+ s['origin']=context(s['origin'],9);s['current']=context(s['current'],9)
147
+ for r in s['records']:
148
+ if type(r) is not dict or set(r)!={'context','after','certificate'}:raise ValueError('Complete original actual transition required')
149
+ r['context']=context(r['context'],15);r['after']=model(r['after'])
150
+ return s
151
+ if type(p['archived']) is not list:raise ValueError('Ordered retained sessions required')
152
+ archived=[session(s) for s in p['archived']];active=session(p['active']);root_origin=context(p['root_origin'],9)
153
+ first=(archived[0] if archived else active)['origin']
154
+ if not same_state_context(root_origin,first,b) or canonical(root_origin[8])!=canonical(first[8]) or canonical(raw(root_origin[7]))!=canonical(raw(first[7])):raise ValueError('Original root session binding required')
155
+ if used!=set(range(len(models))) or not verify_sessions(archived,active,p['goal'],p['max_depth'],b):raise ValueError('Independent full workflow recovery verification failed')
156
+ obj=cls.__new__(cls);obj._goal=p['goal'];obj._depth=p['max_depth'];obj._archived=archived;obj._active=active;runtime=ObservedActuationRuntime.__new__(ObservedActuationRuntime);runtime._args=tuple(active['current']);runtime._plan=active['current_plan'];runtime._transaction=None
157
+ for s in [*archived,active]:
158
+ for r in s['records']:runtime._transaction=(tuple(r['context']),r['after'],r['certificate'])
159
+ obj._runtime=runtime;return obj
@@ -0,0 +1,41 @@
1
+ """Original choice, actual available-command records and coherent sequence outcome."""
2
+ from copy import deepcopy
3
+ from .actuation_goal_frontier_check import verify_actuation_goal_frontier
4
+ from .measured_actuation_transition_check import verify_measured_actuation_transition
5
+ from .observed_actuation_discovery_check import verify_observed_actuation_discovery
6
+ from .observed_actuation_runtime import raw
7
+ from .joint_goal_traversal import _seed_routes
8
+ from .frame_engine import canonical
9
+ from .role_work import RoleSearchBudget
10
+
11
+ def same_state_context(a,b,budget):
12
+ budget.consume()
13
+ return len(a)>=7 and len(b)>=7 and all(canonical(raw(a[i]))==canonical(raw(b[i])) for i in (0,3)) and canonical([a[1],a[2],a[4],a[5],a[6]])==canonical([b[1],b[2],b[4],b[5],b[6]])
14
+
15
+ def certify_actuation_sequence_feedback(origin,goal,frontier,selection_index,records,current,current_plan,*,max_depth=None,max_search_steps=None):
16
+ budget=RoleSearchBudget(max_search_steps)
17
+ with budget.scope():
18
+ budget.consume()
19
+ if len(origin)!=9 or len(current)!=9 or not verify_actuation_goal_frontier(*origin,goal,frontier,max_depth=max_depth):raise ValueError('Original verified available-command frontier required')
20
+ if type(selection_index) is not int or not 0<=selection_index<len(frontier['choices']):raise ValueError('Original exact choice index required')
21
+ if not verify_observed_actuation_discovery(*current,current_plan):raise ValueError('Verified current actual state/capability plan required')
22
+ choice=frontier['choices'][selection_index];previous=origin;steps=[];status='SELECTED_SEQUENCE_PENDING';terminal=False
23
+ if not choice['actions']:status='GOAL_ALREADY_ACTUALLY_OBSERVED';terminal=True
24
+ for position,record in enumerate(records):
25
+ budget.consume()
26
+ if terminal or position>=len(choice['actions']) or type(record) is not dict or set(record)!={'context','after','certificate'}:raise ValueError('No extra, malformed or post-terminal record')
27
+ context=record['context'];after=record['after'];c=record['certificate']
28
+ if len(context)!=15 or not same_state_context(context,previous,budget) or not verify_measured_actuation_transition(*context,after,c) or not c['result']['experience_admitted']:raise ValueError('Complete linked actual transition required')
29
+ edge=frontier['edges'][choice['edges'][position]];before=frontier['nodes'][edge['source']]['state']
30
+ if canonical(context[9]['state_certificate']['state'])!=canonical(before) or c['selected_action']!=choice['actions'][position] or c['selected_action']!=edge['action']:raise ValueError('Original selected before state and command required')
31
+ expected=frontier['nodes'][edge['successor']]['state'] if edge['supported'] else None;actual=c['result']['actual_state'];route='UNRESOLVED' if expected is None else 'MATCHED' if actual==expected else 'CONTRADICTED'
32
+ if expected is None:status='FRONTIER_EXPERIENCE_ACTUALLY_VERIFIED';terminal=True
33
+ elif route!='MATCHED' or c['result']['prediction_outcome']!='MATCHED' or canonical(c['predicted_state'])!=canonical(expected):status='ACTUAL_EVIDENCE_REPLAN_REQUIRED';terminal=True
34
+ elif position+1==len(choice['actions']):status='SUPPORTED_GOAL_ACTUALLY_VERIFIED' if choice['kind']=='SUPPORTED_GOAL' else 'SUPPORTED_PREFIX_ACTUALLY_VERIFIED';terminal=True
35
+ else:status='SUPPORTED_PREFIX_PROGRESS_VERIFIED'
36
+ steps.append({'position':position,'edge':choice['edges'][position],'selected_action':c['selected_action'],'projected_after':deepcopy(expected),'current_prediction':deepcopy(c['predicted_state']),'actual_state':deepcopy(actual),'route_outcome':route,'current_prediction_outcome':c['result']['prediction_outcome'],'actual_lineage_routes':_seed_routes(c['next_state'],budget),'transition':deepcopy(c)})
37
+ h=c['history'];anchor=h.get('acquired_group_indices',list(range(len(context[1]),len(context[1])+len(context[12]))))[context[14]];previous=(after,h['groups'],h['measurements'],after,h['groups'],h['measurements'],anchor)
38
+ if not same_state_context(current,previous,budget):raise ValueError('Original complete last actual successor required')
39
+ state=current_plan['state_certificate'];observed=state['result']['status']=='JOINT_STATE_READY' and all(state['state'][p]==v for p,v in goal.items());verified=terminal and status in ('GOAL_ALREADY_ACTUALLY_OBSERVED','SUPPORTED_GOAL_ACTUALLY_VERIFIED','SUPPORTED_PREFIX_ACTUALLY_VERIFIED')
40
+ result={'status':status,'consumed_steps':len(steps),'remaining_steps':len(choice['actions'])-len(steps),'terminal':terminal,'selected_supported_path_actually_verified':verified,'actual_goal_observed':bool(observed),'catalogue_current':current_plan['result']['catalogue_current']}
41
+ return {'policy':'actuation_sequence_feedback_v1','frontier':deepcopy(frontier),'selection_index':selection_index,'current_discovery':deepcopy(current_plan),'steps':steps,'result':result}
@@ -0,0 +1,43 @@
1
+ """Original choice, actual available-command records and coherent sequence outcome."""
2
+ from .actuation_goal_frontier_check import verify_actuation_goal_frontier
3
+ from .measured_actuation_transition_check import verify_measured_actuation_transition
4
+ from .observed_actuation_discovery_check import verify_observed_actuation_discovery
5
+ from .observed_actuation_runtime import raw
6
+ from .joint_goal_traversal_check import _initial_owners
7
+ from .frame_engine import canonical
8
+ from .role_work import RoleSearchBudget
9
+
10
+ def same_state_context(a,b,budget):
11
+ budget.consume()
12
+ return len(a)>=7 and len(b)>=7 and all(canonical(raw(a[i]))==canonical(raw(b[i])) for i in (0,3)) and canonical([a[1],a[2],a[4],a[5],a[6]])==canonical([b[1],b[2],b[4],b[5],b[6]])
13
+
14
+ def verify_actuation_sequence_feedback(origin,goal,frontier,selection_index,records,current,current_plan,certificate,*,max_depth=None,max_search_steps=None):
15
+ budget=RoleSearchBudget(max_search_steps)
16
+ with budget.scope():
17
+ try:
18
+ budget.consume()
19
+ if len(origin)!=9 or len(current)!=9 or not verify_actuation_goal_frontier(*origin,goal,frontier,max_depth=max_depth):raise ValueError('Original verified available-command frontier required')
20
+ if type(selection_index) is not int or not 0<=selection_index<len(frontier['choices']):raise ValueError('Original exact choice index required')
21
+ if not verify_observed_actuation_discovery(*current,current_plan):raise ValueError('Verified current actual state/capability plan required')
22
+ choice=frontier['choices'][selection_index];previous=origin;steps=[];status='SELECTED_SEQUENCE_PENDING';terminal=False
23
+ if not choice['actions']:status='GOAL_ALREADY_ACTUALLY_OBSERVED';terminal=True
24
+ for position,record in enumerate(records):
25
+ budget.consume()
26
+ if terminal or position>=len(choice['actions']) or type(record) is not dict or set(record)!={'context','after','certificate'}:raise ValueError('No extra, malformed or post-terminal record')
27
+ context=record['context'];after=record['after'];c=record['certificate']
28
+ if len(context)!=15 or not same_state_context(context,previous,budget) or not verify_measured_actuation_transition(*context,after,c) or not c['result']['experience_admitted']:raise ValueError('Complete linked actual transition required')
29
+ edge=frontier['edges'][choice['edges'][position]];before=frontier['nodes'][edge['source']]['state']
30
+ if canonical(context[9]['state_certificate']['state'])!=canonical(before) or c['selected_action']!=choice['actions'][position] or c['selected_action']!=edge['action']:raise ValueError('Original selected before state and command required')
31
+ expected=frontier['nodes'][edge['successor']]['state'] if edge['supported'] else None;actual=c['result']['actual_state'];route='UNRESOLVED' if expected is None else 'MATCHED' if actual==expected else 'CONTRADICTED'
32
+ if expected is None:status='FRONTIER_EXPERIENCE_ACTUALLY_VERIFIED';terminal=True
33
+ elif route!='MATCHED' or c['result']['prediction_outcome']!='MATCHED' or canonical(c['predicted_state'])!=canonical(expected):status='ACTUAL_EVIDENCE_REPLAN_REQUIRED';terminal=True
34
+ elif position+1==len(choice['actions']):status='SUPPORTED_GOAL_ACTUALLY_VERIFIED' if choice['kind']=='SUPPORTED_GOAL' else 'SUPPORTED_PREFIX_ACTUALLY_VERIFIED';terminal=True
35
+ else:status='SUPPORTED_PREFIX_PROGRESS_VERIFIED'
36
+ steps.append({'position':position,'edge':choice['edges'][position],'selected_action':c['selected_action'],'projected_after':expected,'current_prediction':c['predicted_state'],'actual_state':actual,'route_outcome':route,'current_prediction_outcome':c['result']['prediction_outcome'],'actual_lineage_routes':_initial_owners(c['next_state'],budget),'transition':c})
37
+ h=c['history'];anchor=h.get('acquired_group_indices',list(range(len(context[1]),len(context[1])+len(context[12]))))[context[14]];previous=(after,h['groups'],h['measurements'],after,h['groups'],h['measurements'],anchor)
38
+ if not same_state_context(current,previous,budget):raise ValueError('Original complete last actual successor required')
39
+ state=current_plan['state_certificate'];observed=state['result']['status']=='JOINT_STATE_READY' and all(state['state'][p]==v for p,v in goal.items());verified=terminal and status in ('GOAL_ALREADY_ACTUALLY_OBSERVED','SUPPORTED_GOAL_ACTUALLY_VERIFIED','SUPPORTED_PREFIX_ACTUALLY_VERIFIED')
40
+ result={'status':status,'consumed_steps':len(steps),'remaining_steps':len(choice['actions'])-len(steps),'terminal':terminal,'selected_supported_path_actually_verified':verified,'actual_goal_observed':bool(observed),'catalogue_current':current_plan['result']['catalogue_current']}
41
+ expected_certificate={'policy':'actuation_sequence_feedback_v1','frontier':frontier,'selection_index':selection_index,'current_discovery':current_plan,'steps':steps,'result':result}
42
+ return canonical(certificate)==canonical(expected_certificate)
43
+ except (ValueError,TypeError,KeyError,IndexError,AttributeError):return False
tgi/ask_certificate.py ADDED
@@ -0,0 +1,74 @@
1
+ """Complete prefix-scope certificate for raw stored-context search."""
2
+ from .identity import encode,decode
3
+ from .frame_engine import canonical
4
+ from .organization_snapshot import snapshot
5
+ from .organization_check import verify_resolution,verify_refusal,_verify_refusal_view
6
+
7
+
8
+ def certify_ask(engine, raw):
9
+ encode(raw)
10
+ if not raw:raise ValueError('Empty query')
11
+ view=snapshot(engine)
12
+ lengths={len(h.pattern)-2 for h in view.organizations.values()}
13
+ lengths.update(len(h.pattern)-2 for h,_ in view.rejected_organizations.values())
14
+ prefixes={():[]} if 0 in lengths else {}
15
+ for sid,(frames,_) in view.episodes.items():
16
+ for count in lengths:
17
+ if 0<count<=len(frames):prefixes.setdefault(tuple(decode(f) for f in frames[:count]),[]).append(sid)
18
+ rows=[];outputs=set();uncertain=False;broken=False
19
+ for prefix,sources in sorted(prefixes.items()):
20
+ r=view.resolve(prefix+(raw,))
21
+ if r['status']!='NO_PATH':
22
+ live=[sid for sid in sources if view._alive(sid)]
23
+ if sources and not live:broken=True
24
+ else:
25
+ broken |= r['status']=='INCOMPLETE'
26
+ uncertain |= r['status']=='AMBIGUOUS'
27
+ if r['status']=='RESOLVED':outputs.add(tuple(r['output']))
28
+ if r['status']=='RESOLVED':r={k:r[k] for k in ('status','output','proofs')}
29
+ rows.append({'prefix':list(prefix),'sources':sorted(sources),'resolution':r})
30
+ status='INCOMPLETE' if broken else 'CONFLICT' if len(outputs)>1 else 'AMBIGUOUS' if uncertain else 'RESOLVED' if outputs else 'NO_PATH'
31
+ result={'status':status,'output':list(next(iter(outputs))) if status=='RESOLVED' else [],'candidates':[list(x) for x in sorted(outputs)]}
32
+ return {'query':raw,'result':result,'search':rows}
33
+
34
+
35
+ def _verify_ask_certificate_view(engine, certificate):
36
+ from .organization_snapshot import _Snapshot
37
+ try:
38
+ if type(engine) is not _Snapshot or engine._dirty or set(certificate)!={'query','result','search'}:return False
39
+ raw=certificate['query'];encode(raw)
40
+ if not raw:return False
41
+ sizes=set()
42
+ for h in engine.organizations.values():sizes.add(len(h.pattern)-2)
43
+ for h,_ in engine.rejected_organizations.values():sizes.add(len(h.pattern)-2)
44
+ scope={():set()} if 0 in sizes else {}
45
+ for sid,(frames,_) in engine.episodes.items():
46
+ for n in sizes:
47
+ if 0<n<=len(frames):scope.setdefault(tuple(decode(f) for f in frames[:n]),set()).add(sid)
48
+ rows=certificate['search']
49
+ if len(rows)!=len(scope):return False
50
+ outputs=set();uncertain=False
51
+ for row,(prefix,sources) in zip(rows,sorted(scope.items())):
52
+ if set(row)!={'prefix','sources','resolution'}:return False
53
+ if canonical(row['prefix'])!=canonical(list(prefix)) or canonical(row['sources'])!=canonical(sorted(sources)):return False
54
+ if not all(engine._alive(sid) for sid in sources):return False
55
+ r=row['resolution'];status=r['status'];trigger=list(prefix)+[raw]
56
+ if status=='RESOLVED':
57
+ if set(r)!={'status','output','proofs'} or not verify_resolution(engine,trigger,r):return False
58
+ outputs.add(tuple(r['output']))
59
+ elif status in ('NO_PATH','AMBIGUOUS'):
60
+ if not _verify_refusal_view(engine,trigger,r):return False
61
+ uncertain |= status=='AMBIGUOUS'
62
+ else:return False
63
+ status='CONFLICT' if len(outputs)>1 else 'AMBIGUOUS' if uncertain else 'RESOLVED' if outputs else 'NO_PATH'
64
+ expected={'status':status,'output':list(next(iter(outputs))) if status=='RESOLVED' else [],'candidates':[list(x) for x in sorted(outputs)]}
65
+ return canonical(certificate['result'])==canonical(expected)
66
+ except (KeyError,IndexError,TypeError,ValueError,AttributeError):return False
67
+
68
+
69
+ def verify_ask_certificate(engine, certificate):
70
+ """Fresh public evidence boundary; never reuse a caller's cached admission."""
71
+ try:
72
+ return _verify_ask_certificate_view(snapshot(engine), certificate)
73
+ except (KeyError, IndexError, TypeError, ValueError, AttributeError):
74
+ return False
tgi/bands.py ADDED
@@ -0,0 +1,59 @@
1
+ """8 C + 8 L disjoint ownership of character-clock constraint blocks.
2
+
3
+ This is the declared TGI candidate, not a copy of the VEYRA MULTIPITA cell.
4
+ """
5
+ from dataclasses import dataclass
6
+ from .exact_field import Field
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class Block:
11
+ start: int
12
+ stop: int
13
+ field: Field
14
+
15
+
16
+ class Bands:
17
+ def __init__(self):
18
+ self.clock = 0
19
+ self._banks = [None]*16
20
+ self.merges = [0]*16
21
+
22
+ def tick(self, field=Field()):
23
+ carry = Block(self.clock,self.clock+1,field)
24
+ self.clock += 1
25
+ for index in range(16):
26
+ old = self._banks[index]
27
+ if old is None:
28
+ self._banks[index] = carry
29
+ return
30
+ if old.stop != carry.start:
31
+ raise RuntimeError("Noncontiguous band ownership")
32
+ carry = Block(old.start,carry.stop,old.field.merge(carry.field))
33
+ self.merges[index] += 1
34
+ if index == 15:
35
+ self._banks[index] = carry
36
+ return
37
+ self._banks[index] = None
38
+
39
+ def feed(self, identities, final_field):
40
+ if not identities:
41
+ raise ValueError("A measurement frame must have character events")
42
+ for i in range(len(identities)):
43
+ self.tick(final_field if i == len(identities)-1 else Field())
44
+
45
+ def field(self, excluded=()):
46
+ result = Field()
47
+ for i,block in enumerate(self._banks):
48
+ if block is not None and i not in excluded:
49
+ result = result.merge(block.field)
50
+ return result
51
+
52
+ def blocks(self):
53
+ return tuple((i,block) for i,block in enumerate(self._banks) if block is not None)
54
+
55
+ def inspect(self):
56
+ return [{"owner":("C"+str(i)) if i<8 else ("L"+str(i-8)),
57
+ "index":i,"start":b.start,"stop":b.stop,
58
+ "rows":len(b.field.rows),"omega":b.field.omega,"phase":b.field.phase}
59
+ for i,b in self.blocks()]
tgi/capacity_graph.py ADDED
@@ -0,0 +1,70 @@
1
+ """Neutral matching/cover bounds; no semantic pairing selection."""
2
+ from tgi.role_work import RoleSearchBudget
3
+
4
+ def certify_capacity_graph(left,right,edges,*,max_search_steps=None):
5
+ budget=RoleSearchBudget(max_search_steps)
6
+ with budget.scope():
7
+ left=sorted(left);right=sorted(right);l=set(left);r=set(right)
8
+ if len(left)!=len(l) or len(right)!=len(r):raise ValueError('Duplicate vertex')
9
+ adjacent={a:set() for a in left}
10
+ for pair in edges:
11
+ budget.consume()
12
+ if len(pair)!=2 or pair[0] not in l or pair[1] not in r:raise ValueError('Invalid edge')
13
+ adjacent[pair[0]].add(pair[1])
14
+ adjacent={a:sorted(bs) for a,bs in adjacent.items()};mate={};matched={}
15
+ for root in left:
16
+ budget.consume();stack=[(root,iter(adjacent[root]))];seen=set();parent={};free=None
17
+ while stack and free is None:
18
+ budget.consume();a,it=stack[-1]
19
+ try:b=next(it)
20
+ except StopIteration:stack.pop();continue
21
+ if b in seen:continue
22
+ seen.add(b);parent[b]=a
23
+ if b not in mate:free=b;break
24
+ child=mate[b];stack.append((child,iter(adjacent[child])))
25
+ while free is not None:
26
+ budget.consume();a=parent[free];previous=matched.get(a);matched[a]=free;mate[free]=a;free=previous
27
+ zl=l-set(matched);zr=set();pending=list(zl)
28
+ while pending:
29
+ budget.consume();a=pending.pop()
30
+ for b in adjacent[a]:
31
+ budget.consume()
32
+ if matched.get(a)==b or b in zr:continue
33
+ zr.add(b)
34
+ if b in mate and mate[b] not in zl:zl.add(mate[b]);pending.append(mate[b])
35
+ return dict(capacity=len(mate),matching=[list(p) for p in sorted(matched.items())],cover_left=sorted(l-zl),cover_right=sorted(zr))
36
+
37
+
38
+ def verify_capacity_graph(left,right,edges,c,*,max_search_steps=None):
39
+ budget=RoleSearchBudget(max_search_steps)
40
+ with budget.scope():
41
+ try:
42
+ if not isinstance(c,dict) or set(c)!={'capacity','matching','cover_left','cover_right'} or type(c['capacity']) is not int:return False
43
+ l=set(left);r=set(right)
44
+ if len(l)!=len(left) or len(r)!=len(right):return False
45
+ e=set()
46
+ for pair in edges:
47
+ budget.consume()
48
+ if len(pair)!=2 or pair[0] not in l or pair[1] not in r:return False
49
+ e.add(tuple(pair))
50
+ seen_left=set();seen_right=set()
51
+ for pair in c['matching']:
52
+ budget.consume()
53
+ if len(pair)!=2 or tuple(pair) not in e:return False
54
+ a,b=pair
55
+ if a in seen_left or b in seen_right:return False
56
+ seen_left.add(a);seen_right.add(b)
57
+ cover=[]
58
+ for vertices,allowed in ((c['cover_left'],l),(c['cover_right'],r)):
59
+ values=set()
60
+ for v in vertices:
61
+ budget.consume()
62
+ if v not in allowed or v in values:return False
63
+ values.add(v)
64
+ cover.append(values)
65
+ if len(c['matching'])!=c['capacity'] or c['capacity']!=sum(map(len,cover)):return False
66
+ for a,b in e:
67
+ budget.consume()
68
+ if a not in cover[0] and b not in cover[1]:return False
69
+ return True
70
+ except (ValueError,TypeError,KeyError,IndexError):return False
@@ -0,0 +1,13 @@
1
+ """Quantified closure determines full-route depth; actual experience stays native."""
2
+ from copy import deepcopy
3
+ from .structural_append_closure import certify_structural_append_closure
4
+ from .actuation_goal_frontier import certify_actuation_goal_frontier
5
+ from .role_work import RoleSearchBudget
6
+
7
+ def certify_closed_actuation_goal_frontier(*args,goal,max_depth=None,max_search_steps=None):
8
+ b=RoleSearchBudget(max_search_steps)
9
+ with b.scope():
10
+ b.consume()
11
+ if max_depth is not None and (type(max_depth) is not int or max_depth<0):raise ValueError('Original declared depth required')
12
+ closure=certify_structural_append_closure(*args,goal=goal);r=closure['result'];distance=r['shortest_supported_goal_length'];effective=max_depth if max_depth is not None else distance if distance is not None else 1;origin='DECLARED_SEARCH_DEPTH' if max_depth is not None else 'QUANTIFIED_SHORTEST_GOAL_BOUND' if distance is not None else 'ACTUAL_EXPERIENCE_LAYER_AFTER_CLOSURE';frontier=certify_actuation_goal_frontier(*args,goal,max_depth=effective);status=frontier['result']['status'] if frontier['result']['status'] in ('GOAL_ALREADY_OBSERVED','SUPPORTED_GOAL_READY') else r['status'] if distance is None else frontier['result']['status']
13
+ return {'policy':'closed_actuation_goal_frontier_v1','goal':deepcopy(goal),'max_depth':max_depth,'effective_depth':effective,'depth_origin':origin,'closure':closure,'frontier':frontier,'discovery':deepcopy(frontier['discovery']),'choices':deepcopy(frontier['choices']),'result':{'status':status,'closure_status':r['status'],'native_frontier_status':frontier['result']['status'],'choice_count':len(frontier['choices']),'quantified_append_system_complete':r['quantified_append_system_complete']}}
@@ -0,0 +1,19 @@
1
+ """Independent binding of quantified closure, route depth and actual frontier."""
2
+ from .structural_append_closure_check import verify_structural_append_closure
3
+ from .actuation_goal_frontier_check import verify_actuation_goal_frontier
4
+ from .frame_engine import canonical
5
+ from .role_work import RoleSearchBudget
6
+
7
+ def verify_closed_actuation_goal_frontier(*args,goal,certificate,max_depth=None,max_search_steps=None):
8
+ b=RoleSearchBudget(max_search_steps)
9
+ with b.scope():
10
+ try:
11
+ b.consume();c=certificate
12
+ if type(c) is not dict or set(c)!={'policy','goal','max_depth','effective_depth','depth_origin','closure','frontier','discovery','choices','result'} or c['policy']!='closed_actuation_goal_frontier_v1' or canonical(c['goal'])!=canonical(goal) or type(max_depth) is bool or (max_depth is not None and (type(max_depth) is not int or max_depth<0)) or type(c['max_depth']) is not type(max_depth) or c['max_depth']!=max_depth:return False
13
+ if not verify_structural_append_closure(*args,goal=goal,certificate=c['closure']):return False
14
+ r=c['closure']['result'];distance=r['shortest_supported_goal_length'];effective=max_depth if max_depth is not None else distance if distance is not None else 1;origin='DECLARED_SEARCH_DEPTH' if max_depth is not None else 'QUANTIFIED_SHORTEST_GOAL_BOUND' if distance is not None else 'ACTUAL_EXPERIENCE_LAYER_AFTER_CLOSURE'
15
+ if type(c['effective_depth']) is not int or c['effective_depth']!=effective or c['depth_origin']!=origin or not verify_actuation_goal_frontier(*args,goal,c['frontier'],max_depth=effective):return False
16
+ if canonical(c['discovery'])!=canonical(c['frontier']['discovery']) or canonical(c['closure']['discovery'])!=canonical(c['discovery']) or canonical(c['choices'])!=canonical(c['frontier']['choices']):return False
17
+ status=c['frontier']['result']['status'] if c['frontier']['result']['status'] in ('GOAL_ALREADY_OBSERVED','SUPPORTED_GOAL_READY') else r['status'] if distance is None else c['frontier']['result']['status']
18
+ return canonical(c['result'])==canonical({'status':status,'closure_status':r['status'],'native_frontier_status':c['frontier']['result']['status'],'choice_count':len(c['frontier']['choices']),'quantified_append_system_complete':r['quantified_append_system_complete']})
19
+ except (ValueError,TypeError,IndexError,KeyError,AttributeError):return False