needle / scripts /audit_native_schema_clock.py
Leon4gr45's picture
Upload folder using huggingface_hub (part 2)
25a2c1c verified
Raw History Blame Contribute Delete
1.72 kB
"""Development-only matched-date replay of the captured MCP schema failure."""
import datetime,json,time
from pathlib import Path
import needle
from context_adapter import DecisionContext
from decision_policy import validate_decision
from native_schema import inference_tools
def main():
record=json.loads(Path('benchmarks/workflow/results/mcp-failure-native.json').read_text())['records'][2]
captured=record['native'][0]
minute=datetime.datetime.fromtimestamp(record['response']['created'],datetime.timezone.utc).strftime('date: %Y-%m-%d %a %H:%M')
system=minute+'; '+captured['system'];rows=[]
for projected in (False,True):
tools=inference_tools(captured['candidates']) if projected else captured['candidates']
agent=needle.Needle(tools=tools,system=system,generation=3)
start=time.perf_counter();native=agent.complete(captured['query'])
rows.append({'titles_removed':projected,'tools':tools,'system':system,'query':captured['query'],'latency_ms':(time.perf_counter()-start)*1000,'native':native,'validated':validate_decision(native,captured['candidates'],DecisionContext(**record['request']['decision_context']),system+'\n'+captured['query'])})
Path('benchmarks/workflow/results/native-schema-controlled-audit.json').write_text(json.dumps({'methodology':'Development causal probe, no tool execution. Both fresh calls use the same explicit date fact at the response minute of the captured failure; no SDK clock/source/weights/flags/threshold changes. Original internal constructor timestamp was not separately captured, so this is a matched replay, not a claim about hidden historical bytes.','rows':rows},indent=2)+'\n')
if __name__=='__main__':main()