2222from agent_session_tools .eval .arms import _frozen_escape_fts_query , build_arm
2323from agent_session_tools .eval .census import collect_questions
2424from agent_session_tools .eval .seam import ArmError , Query
25- from agent_session_tools .retrieval import plan_query
2625
2726ROOT = Path (__file__ ).resolve ().parents [2 ]
2827RECEIPTS = ROOT / "docs/architecture/session-memory/receipts/semantic-layer"
2928DB = Path .home () / ".config/studyloop/sessions.db"
3029GOLDEN = "packages/agent-session-tools/tests/golden/session_search_pre_planner.json"
30+ CLASS_CODES = {
31+ "identical" : "I" ,
32+ "frozen_crash" : "C" ,
33+ "frozen_empty_live_rows" : "E" ,
34+ "different_lists" : "D" ,
35+ }
3136
3237
3338def sessions (arm , question ) -> list [str ] | str :
@@ -70,6 +75,8 @@ def census_transitions() -> dict:
7075 mechanism ["whole_question_as_one_phrase" if whole_text_phrase else "other" ] += 1
7176 classes [cls ] += 1
7277 transitions [(cls , f_hit , m_hit )] += 1
78+ # Compact row: the MATCH strings are reproducible from the text and
79+ # would put the receipt over the repo's large-file limit.
7380 rows .append (
7481 {
7582 "message_id" : q .message_id ,
@@ -78,8 +85,7 @@ def census_transitions() -> dict:
7885 "class" : cls ,
7986 "frozen_hit" : f_hit ,
8087 "live_hit" : m_hit ,
81- "frozen_match" : escaped if cls != "frozen_crash" else None ,
82- "live_plan" : plan_query (q .text ).queries [:1 ],
88+ "whole" : bool (whole_text_phrase and cls != "frozen_crash" ),
8389 }
8490 )
8591 elapsed = time .perf_counter () - t0
@@ -98,7 +104,29 @@ def census_transitions() -> dict:
98104 "frozen" : round (sum (r ["frozen_hit" ] for r in rows ) / len (rows ), 4 ),
99105 "live" : round (sum (r ["live_hit" ] for r in rows ) / len (rows ), 4 ),
100106 },
101- "per_question" : rows ,
107+ "per_question_columns" : [
108+ "message_id" ,
109+ "source" ,
110+ "class_code" ,
111+ "frozen_hit" ,
112+ "live_hit" ,
113+ "frozen_whole_question_phrase" ,
114+ ],
115+ "class_codes" : CLASS_CODES ,
116+ # The session id is derivable from the message id; the MATCH strings
117+ # are reproducible from the text. Both are dropped to keep the receipt
118+ # under the repository's 500 KB large-file limit.
119+ "per_question" : [
120+ [
121+ r ["message_id" ],
122+ r ["source" ],
123+ CLASS_CODES [r ["class" ]],
124+ int (r ["frozen_hit" ]),
125+ int (r ["live_hit" ]),
126+ int (r ["whole" ]),
127+ ]
128+ for r in rows
129+ ],
102130 }
103131
104132
@@ -156,7 +184,7 @@ def main() -> None:
156184 "census" : census_transitions (),
157185 }
158186 target = RECEIPTS / "stage2-census-transitions.json"
159- target .write_text (json .dumps (out , indent = 1 , sort_keys = True ) + "\n " )
187+ target .write_text (json .dumps (out , sort_keys = True , separators = ( "," , ":" ) ) + "\n " )
160188 summary = {k : v for k , v in out ["census" ].items () if k != "per_question" }
161189 print (
162190 json .dumps (
0 commit comments