#!/usr/bin/env python3 """Push what the mind already holds into an agent's context. Usage: recall.py prompt (a UserPromptSubmit command hook; the hook JSON is on stdin) recall.py admit (a PreToolUse command hook on mcp__eureka-state__admit) recall.py dispatch (a PreToolUse command hook on Agent|Task) Queries the rulings, questions and follow-ups in force, across every root, ranked by Huginn's embeddings against the prompt, and prints one hook JSON whose additionalContext lists the nearest. Huginn's ranking is the only judge of relevance. It never blocks a prompt: every failure, the deadline included, exits 0 with empty stdout. One attempt, no retry. Standard library only. Env: RECALL_TOP_K (5), RECALL_BUDGET characters (4000, at most 9000), RECALL_DEADLINE_MS (4000; set the hook's own timeout above it). The deadline bounds the whole run: stdin, the reply, parsing, the kill and the write; stdin is read to at most 4 MiB, the answer to 1 MiB. On Windows the clock starts at process creation, so interpreter start-up and imports (about 200 ms) count against the deadline. What stays outside it: the `py` launcher that starts the interpreter (40 to 130 ms measured) and the creation call itself, which this script cannot see; elsewhere the clock starts after the imports (interpreter start about 20 ms). admit holds an admit batch once. For each ruling or question in it (at most RECALL_ADMIT_MAX, 3) it queries the in-force rulings and questions nearest the title; excluded are the document itself, every ruling or question in the batch, the question a ruling answers and the subjects of Superseded resolutions in the batch. A batch with a neighbour left is denied, the neighbours as the reason, and its digest (tool_input plus agent_id) is recorded in the session scratchpad; the identical call sent again passes untouched. It never decides allow or ask. Any failure to check exits 0 with a note naming only the failure kind. Env defaults in this mode: RECALL_TOP_K 3, RECALL_DEADLINE_MS 10000. dispatch appends recall to an Agent or Task brief. It collects the ruling, question and follow_up ids the prompt cites (::