DMC-RELKEY-C0-S3B -- Relation-Key Identity Slice 3b: reference and graph relation-key validation delegation
================================================================================================================

AUTHORITY
---------
Implement ONLY the accepted Slice 3b of the Relation-Key Identity Cycle-0
design. The architecture authority is the `relation_key_cycle0_assessment`
component (the corrected, independently accepted assessment), specifically
its "Slice 3b -- reference and graph relation-key validation delegation"
section, its "Delegation and deletion inventory" table (rows for
`reference_validations.py::_key_token` and `graph_validations.py::_key_token`),
and its "Adjacent and lifecycle dispositions" / "Generic tuple-uniqueness
identity" follow-up section, together with `relation_key_cycle0_delta_rereview`
(the closing delta re-review; read its F2 disposition in full -- it is the
authority for the relation-identity/generic-tuple-uniqueness separation this
slice must preserve -- and its W4 finding, which names this slice by number
as owning the default-`unique_edges`-columns characterization). The
already-accepted Slice-1 owner is authority for what you consume, not
something you may change: `relation_key_slice1_acceptance` records verdict A
for `src/spreadsheet_handling/domain/relation_keys.py` and
`tests/unit/domain/test_relation_keys.py` (commit `efe3187b`). Its exact
public surface is:

    is_relation_key_eligible(*components) -> bool
    relation_key_identity(*components) -> RelationKeyIdentity | None
    relation_keys_equal(left: tuple, right: tuple) -> bool

`relation_key_identity` returns `None` when any component is Missing;
otherwise it returns one hashable, category-tagged, equality-consistent
identity for the ordered composite key. `relation_key_slice2_acceptance` and
`relation_key_slice3a_acceptance` record verdict A for the sibling FK and
Lookup delegation slices; read them as *pattern precedent only* (the
Local-Human-Readability naming discipline -- every delegating call site
imports or calls a name containing `relation_key`, with a comment on why
local string/pandas equality is insufficient -- and the general shape of
"split a shared local helper that silently served two purposes"). Neither
authorizes touching any Slice-1/2/3a file, and reference/graph validation has
no pandas-merge boundary comparable to Slice 3a's -- it iterates rows and
builds Python `set`/`Counter` structures over tuples, so the delegation shape
here is a direct membership/equality substitution, not a join-representation
design question. The `dmc_contract` component is the governing procedure. Do
not treat this task.txt as a substitute for reading those components in full
before editing.

CONCERN
-------
Make the maintained declarative reference/graph validation path
(`validate_references` / `validate_graph`) consume the Slice-1 relation-key
semantic owner (`spreadsheet_handling.domain.relation_keys`) for *relation
identity* while leaving *generic tuple uniqueness* completely unchanged:

* `_validate_foreign_key` in `reference_validations.py` currently builds
  `target_keys = {_key_token(key) for _, key in _row_keys(target,
  target_columns) if not any(_is_empty_cell(value) for value in key)}`
  (`reference_validations.py:273-277`) and tests membership with
  `_key_token(key) not in target_keys` (`:297`). This is `foreign_key` target
  resolution and must delegate to the owner: build target eligibility/
  identity with `relation_key_identity`/`is_relation_key_eligible`, not
  `_key_token`'s per-component `str()` stringification. The existing empty
  key-part finding (`"Foreign key contains empty key part."`) and the
  existing `allow_empty` skip for an all-empty source key are separate,
  already-correct caller policy and must keep their current behavior and
  messages; only the *resolution* identity underneath changes.
* `_validate_primary_key` in `reference_validations.py` calls the shared
  `_duplicate_findings` helper (`:205-214`) for its uniqueness check. That
  same helper is also called by `_validate_unique` (`:158-165`) and
  `_validate_unique_reference` (`:334-341`). Per the assessment's disposition
  table, only `primary_key` duplicate identity delegates to the owner;
  `unique` and `unique_reference` are explicitly *not* in scope and must keep
  exactly their current `_key_token`-based duplicate identity. This means
  `_duplicate_findings` must be split: introduce a relation-key-based
  duplicate-finding path used only by `_validate_primary_key`, and leave
  `_duplicate_findings` (or an equivalently named generic helper) serving
  `_validate_unique` and `_validate_unique_reference` unchanged. The already
  existing separate Missing-presence check in `_validate_primary_key`
  (`"Primary key values must be present and non-empty."`, based on
  `_is_empty_cell`, not relation-key eligibility) is caller policy and stays
  exactly as-is; do not fold it into or replace it with owner-eligibility.
