Skip to content

N1 — rename backend to engine, codebase-wide - #56

Merged
can-goodfire merged 1 commit into
can/protocol-refactorfrom
can/engine-rename
Aug 28, 2026
Merged

can-goodfire merged 1 commit into
can/protocol-refactorfrom
can/engine-rename

Conversation

@can-goodfire

Copy link
Copy Markdown
Collaborator

The nnsight-engine plan (cockpit notes/causalab-nnsight-engine-plan.md, §0 decision 6 / §6-N1) fixes the term engine for what protocol/backend.py already described as "one execution engine". This PR is the codebase-wide rename, landed first in the N-stack because it is only cheap pre-merge: the artifact stamp key rides along, and no artifacts are canon yet.

What renames

  • protocol/backend.pyprotocol/engine.py; BackendEngine, choose_backendchoose_engine. ExecutionRequest/RunResult keep their names.
  • neural/pytorch_hooks/neural/engines/pytorch_hooks/; backend.pyengine.py; PytorchHooksBackendPytorchHooksEngine. A shim at the old package path re-exports for one deprecation beat.
  • Stamp key identity_base["backend"]"engine" (ARTIFACT_IDENTITY_KEYS, both stamping sites: workflow/runner.py, engines/pytorch_hooks/engine.py).
  • tests/neural/pytorch_hooks/tests/neural/engines/pytorch_hooks/; test_backend_routing.pytest_engine_routing.py.
  • Living docs (intervention_protocol.md §8 + capability table, workflow_protocol.md, CODEBASE.md, TESTS.md, READMEs), CLI refusal messages.

What deliberately does not

  • The corpus fixture keeps the old stamp key. tests/protocol/_env.py generates 09's "previously fitted" artifact at test time; pre-rename artifacts factually carry "backend", and keeping it keeps 09's content_digest — hence the pinned canonical form — byte-stable, and keeps the loader's tolerance of pre-rename bundles under test. This is the one place the plan's "stamp is metadata, not canonical form" reasoning meets a fixture whose bytes embed the stamp.
  • Historical docs (REBASE_CAUSALAB_ON_NNTERP.md, test_migration.md, NNsight_overview.md), pinned goldens JSON, and third-party senses (matplotlib Agg, LAPACK, uv build-backend, torch.backends).

Gates

  • pytest -m "not golden": 1963 passed.
  • update_corpus_digests.py: zero diff.
  • pre-commit run --all-files: clean.
  • grep gate: no [Bb]ackend outside the exemptions above.

Note for #54 (can/backend-forward-interning): it targets this base and touches the renamed executor; it will need a rebase over this (its CI is currently red anyway).

🤖 Generated with Claude Code

The term is decided in the nnsight-engine plan (§0 decision 6): what
protocol/backend.py already called "one execution engine" in its own
docstring is now named that everywhere, before a second engine exists and
while no artifacts are canon — the only time the stamp-key half of this is
cheap.

- protocol/backend.py → protocol/engine.py: Backend → Engine,
  choose_backend → choose_engine; ExecutionRequest/RunResult unchanged.
- neural/pytorch_hooks/ → neural/engines/pytorch_hooks/ (backend.py →
  engine.py, PytorchHooksBackend → PytorchHooksEngine); a shim keeps the
  old import path alive for one deprecation beat.
- The artifact stamp key 'backend' → 'engine' (resolve.py
  ARTIFACT_IDENTITY_KEYS, both stamping sites in workflow/runner.py and
  engines/pytorch_hooks/engine.py). The corpus fixture in tests/protocol/
  _env.py deliberately keeps the old key: it models a previously fitted
  artifact, which keeps 09's content_digest byte-stable (zero corpus-digest
  diff) and keeps loader tolerance of pre-rename bundles under test.
- tests/neural/pytorch_hooks/ → tests/neural/engines/pytorch_hooks/
  (parents[] depths adjusted), test_backend_routing.py →
  test_engine_routing.py.
- Living docs renamed; historical docs (REBASE_CAUSALAB_ON_NNTERP,
  test_migration, NNsight_overview), pinned goldens, and third-party senses
  (matplotlib Agg, LAPACK, uv build-backend, torch.backends) untouched.

Rename-only: no behavior change. Gates: 1963 passed (-m 'not golden'),
corpus digests regenerated with zero diff, pre-commit clean, grep gate
clean outside the exemptions above.

Plan: cockpit notes/causalab-nnsight-engine-plan.md §6-N1.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Test Results

1 962 tests  ±0   1 954 ✅ ±0   58s ⏱️ -10s
    1 suites ±0       8 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 514a70b. ± Comparison against base commit 58be68e.

This pull request removes 365 and adds 365 tests. Note that renamed tests count towards both.
tests.neural.pytorch_hooks.test_attention_probs ‑ test_a_deltanet_layer_refuses_on_the_architecture
tests.neural.pytorch_hooks.test_attention_probs ‑ test_a_family_without_eager_math_refuses_by_name
tests.neural.pytorch_hooks.test_attention_probs ‑ test_a_generated_frame_read_refuses
tests.neural.pytorch_hooks.test_attention_probs ‑ test_a_non_swap_pattern_write_is_refused
tests.neural.pytorch_hooks.test_attention_probs ‑ test_an_edit_to_one_layer_leaves_the_other_layers_pattern_intact
tests.neural.pytorch_hooks.test_attention_probs ‑ test_an_identity_edit_is_bit_identical
tests.neural.pytorch_hooks.test_attention_probs ‑ test_an_identity_edit_is_bit_identical_on_llama
tests.neural.pytorch_hooks.test_attention_probs ‑ test_an_interchange_across_different_lengths_refuses
tests.neural.pytorch_hooks.test_attention_probs ‑ test_no_edits_installs_nothing
tests.neural.pytorch_hooks.test_attention_probs ‑ test_the_backend_now_declares_the_capability
…
tests.neural.engines.pytorch_hooks.test_attention_probs ‑ test_a_deltanet_layer_refuses_on_the_architecture
tests.neural.engines.pytorch_hooks.test_attention_probs ‑ test_a_family_without_eager_math_refuses_by_name
tests.neural.engines.pytorch_hooks.test_attention_probs ‑ test_a_generated_frame_read_refuses
tests.neural.engines.pytorch_hooks.test_attention_probs ‑ test_a_non_swap_pattern_write_is_refused
tests.neural.engines.pytorch_hooks.test_attention_probs ‑ test_an_edit_to_one_layer_leaves_the_other_layers_pattern_intact
tests.neural.engines.pytorch_hooks.test_attention_probs ‑ test_an_identity_edit_is_bit_identical
tests.neural.engines.pytorch_hooks.test_attention_probs ‑ test_an_identity_edit_is_bit_identical_on_llama
tests.neural.engines.pytorch_hooks.test_attention_probs ‑ test_an_interchange_across_different_lengths_refuses
tests.neural.engines.pytorch_hooks.test_attention_probs ‑ test_no_edits_installs_nothing
tests.neural.engines.pytorch_hooks.test_attention_probs ‑ test_the_engine_now_declares_the_capability
…

@can-goodfire
can-goodfire merged commit 3d8ec63 into can/protocol-refactor Aug 28, 2026
4 checks passed
@can-goodfire
can-goodfire deleted the can/engine-rename branch August 28, 2026 14:47
@can-goodfire
can-goodfire restored the can/engine-rename branch August 28, 2026 14:47
@can-goodfire
can-goodfire deleted the can/engine-rename branch August 28, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants