DMC-RELKEY-C0-S2 -- Relation-Key Identity Slice 2: FK materialization and FK validation delegation
====================================================================================================

AUTHORITY
---------
Implement ONLY the accepted Slice 2 of the Relation-Key Identity Cycle-0
design. The architecture authority is the `relation_key_cycle0_assessment`
component (the corrected, independently accepted assessment) together with
`relation_key_cycle0_delta_rereview` (the closing delta re-review; read its
F1/F2 dispositions and W2). The already-accepted Slice-1 owner is authority
for what you consume, not something you may change:
`relation_key_slice1_acceptance` records the independent verdict A ("SLICE 1
ACCEPTED", commit `efe3187b1095e97d3840670d258535ff67948ab1`) for
`src/spreadsheet_handling/domain/relation_keys.py` and
`tests/unit/domain/test_relation_keys.py`. The `dmc_contract` component is the
governing procedure. `concepts_fk_helpers` explains the v2 FK relation-policy
contract (`_meta.helper_policies.fk`, derived helper provenance) that your
changes must keep intact -- this WorkItem changes *identity*, not FK policy
resolution. Do not treat this task.txt as a substitute for reading those
components in full before editing.

CONCERN
-------
Make the maintained FK path consume the Slice-1 relation-key semantic owner
(`spreadsheet_handling.domain.relation_keys`) instead of independently
interpreting relation-key identity:

* FK value-mode materialization (`add_fk_helpers` / `enrich_helpers`) must
  resolve helper values by owner-defined relation-key identity, not by
  `core/fk.py`'s `_norm_id` (`str(value)` + `pd.isna`) / `build_id_value_maps`.
* FK unresolvable/value checks (`check_unresolvable_fks`, `check_helper_values`
  in `domain/validations/fk_helpers.py`) must delegate FK/target relation-key
  matching to the owner.
* FK duplicate checking (`check_duplicate_ids`) must delegate to the owner,
  for both the FK-policy-declared `id_field` selection and the
  policy-independent fallback (`defaults['id_field']` or `"id"`).
* Maintained-path dependence on `core/fk.py:_norm_id` must cease.
* The local `validations/fk_helpers.py::_norm_key` module-level helper, and
  the local `_norm` inside `check_unresolvable_fks`, are pure relation-key
  identity interpretation and must be deleted/delegated.
* C3-S2 (the old FK-family Cycle-3 Slice-2 "remove the literal `"nan"`
  duplicate-exclusion guard" question) is absorbed here: remove the
  rendered-String count / literal-`"nan"`-exclusion path from
  `check_duplicate_ids`. Literal `"nan"` becomes an ordinary eligible String
  and duplicates normally; Missing carriers (`None`, `""`, NaN, `pandas.NA`,
  `NaT`) are excluded from relation-key identity entirely, so repeated Missing
  values stop being reported as `duplicate_id`.
* Use the existing `HelperValueProvider` seam in `core/fk.py`
  (`_materialize_fk_helpers` already bypasses its own `value_map`/`_norm_id`
  lookup whenever a provider is supplied -- proven today by
  `domain/transformations/fk_helpers/formula_provider.py`'s formula-mode
  provider). Core MUST NOT import Domain.
* Add the truthful FK behavior-change release-note bullet under the active
  unreleased section (`== unknown -- planned`) of
  `docs/release_notes/release_notes.adoc`.

CORE/DOMAIN LAYER BOUNDARY -- core/fk.py IS OUT OF SCOPE
----------------------------------------------------------
Preparation-time inspection of `src/spreadsheet_handling/core/fk.py` found
that `_materialize_fk_helpers` already takes an optional
`helper_value_provider`: when one is supplied, it calls
`helper_value_provider(fk, raw_ids)` and never touches its own `value_map` /
`_norm_id` path at all. `enrich_helpers` in
`domain/transformations/fk_helpers/enrich.py` already exercises this exact
bypass for formula mode via `build_lookup_formula_value_provider`
(`formula_provider.py`) -- it just does not currently do so for value mode,
where it instead calls `core.fk.build_id_value_maps` (which internally keys by
`_norm_id`) and lets `_materialize_fk_helpers` fall through to its own
`value_map.get(_norm_id(rid), "")` mechanics.

The required Slice-2 shape is therefore: Domain builds owner-keyed value maps
using `relation_key_identity` from the accepted Slice-1 owner, and always
supplies a value-mode `HelperValueProvider` to `_materialize_fk_helpers` (not
only for formula mode). This requires NO change to `core/fk.py` -- the seam
already exists and is already proven. `core/fk.py` is therefore explicitly OUT
OF SCOPE for this WorkItem (see NON-SCOPE). `core/fk.py:_norm_id` and
`core/fk.py:build_id_value_maps` remain untouched legacy Core sediment
(FOLLOW-UP, off the maintained path once this slice lands) -- do not "clean
them up" and do not delete them; ceasing to call them from the maintained
`enrich_helpers` path is the entire required action.

If, once you are actually writing code, you find a genuine mechanical
necessity to touch `core/fk.py` that this analysis missed, STOP and escalate
(report the exact necessity and why the bypass seam does not cover it) rather
than silently editing it. Do not create a Core -> Domain import.

You may add a new sibling module,
`src/spreadsheet_handling/domain/transformations/fk_helpers/value_provider.py`,
mirroring `formula_provider.py`'s shape, if that is the cleanest place for the
new value-mode provider construction; this is a structural choice, not a
requirement -- placing it directly in `enrich.py` is equally acceptable. Do
not add any other new production file without escalating first.

REQUIRED SEMANTICS (see the assessment component for the full contract)
-------------------------------------------------------------------------
Producer (materialization) and validator (unresolvable/duplicate checks) must
agree on the same owner-defined relation-key identity for the deterministic
five-pair matrix:

    " 1 " / "1"   -> unequal (no trim; exact String)
    1 / "1"       -> unequal (distinct categories; no text-token coercion)
    1.0 / 1       -> equal (one Number category, exact represented value)
    "" / ""       -> ineligible (Missing; never a key)
    None / None   -> ineligible (Missing; never a key)

Required consequences:

* exact String whitespace matters -- no `.strip()` anywhere in relation-key
  identity (materialization, unresolvable check, duplicate check);
* Number and String remain distinct; Boolean and Number remain distinct
  (`True` is not `1`);
* integral Number carrier differences resolve/duplicate as one key (`1`,
  `1.0`, `numpy.int64(1)` agree);
* Missing (`None`, `""`, NaN, `pandas.NA`, `NaT`) never participates as a
  relation key on either the source or the target side -- this is
  *participation*, not row validity: source-side Missing continues to be
  whatever caller policy it already is (this slice does not add a new
  FK-side "invalid target" finding), and Missing target values are simply
  excluded from resolution/matching/duplicate maps and sets;
* eligible numeric duplicates report as `duplicate_id`; repeated Missing no
  longer reports as `duplicate_id` (this is the accepted, deliberate
  Missing-ineligibility consequence, not a regression);
* mixed Number/String is never a duplicate;
* literal String `"nan"` duplicates like any ordinary String (this closes
  C3-S2's durable obligation -- see LIFECYCLE OBLIGATION below).

Local Human Readability (per the DMC and the Slice-1 precedent): every call
site that now delegates to the owner must import or call a name containing
`relation_key`, with a comment stating why local pandas/string equality is
insufficient. Names such as `_norm`, `_norm_key`, `_plain`, `_token`, or
`_coerce` alone do not satisfy this and must not survive as the identity
interpreter (they may survive only for an unrelated, explicitly distinct,
locally-owned contract -- see `check_helper_values` below).

`check_helper_values` split (per the assessment's disposition table):

* the FK-column-value -> target-row lookup key (currently built through the
  module-level `_norm_key` inside `_build_target_value_maps`, and matched
  against `_norm(fk_val)` inside `check_helper_values` itself) is relation-key
  *identity* and must delegate to the owner;
* the helper-payload comparison (`actual != exp_norm`, i.e. does the
  materialized helper cell's displayed value match the target row's stored
  field value) is a *different*, Lookup/helper-payload-shaped contract, not
  relation-key identity. It must remain local, explicit mechanics (its
  current `str(value).strip()` shape may be kept), but must be clearly
  separated from -- and not reuse the same private name as -- the relation-key
  delegation above, per Local Human Readability.

`check_unresolvable_fks` and `check_duplicate_ids` have no separate
payload-comparison contract; their local `_norm`/rendered-count logic is pure
identity interpretation and must be fully deleted/delegated, not split.

EXPLICIT NON-SCOPE
------------------
Do not, under this WorkItem:

* modify `src/spreadsheet_handling/domain/relation_keys.py` or
  `tests/unit/domain/test_relation_keys.py` -- Slice 1 is independently
  accepted and closed; this WorkItem is a pure consumer;
* modify `src/spreadsheet_handling/core/fk.py` -- see the layer-boundary
  section above; escalate rather than silently touch it;
* migrate or modify Lookup enrichment
  (`domain/transformations/enrich_lookup/**`) -- Slice 3a;
* migrate or modify reference or graph validation
  (`domain/validations/reference_validations.py`,
  `domain/validations/graph_validations.py`) -- Slice 3b;
* touch canonical Semantic Model, Technical Model, or any other canonical
  documentation surface -- Slice 4;
* widen or rename any public/helper surface, change the v2 FK relation-policy
  shape, or register a new pipeline step;
* implement a general scalar normalizer, general tuple-uniqueness identity,
  or any Number/DateTime normalization API beyond what the accepted Slice-1
  owner already exposes;
* touch `docs/backlog/roadmap_domain_hardening_sequence.adoc` or any
  FK/reference-helper family Cycle-3 record -- see LIFECYCLE OBLIGATION below;
  this WorkItem records the obligation, it does not execute it;
* touch Project Memory;
* touch the `spreadsheet-handling-demo` repository or any file outside the
  `core` repository -- the maintained-consumer probe required by the accepted
  assessment is bounded, inside `core`, to the registered `validate` pipeline
  step exercised by `tests/unit/domain/validations/test_validate_modes.py`
  (this is the only maintained test found in `core` that drives
  `make_validate_step`/`run_pipeline` with `mode_duplicate_ids`/
  `mode_missing_fk` including `"fail"`, matching the assessment's named
  maintained-consumer surface); `core`'s shipped example pipelines
  (`src/spreadsheet_handling/examples/*.yml`) are not exercised by any
  automated `core` test today and adding such a test is not part of this
  slice;
* touch Slices 3a, 3b, or 4 in any form; and
* touch the Workflow Coordinator, the Runtime, or any other WorkItem's
  artifacts.

If correct Slice-2 implementation mechanics genuinely require touching a file
not named in `authorized_scope`, do not silently add it: stop and escalate
(report the need and rationale) rather than expanding scope.

LIFECYCLE OBLIGATION -- C3-S2 / FK FAMILY CYCLE 3 (RECORD, DO NOT EXECUTE)
---------------------------------------------------------------------------
The accepted Cycle-0 assessment and its governing reviews record a durable
obligation: when Slice 2 is ACCEPTED, the roadmap's stale "Family cycle 3
NEXT and NOT STARTED" text (multiple occurrences in
`docs/backlog/roadmap_domain_hardening_sequence.adoc`) and the
FK/reference-helper family's Cycle-3 record must state that C3-S2 (the
literal-`"nan"` duplicate-exclusion guard) was superseded by this shared
relation-key correction, not independently implemented. C3-S1 remains
accepted history and is untouched.

This WorkItem's `review` phase is authorized to edit and commit only the new
Slice-2 review artifact
(`docs/warm_storage/global_reviews/relation_key_identity_slice2_fk_delegation_implementation_review_2026-09-25.adoc`).
It must NOT edit the roadmap or any Cycle-3 record file, even when its own
verdict is ACCEPTED -- doing so would exceed this WorkItem's authorized scope
and would couple a design-review-style lifecycle edit to a still-uncommitted
acceptance in a way this WFC phase graph cannot make safely atomic.

Instead, the review artifact's required "Lifecycle cleanup check" section
(per `review_instructions.adoc`) must:

* state the verdict reached (ACCEPTED or CHANGES REQUIRED);
* if ACCEPTED: name this exact obligation (the roadmap's stale Family-Cycle-3
  text and the Cycle-3 record) and state explicitly that it is now owed as an
  *immediate post-acceptance maintainer action*, not performed by this
  WorkItem and not performed by this Run;
* if CHANGES REQUIRED: state that the obligation remains deferred until a
  future acceptance, unchanged from its current status.

Do not fabricate authority to edit the roadmap or Cycle-3 record inside this
bundle, and do not claim the obligation was fulfilled. This mirrors how the
Slice-1 review artifacts and the Cycle-0 delta re-review each recorded
lifecycle obligations without executing them ahead of the authorizing event.

REVIEW / FINDING CHOREOGRAPHY
-----------------------------
An implementation that meets the accepted contract may be accepted without a
Finding:

    implement -> review -> accept

The fresh gate reviewer writes the required review artifact and may open a new
blocking Finding only for a real remaining defect against the accepted
Cycle-0 contract and this task's bounded scope; do not manufacture one. In
that case return `outcome: changes_required` and request `correct`:

    implement -> review -> correct -> rereview -> accept

The corrector may cite or add evidence to an existing Finding but must not
resolve, residualize, supersede, reopen, or otherwise dispose of it. After a
completed correction, request `rereview`.

The fresh gate rereviewer may resolve an open blocking Finding only when the
correction establishes closure, then request `accept`. If a blocker remains,
return `changes_required` and request `correct`; the four-Hop budget, not an
invented retry, controls whether another correction can run.

CORRECTION AUTHORITY
---------------------
If and only if the fresh review finds a REAL remaining Slice-2 semantic or
scope defect, `correct` may mutate only:

    src/spreadsheet_handling/domain/transformations/fk_helpers/enrich.py
    src/spreadsheet_handling/domain/transformations/fk_helpers/value_provider.py
    src/spreadsheet_handling/domain/validations/fk_helpers.py
    tests/unit/domain/transformations/test_fk_helpers_enrich.py
    tests/unit/domain/validations/test_fk_check.py
    tests/unit/domain/validations/test_validate_modes.py
    docs/release_notes/release_notes.adoc

No other production path. No amend/rewrite of any existing commit. No later
Relation-Key slices. No roadmap or Cycle-3 record edit (see LIFECYCLE
OBLIGATION above).

VALIDATION
----------
Before claiming implementation or correction success, run at least:

    python -m pytest -q tests/unit/domain/transformations/test_fk_helpers_enrich.py
    python -m pytest -q tests/unit/domain/validations/test_fk_check.py
    python -m pytest -q tests/unit/domain/validations/test_validate_modes.py
    git diff --check

Report results truthfully. The only trusted evidence providers selected by
this profile are `diff_hygiene`, `git_version`, `pytest_fk_enrich`,
`pytest_fk_validate`, and `pytest_validate_modes`. All three named test files
pass on the unmodified baseline (55 tests total); implementation and
correction must not reduce that count without an explicit, justified
rationale in the commit or review artifact.

AGENT GIT RULE
--------------
Core's general commit-identity guidance
(`docs/ai_info/git_and_workflow.adoc`, "DMC-family commit identity") is a
traceability *recommendation*, not a binding rule. Do not repeat Run 01's
historical mistake of treating trailers as mandatory (see
`docs/warm_storage/global_reviews/relation_key_identity_slice1_wfc_run_01_disposition_2026-09-25.adoc`).

For any commit the Coordinator creates under this WorkItem, the only
requirement is a valid, single-line, Conventional-Commit-compatible subject
that contains both this WorkItem's ID and the current Hop ID as identity
tokens, e.g.:

    feat(DMC-RELKEY-C0-S2): delegate FK relation identity H001
    docs(DMC-RELKEY-C0-S2): record Slice 2 review H002

This is exactly what Runtime `ec397b6`'s `commit_subject_error` mechanically
enforces (Conventional-Commit subject shape plus WorkItem/Hop token
presence); it requires no body and no trailers. Do not invent a new
commit-identity mechanism or validator, and do not require a multiline commit
body -- the generic `CommitIntent` body gap is tracked separately as
standalone WFC `FTR-WFC-COMMIT-INTENT-BODY` and is out of scope here.
