# Controlled interventions A controlled intervention tests whether one ready target-dossier estimate changes a scored behavior when it is temporarily edited, compared with an equally sized edit in a random direction. It is the only route by which a dossier reaches the `controlled intervention result` evidence label. Runtime activation changes are transient, but they still count as interventions: every hook is owned by a context manager and the model is checked for restoration after every arm. ```bash obliteratus experiments intervene run spec.json --run ./observations/ obliteratus experiments intervene attach ./observations//interventions//attempts/0001/result.json \ --dossier ./observations//dossiers/alpha.json obliteratus experiments dossier show ./observations//dossiers/alpha.json ``` ```python from obliteratus.experiments.intervention_runner import run_intervention from obliteratus.analysis.dossier_interventions import attach_result result = run_intervention(spec, run_dir) attach_result(dossier_path, result["location"]["result"]) ``` ## Experiment spec A separate versioned spec (`obliteratus/concepts/schema/intervention-spec.v1.schema.json`) leaves baseline observation specs and their digests unchanged. Its canonical digest is the experiment identity; results are stored beside the dossier's run as `/interventions//attempts/NNNN/` with the observation store's attempt lifecycle (`pending`, `running`, `complete`, `failed`, `cancelled`). * `kind`: `controlled_intervention` or `activation_patching`. * `dossier` (relative to the run) and `estimate`: one ready estimate of a current dossier (see "Estimate types" below): a `channel`, a fixed pack-basis `residual_direction` or a `subspace`. Refitted difference-of-means directions are refused with a reason. * `direction_artifact` (optional `{path, sha256}`, path relative to the run): relocates the extracted `direction.safetensors` that the estimate's source report recorded; `sha256` must equal the report's recorded `file_sha256`. Without it the report's recorded path is used. Refused for channels. * `model`: id, dtype, device and `model_class` (`pretrained` or `fixture`). * `dataset` and `tasks`: evaluation rows (`select`, `calibrate` or acknowledged `test`) scored with registered task scorers, as in observation specs. * `target_task`: the task whose success rate is the declared endpoint; every other task is a collateral endpoint (at least one is required). * `operation`: `kind` (`steer` or `ablate`), `site` (must equal the estimate site), `token_scope` (`all_tokens` or `last_token`), `units` and the dose ladder `coefficients`. The `decision_coefficient` and the spec's `target_task` must equal the values pre-registered in the dossier hypothesis, so the deciding comparison cannot be chosen after reading the ladder. `steer` adds `c * unit(v)` (`raw`) or `c * ||x|| * unit(v)` (`residual_norm`) to the decoder layer output; `ablate` removes `c * (x . unit(v)) * unit(v)` (`projection_fraction`, `0 <= c <= 1`); on a rank-k span it removes `c` of the projection onto the whole span. Token scope applies to every forward pass, including each decoding step. * `operation.steer_direction` (subspace estimates, `steer` only): `{"source": "direction"}` (the artifact's rank-1 direction at the layer) or `{"source": "basis_row", "index": i}`; it must lie in the span. * `control.seed`: seed of the random control direction. ## Estimate types | Estimate | Intervened tensor | `steer` | `ablate` | | --- | --- | --- | --- | | `channel` | standard-basis vector of the channel | yes | yes | | `residual_direction`, source `pack_direction` | row `index` of the artifact's stored basis at the site's layer (fixed vector) | yes | yes | | `residual_direction`, source `difference_of_means_refit` | refused: refitted in every fold and on all discovery rows, so no stored vector is the estimate | | | | `subspace` (rank k) | the artifact's full rank-k basis, rows orthonormalized by QR | rank 1, or one declared direction in the span | projects out the whole span | Direction and subspace estimates intervene on exactly the bytes their evidence was computed on. Candidate-discovery reports (`pack_direction.artifact`) and labeled-subspace reports (`basis.artifact`) record the artifact's binding when discovery or the subspace report ran with `--direction`: `{path, file_sha256, tensor_sha256, metadata_sha256}` (SHA-256 of the `.safetensors` bytes, the tensor digest its sidecar records, and SHA-256 of the sidecar bytes). A report written before this binding existed is refused ("report predates artifact digests; rerun discovery/subspace with `--direction`"). Before any forward pass the artifact's bytes, its sidecar's tensor digest and the sidecar bytes must match the report's binding, so an artifact with the same metadata but other vectors (or the same vectors with other metadata) is refused. Its identity must match what the estimate's source report recorded: concept id, layer and basis rank for a pack-basis row (the discovery report's `pack_direction`); concept id and version, model id, rank and pack-provenance digest for a subspace (the subspace report's `basis`). The artifact's model id and dtype must match the dossier's model. Its width must equal the model's hidden size, the vector must be finite and nonzero, basis rows must be linearly independent (singular-value ratio above `1e-6`), and a declared steering direction must lie in the span (unit-vector residual at most `1e-4`). Evaluation rows must also differ in role or revision from the artifact's dataset access receipt (the rows it was fitted on). Estimate-scope activation patching needs rank 1; patch a rank-k span with scope `site`. The result records the artifact path, its digests, the report's recorded binding and the artifact identity under `target`. ## Arms On the same evaluation examples, in this order: 1. unchanged baseline; 2. for each coefficient, the intended operation on the estimate, then 3. the same operation along a random control direction; 4. a fresh-baseline replay, which must reproduce the baseline completions exactly. Each arm records its order, the hook site (site name and module path), hook type, operation, token scope, units, coefficient, vector or basis digest, rank, orthogonalization details and ordering. Every non-baseline arm has a paired scorecard against the baseline (task success, invalid output, abstention) using the dossier's pre-declared collateral margin. Coefficients other than the decision coefficient are descriptive and never used for the verdict. The random control is rank- and norm-matched. For a rank-1 target (channel, fixed direction or rank-1 subspace) it is a seeded standard-normal draw projected onto the orthogonal complement of the intended direction and scaled to the intended direction's norm. For a declared steering direction inside a rank-k span it is a rank-1 seeded draw projected onto the orthogonal complement of the whole estimate span (not only the steered vector) and scaled to the steered vector's norm; its cosine with every span row is recorded (`span_row_cosines`). For a rank-k span it is a seeded float64 draw of k columns projected onto the orthogonal complement of the target span, QR-orthonormalized and scaled row by row to the target rows' norms. Either way it has the same rank, norms, site, token scope, units and coefficients and zero overlap with the target; its principal cosines, row norms and orthogonalization are recorded. A control of another rank (for example rank 1 against a rank-2 span) is refused before the arms run, and a result whose control rank differs from its `target` rank cannot be attached. An effect that the control reproduces is not specific to the estimate. ## Restoration, exceptions and cancellation After every arm the parameter and buffer SHA-256, the forward hook count of every module and the final-token logits of probe prompts must match the pristine model (logits within `atol = rtol = 1e-5`). A failed check stops the attempt, records it as `failed` with the restoration details, and asks for the model to be reloaded. An exception or cancellation removes the experiment's hooks and records a `failed` or `cancelled` attempt, including whether hook counts returned to the pristine state and whether forward passes had started. ## Refusals before any forward pass * a stale, not-ready or threshold-less dossier, an estimate that is not ready, a refitted direction, a source report without an artifact binding, or a direction artifact that is missing, does not match the report's recorded digests or fails the identity, width and rank checks; * incompatible geometry: a different site, model id, dtype, weight fingerprint, tokenizer vocabulary, decoder layer class or readout than the coordinate was captured with, a capture width other than the model's hidden size, a channel outside it, or a model that is not dense on the spec's device; * evaluation rows that are not independent of the estimate's discovery rows (same revision with overlapping roles, as for dossier confirmation data) or that share a tokenized input with the discovery labeled set; * evaluation on the dossier's confirmation rows: the estimate was selected partly on them, so measuring its effect there would carry that selection into the result. Use rows independent of both, such as the `calibrate` role. ## Activation patching `activation_patching` uses the same checks, storage and restoration. At the final prompt position of the estimate's site it replaces each target-task example's activation by the paired source-task example's (`source_swap`, paired by order, the source list cycled) or by the mean over the source examples (`mean_ablation`). `scope` `estimate` replaces only the component along the estimate's coordinate; `site` replaces the whole vector. The declared metric is `logit[target_token] - logit[foil_token]` at the final position; the recorded effect per example is patched minus clean. Patching results are descriptive and cannot be attached to a dossier. ## Results and the label rule Results follow `obliteratus/concepts/schema/intervention-result.v1.schema.json`. A dossier attaches a controlled-intervention result by reference (`{path, sha256, pointer: "/verdict"}`). Whenever the dossier is assessed, the result is re-read, validated and its verdict recomputed from its per-example records. Attachment works the same way for channel, direction and subspace estimates. A result produced as one row of a causal targeting map carries a `family` mark and is refused here; it can only be attached through `map attach`, which applies the map's multiple-comparison correction. It is refused when the result was run against another dossier, before the dossier was created, on another model, or after the hypothesis or its thresholds changed (the result stores the hypothesis digest); when it names another estimate type than the dossier or its control is not rank-matched to its target; or when its stored verdict does not follow from its records. The dossier hypothesis must pre-declare `useful_effect_threshold` (absolute target success-rate difference), `effect_direction` (`increase` or `decrease`), `collateral_margin`, `decision_coefficient` and `target_task`. The verdict is `supported` only when, at the decision coefficient, the intended arm beats the random control by at least the threshold in the declared direction with a one-sided exact McNemar p < 0.05, every collateral endpoint (each collateral task and the target task's invalid-output endpoint, intended arm against baseline) is `PASS`, and restoration passed. Otherwise it is `not_supported` or `inconclusive`; such results are attached and shown, and never upgrade the label. ## Fixture models A result is labeled `software-contract` when the spec declares `model_class: fixture` or when the spec's or dossier's model id starts with `local/`. Such results test the harness, not a model: they never count as model findings and never upgrade a dossier's label by default. `dossier show --allow-fixture-results` (Python: `allow_fixture_results=True`) lets them raise the computed label, for software-contract tests only; the stored dossier label is always computed without that allowance.