# Tier 2 harness fix, 27 Oct 2026 (before the freeze)

## What failed

The first server tier 2 check ran at 14:37 UTC on 27 Oct, right after unattended run 001 ended and freed the server. Its receipt and log are kept: `receipt-20261027T143746Z.json` and `tier2-20261027T143746Z.log`.

- **Passed:** the model constants and the run workflow order.
- **Failed:** all four stimulus checks (`v2_v3_frames`, `generate_stimuli`, `pilot_bounds`, `plaid_fit`), each with the same error. Mozaik's `MozaikParametrized.__init__` calls `inspect.getmodule(self).__name__`, which raised `AttributeError: 'NoneType' object has no attribute '__name__'`.

## Cause

The bug is in the check script, not in the stimulus code or the design.

`server/tier2_imagen_check.py` loads the two stimulus modules (version 2 as `ce_v2`, version 3 as `ce_v3`) from their file paths with `importlib.util.spec_from_file_location` and `exec_module`. It never registered them in `sys.modules`. `inspect.getmodule` finds a class's module only through `sys.modules`, so every stimulus built from a loaded module failed.

The real runs import `controller_experiments` normally, so they would not have hit this. But tier 2 exists to test the stimulus code before the freeze, and it could not run.

## Fix

- `load()` now registers the module in `sys.modules` before running it, the standard importlib recipe. Nothing else in the script changed.
  - Before: SHA-256 `5791f564572781a3306e362f912d9217f71ef3fd3c25c06d497bd8ce738f3e38`. That version is kept here as `tier2_imagen_check-v1-failed-20261027.py`.
  - After: SHA-256 `1f5528f79244ae22e924902fdc7d745dc4748f9395e6e85e0cb23238ff756ee8`.
- **Unchanged:** the declared spec (`8f8878fc…`), `contract-r2.json`, the sequence, the stimulus code, the analysis and the queue.
- **Why this is allowed:** the launcher's `tier2` mode uploads the local working files and is meant to be run, and if needed rerun, before the freeze. The freeze manifest will record the fixed script.

## A stale test, also fixed

`test_freeze_022r2.py` errored in `setUpClass`. Its mirror "declared" the spec by replacing the placeholder "(not declared yet)", but the real spec has been declared since 26 Oct 23:15:38 UTC, so the placeholder no longer exists.

- `declare()` now leaves an already declared spec alone.
- A new `undeclare()` gives the refusal test an undeclared spec from either form: it reverts the test marker, or turns "Status: DECLARED" into "Status: (not declared yet)".
- No assertion changed. The freeze still has to refuse an undeclared spec, and the test checks that it does.

## Results

- `python3 -B -m unittest` over the seven plaids test modules: 173 tests OK, 2 skipped (as before).
- `test_queue_guard.sh`: 168 passed, 0 failed.
- **Tier 2 rerun:** the first attempt, at 17:55 to 18:16 UTC, never reached the check. The research server's SSH went silent after a local network outage had dropped the shared connection, and the per-file uploads then opened new connections.
  - At 18:22 UTC, with SSH back and the shared connection up, the launcher ran again: guard passed, all 34 server files matched.
  - **Tier 2 PASS:** all six checks pass (`model_constants`, `v2_v3_frames`, `generate_stimuli`, `pilot_bounds`, `plaid_fit`, `run_workflow_order`); 68.6 s; peak 116 MB; launcher exit 0. Receipt: `receipt-20261027T182426Z.json` (SHA-256 `6ed21ebd154e9315…`).
