"""Derive a descriptive report, never pick a model winner from activity reduction.""" import json import pandas as pd def write_report(exp): synthetic = pd.read_csv(exp/'synthetic/results.csv') motifs = pd.read_csv(exp/'motifs/summary.csv') one = synthetic[synthetic['case'].str.startswith('one_impulse')] combined = one.pivot(index='case',columns='policy',values='spikes') lines = [ '# Phase 4AC — LIF semantics and unchanged-dynamics motif audit', '', 'Status: COMPLETE-SEMANTICS-AUDIT / LEARNING-NOT-ACHIEVED.', 'No alternative dynamics deployed to MaleCNS; no conditioning, learned candidate or new formal runtime.', '', '## Author model versus frozen adapted model', '', 'Pinned author model resets g on a spike and declares v/g `(unless refractory)`, uses linear integration, strict > threshold and voltage Poisson input with zero refractory on stimulated cells.', 'The frozen adapted model retains g, decays/accepts events during refractory, uses explicit Euler and >= threshold, and forced sensory spikes respect refractory.', 'These are documented model choices, not a newly established GPU regression. g is an additive voltage-valued drive, not a measured conductance.', 'W_syn=0.275 is transferred from a free parameter calibrated in the original FlyWire feeding model, not a measured universal MaleCNS synaptic efficacy.', '', '## Synthetic single-cell component tests', '', 'All impulse amplitudes derive from the complete unique contact counts of the predeclared 13 real motif edges plus a one-contact fixture; other boundary/sustained cases are explicitly synthetic unit tests.', 'These ablations retain frozen Euler arithmetic/scheduling and are NOT complete Brian2 replication. No successful amplitude or policy was selected after seeing results.', '', '| Single-impulse fixture | Frozen | Reset g only | Refractory gate only | Reset + gate |', '|---|---:|---:|---:|---:|'] for name,row in combined.iterrows(): lines.append(f"| {name} | {int(row.frozen)} | {int(row.reset_g_only)} | {int(row.refractory_gate_only)} | {int(row.reset_and_refractory)} |") lines += ['', 'Reset-only and combined policies can produce at most one spike from a single isolated input by construction. This does not establish biological correctness or whole-brain learning improvement.', '', '## Real anatomical motifs — frozen mathematics ONLY', '', 'One forced seed spike at step 0 except the no-input control; no subsequent input; observed for 1 s. Late window=500–1,000 ms.', 'The recurrent pair/trio/five are induced subgraphs. The feedforward control selects four existing edges and removes feedback only within this isolated diagnostic harness.', 'External inhibition, graded APL and other whole-brain inputs are absent. A sustained isolated motif is evidence of sufficiency in this harness, NOT necessity in the complete brain.', '', '| Motif | neuron_idx | Total spikes | Late spikes | Last ms |', '|---|---:|---:|---:|---:|'] for r in motifs.itertuples(): lines.append(f'| {r.motif} | {r.neuron_idx} | {r.spikes} | {r.late_spikes} | {r.last_ms if pd.notna(r.last_ms) else "none"} |') perf=json.loads((exp/'performance/summary.json').read_text()) lines += ['', '## Verification and boundaries', '', 'Seven unit tests; all five real motifs CPU/GPU event, count, final V/g/refractory, queue and timestep history exact; five archived deterministic-v2 full-brain trials exact.', 'Every selected edge_id, source CSR row, destination and original weight validated; generated prepared inputs hashed. All original snapshot files and Phase 4AA/4AB model/experiment manifests checked before and after.', f"Diagnostic wall time including compilation and observation: {perf['wall_seconds']:.3f} s. Peak allocated process VRAM: {perf['peak_allocated_VRAM']} bytes. Not a runtime-speed benchmark.", 'Original author code was inspected, not executed; no Brian2 oracle run and no new package installation. ComfyUI was not stopped or unloaded.', '', '## Decision', '', 'The usable-learning gate remains unmet: independent evaluation, A-vs-neutral-B specificity in MBON/downstream, multiple training seeds and conditioning controls still required.', 'Before any full-network alternative, obtain explicit separate model authorization and distinguish each semantic component; do not claim g reset alone reproduces the author implementation.', 'No evidence here permits changing eta, thresholds, gain, frozen APL calibration, transmitter signs or the plastic mask.', '', '## Primary provenance', '', '[Shiu et al. 2024](https://www.nature.com/articles/s41586-024-07763-9)', '[Pinned author implementation](https://github.com/philshiu/Drosophila_brain_model/blob/91bdd1e7dcf193f3e7ca5a8933497fcef63b7960/model.py)', 'Downloaded source, MIT license, environment specification, exact commit, SHA-256 and source clauses retained under external-resources and audit.', ''] with (exp/'REPORT.md').open('x',encoding='utf-8') as f: f.write('\n'.join(lines))