* `graph_validations.py::_endpoint_findings` (via `_key_set` for per-node
  membership sets, and directly in its two `_row_keys` loops for source/
  target checks, `:100-125`) resolves both node-key membership and edge
  endpoint identity through the local `_key_token`. This is graph endpoint
  *relation* identity (source/target resolution) and must delegate to the
  owner. `_unique_edge_findings` (`:129-159`) is graph `unique_edges` generic
  tuple uniqueness and must keep its current `_key_token`-based identity
  completely unchanged, including a repeated edge tuple with a blank
  qualifier column continuing to produce the current `graph_unique_edge`
  finding (do not let it start being excluded merely because the same
  columns are, for `endpoints_exist`, now Missing-ineligible under the
  owner).
* Add the truthful reference/graph behavior-change release-note bullet under
  the active unreleased section (`== unknown -- planned`) of
  `docs/release_notes/release_notes.adoc`, describing only what actually
  changes: `primary_key`/`foreign_key` and graph-endpoint relation
  resolution now use category-aware relation-key identity (exact String,
  Number/String and Boolean/Number separation, integral Number equivalence,
  Missing exclusion), while graph `unique_edges` and reference
  `unique_reference` generic tuple uniqueness are explicitly unchanged. Do
  not claim a general scalar-normalization change and do not claim
  `unique_reference`/`unique_edges` migrated.

CRITICAL SEMANTIC DISTINCTION -- DO NOT MERGE THESE TWO CONCEPTS
-------------------------------------------------------------------
A. RELATION IDENTITY (delegates to the Slice-1 owner):
   declarative `primary_key` duplicate identity; `foreign_key` target
   resolution; graph source-endpoint resolution; graph target-endpoint
   resolution. These inherit the accepted semantics: exact String (no
   trim); String `"1"` != Number `1`; Boolean `true` != Number `1`;
   integral Number carrier equivalence (`1 == 1.0 == numpy.int64(1)`);
   exact represented numeric/DateTime semantics; Missing carriers are
   ineligible; no fallback through `str`/`repr`/pandas dtype coercion.

B. GENERIC TUPLE UNIQUENESS (local mechanics, unchanged):
   `unique` (`_validate_unique`); reference `unique_reference`
   (`_validate_unique_reference`); graph `unique_edges`
   (`_unique_edge_findings`). These must NOT adopt Relation-Key
   Missing-ineligibility merely because their columns happen to hold
   endpoint/reference values. In particular, per the accepted Cycle-0
   requirement: a repeated `unique_reference` tuple with a blank qualifier,
   and a repeated `unique_edges` tuple with a blank qualifier, both retain
   their current finding behavior exactly.

Do not "simplify" both concepts through one universal normalizer, and do not
let a shared helper (`_duplicate_findings`, `_key_token`, `_plain_value`)
silently become the thing that decides both, by construction or by accident.

W4 / DEFAULT UNIQUE_EDGES CASE -- MUST BE EXPLICITLY CHARACTERIZED
-----------------------------------------------------------------
When an edge's `unique_columns` is not configured, `_edge_specs` defaults it
to `list(dict.fromkeys([*source_columns, *target_columns]))`
(`graph_validations.py:276-280`) -- i.e. the same physical columns used for
endpoint resolution. After this slice:

* `endpoints_exist` resolution over those columns uses relation-key
  identity (distinguishes `1`/`"1"`, excludes Missing); and
* the default `unique_edges` tuple check over the *same* columns keeps its
  current generic token identity (stringified, blank-participating).

This is deliberate: the same physical columns are legitimately interpreted
under two different semantic operations depending on which check consumes
them. Add or keep a test that makes this dual interpretation visible for the
default-columns case specifically (not only for an explicitly configured
`unique_columns`), so a future reader cannot accidentally "fix" the
divergence by wiring `_unique_edge_findings` through the owner.

FOREIGN_KEY VS UNIQUE_REFERENCE DIVERGENCE -- CHARACTERIZE, DO NOT COLLAPSE
----------------------------------------------------------------------------
The accepted assessment requires this known divergence to be characterized
by tests, not silently erased in either direction:

* do not make `unique_reference` duplicate identity mean foreign-key/
  relation-key resolution; and
* do not make `foreign_key`/`primary_key` resolution fall back to
  `unique_reference`'s generic tuple tokenization.

Add or keep a test pair (same input shape, e.g. a Number/String mixed pair or
a repeated Missing value) run once through `foreign_key`/`primary_key` and
once through `unique_reference`, asserting the now-different outcomes, with a
comment naming this as the accepted, intentional post-migration divergence.

