Story-1277 functions lane refactor + relabel

Matter Preset relabel + matter_type package move

This is a label change and a box rename. The product calls these objects "Matter Presets" now, so the words a user reads were updated and the misnamed code folder was given its real name. Nothing about the database, the API, or how the system behaves changed.

The mental model: a folder on disk had the wrong sticker. src/domains/matter_type/ actually held the MatterTemplate domain, not a "matter type." We peeled the sticker, renamed the folder to src/domains/matter_preset/, and pointed every import at the new name. The contents — class names, the matter_templates table, every identifier — are untouched. Separately, two user-facing words flipped from "Template" to "Matter Preset." That frees the matter_type/ name for the real Matter Type catalog that lands in S2.

Why this exists

Spike-1274 mapped the blast radius for splitting two coupled ideas that had been conflated: a Matter Preset (the saved bundle of defaults, historically called "template") and a future Matter Type (the coarse "what kind of matter is this" classification). ADR-115 ratified the plan. The squatted package name was the actual bug: a reader opening matter_type/ would find MatterTemplate and three of its junction tables — confusing, and a direct collision with the new domain. S1 fixes the cheap, code-only half so S2 has a clean home.

What changed

Package move

src/domains/matter_type/ → src/domains/matter_preset/ via git mv. Module path only.

Importers repointed

Every from src.domains.matter_type... updated to matter_preset — six domain/router importers, the entity registry, alembic/env.py, the package's own internal imports, and two test modules.

Audit label

SUBJECTS["template"] display label "Template" → "Matter Preset" in src/shared/audit/registry.py.

Error strings

The seven user-facing PramaanError detail strings carrying "Matter Template" in template_service.py now read "Matter Preset."

Dead subject removed

The orphan audit subject space_meta_template (no emitter anywhere) was deleted from the registry. Folded-in Chore A.

The package move shows up in git as renames, so the diff reads as "this file moved" rather than a delete-plus-add — reviewable at a glance.

What was deliberately NOT touched (frozen)

The word "template" stays inside the schema and the API contract on purpose. Renaming any of these would either orphan stored audit rows or churn the OpenAPI snapshots, which is out of scope for this display-only relabel.

SurfaceStays
Audit event-type keystemplate.created / edited / deleted
Table & columnsmatter_templates, matter_template_id, matter_template_number
Class namesMatterTemplate + its three junction classes
Router prefix & tag/app/matter-templates, tag matterTemplates
Reference prefix / kindMT- prefix, counter kind matter_template
Contract textroute summaries + DTO field descriptions (OpenAPI-bound)

No schema change. No migration. No OpenAPI diff. Because no identifier, table, column, or contract string moved, there is nothing for Alembic to autogenerate and nothing for the snapshot generator to re-emit.

How it was verified

  1. uv run ruff check on every changed/moved file — clean (the repo's pre-existing lint debt in old migrations and scripts/ is untouched and unrelated).
  2. Import smoke test: all six importers, the entity registry, alembic/env.py, and the moved package import successfully; MatterTemplate.__tablename__ is still matter_templates.
  3. make openapi then git diff --exit-code -- openapi/app-api.json openapi/admin-api.json — clean, proving zero contract churn.
  4. Targeted unit tests for the audit registry, route coverage, and matter DTOs pass; the registry now exposes label "Matter Preset" and no longer carries space_meta_template.
  5. No new file under alembic/versions/; the relabel is code, not schema.

Engineering outcome: the folder finally matches its contents and the user-visible word matches the product, while the schema and API contract are provably identical to before. The matter_type/ name is now free for the real Matter Type catalog in S2.