FINDING DISPLAY / REPORTING -- LOCAL, UNCHANGED
------------------------------------------------
Relation-Key identity decides relation equality/resolution only. Do not
expose an opaque `RelationKeyIdentity` object as a public `ReferenceFinding`
payload value, message, or row index. `ReferenceFinding.value`/`.row_index`/
`.message` construction, `_format_scalar`, `_format_value`, and
`_safe_row_index` remain exactly as they are today; owner delegation happens
only in the membership/equality decision that determines *whether* a finding
is produced, never in what a finding *displays*. Do not redesign the finding
model, row-index scalarization, or `_plain_value`'s non-key uses (row-index
label preservation, `enabled_when`/`when` condition evaluation, generic
display formatting) -- those are unrelated existing mechanics and are out of
scope.

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 any Slice-2 FK file (`domain/transformations/fk_helpers/enrich.py`,
  `domain/transformations/fk_helpers/value_provider.py`,
  `domain/validations/fk_helpers.py`, or their tests) -- Slice 2 is
  independently accepted and closed;
* modify any Slice-3a Lookup file
  (`domain/transformations/enrich_lookup/{operation,policy,mismatch}.py`,
  `tests/unit/domain/transformations/test_enrich_lookup.py`,
  `tests/unit/domain/transformations/test_derived_column_policy.py`) --
  Slice 3a is independently accepted and closed;
* modify `src/spreadsheet_handling/core/*` or any other `core/` module;
* modify `tests/unit/domain/validations/test_reference_and_graph_row_index_scalarization.py`
  -- preparation-time inspection found it exercises only `_safe_row_index`
  scalarization (via the generic `unique` rule and `endpoints_exist`), a
  concern this slice does not touch; it is not selected as trusted evidence
  for this WorkItem (see VALIDATION below) and must not be widened into a
  relation-key test;
* change `_validate_unique`, `_validate_unique_reference`,
  `_unique_edge_findings`, `_key_token`, or `_plain_value`'s non-key uses, in
  any way that alters their current output for existing inputs -- these are
  the generic-tuple-uniqueness mechanics this slice must leave intentionally
  unmodified;
* rename, widen, or otherwise change the public `validate_references` /
  `validate_graph` function signatures, the `ReferenceFinding` dataclass
  shape, or the registered `validate`/graph-validation pipeline steps;
* implement a general scalar normalizer, general tuple-uniqueness identity,
  or any Number/DateTime normalization API beyond what the accepted Slice-1
  owner already exposes;
* decide the public FK/Lookup helper-surface consolidation FTR
  (`FTR-FK-REFERENCE-HELPER-SURFACE-CONSOLIDATION-P5`) or the still-open
  generic tuple-uniqueness identity/consistency follow-up named by the
  assessment -- this slice characterizes the divergence, it does not resolve
  it;
* touch canonical Semantic Model, Technical Model, or any other canonical
  documentation surface -- Slice 4;
* touch Project Memory;
* touch the Workflow Coordinator, the Runtime, or any other WorkItem's
  artifacts; and
* touch Slice 4 in any form.

If correct Slice-3b 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.

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` again:

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

The six-Hop budget (H001 implement, H002 review, H003 correct, H004 rereview,
H005 correct, H006 rereview) permits exactly two complete correction/
re-review cycles while preserving independent review after the second
correction; it is not an invented retry mechanism -- the budget boundary,
not this task, controls whether a further correction can run. Do not
manufacture Findings or corrections merely to consume the budget.

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

    src/spreadsheet_handling/domain/validations/reference_validations.py
    src/spreadsheet_handling/domain/validations/graph_validations.py
    tests/unit/domain/validations/test_reference_validations.py
    tests/unit/domain/validations/test_graph_validations.py
    docs/release_notes/release_notes.adoc

No other production path. No amend/rewrite of any existing commit. No later
Relation-Key slices.

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

    python -m pytest -q tests/unit/domain/validations/test_reference_validations.py
    python -m pytest -q tests/unit/domain/validations/test_graph_validations.py
    git diff --check

Report results truthfully. The only trusted evidence providers selected by
this profile are `diff_hygiene`, `git_version`, `pytest_reference_validations`,
`pytest_graph_validations`, and (`review` phase only)
`asciidoc_review_validate`. Both named test files pass on the unmodified
baseline (26 tests total: 21 in `test_reference_validations.py`, 5 in
`test_graph_validations.py`); implementation and correction must not reduce
that count without an explicit, justified rationale in the commit or review
artifact. `tests/unit/domain/validations/test_reference_and_graph_row_index_scalarization.py`
(5 tests, also currently passing) is deliberately NOT selected as trusted
evidence: preparation-time inspection found it exercises only row-index
scalarization (`_safe_row_index`), a concern this slice does not touch, so
requiring it would widen the evidence surface without a concrete reason; do
not add it as evidence merely because it happens to call
`validate_references`/`validate_graph`.

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.

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-S3B): delegate reference graph identity H001
    docs(DMC-RELKEY-C0-S3B): record review H002
    fix(DMC-RELKEY-C0-S3B): correct reference graph identity H003

This is exactly what Runtime commit-subject validation 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.
