---
phase: 168
plan: 01
type: execute
wave: 1
depends_on:
  - 168-discuss
  - 167.1
files_modified:
  - research/knowledge-hub/knowledge_hub/analytical_review_support.py
  - research/knowledge-hub/knowledge_hub/cli_review_handler.py
  - research/knowledge-hub/knowledge_hub/aitp_service.py
  - research/knowledge-hub/tests/test_aitp_cli.py
  - research/knowledge-hub/tests/test_aitp_service.py
  - research/knowledge-hub/tests/test_aitp_cli_e2e.py
autonomous: false
requirements:
  - REQ-ANX-01
  - REQ-ANX-02
must_haves:
  truths:
    - analytical checks must become first-class durable rows that carry their own source anchors and assumption or regime context
    - review-level status, counts, and summary may remain, but they must be derived from the richer row set rather than remain the only durable context
    - the current analytical-review CLI/service path and primary validation-review-bundle behavior must stay compatible in this phase
---

<objective>
Expand the existing `analytical_review` contract into a row-first analytical
cross-check surface where each stored check is self-contained and durable,
while preserving the current analytical-review CLI/service/bundle flow and
deferring new runtime/read-path surfaces to Phase `168.1`.
</objective>

<execution_context>
@D:/BaiduSyncdisk/Theoretical-Physics/.codex-home/get-shit-done/workflows/execute-plan.md
@D:/BaiduSyncdisk/Theoretical-Physics/.codex-home/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/phases/168-analytical-check-rows-and-review-contract-expansion/168-CONTEXT.md
@.planning/phases/168-analytical-check-rows-and-review-contract-expansion/168-RESEARCH.md
@.planning/phases/168-analytical-check-rows-and-review-contract-expansion/168-VALIDATION.md
@research/knowledge-hub/knowledge_hub/analytical_review_support.py
@research/knowledge-hub/knowledge_hub/cli_review_handler.py
@research/knowledge-hub/knowledge_hub/aitp_service.py
@research/knowledge-hub/runtime/scripts/run_analytical_judgment_surface_acceptance.py
</context>

<tasks>

<task type="auto">
  <name>Task 1: Add red tests for row-level analytical check contract coverage</name>
  <files>research/knowledge-hub/tests/test_aitp_cli.py, research/knowledge-hub/tests/test_aitp_service.py, research/knowledge-hub/tests/test_aitp_cli_e2e.py</files>
  <read_first>research/knowledge-hub/tests/test_aitp_cli.py, research/knowledge-hub/tests/test_aitp_service.py, research/knowledge-hub/tests/test_aitp_cli_e2e.py, .planning/phases/168-analytical-check-rows-and-review-contract-expansion/168-CONTEXT.md</read_first>
  <action>Add failing tests that require `analytical_review.json` to store row-level context on each `checks[]` entry. At minimum each stored row must expose `kind`, `label`, `status`, `notes`, `source_anchors`, `assumption_refs`, `regime_note`, and `reading_depth`. Extend the analytical review fixtures to include the new `source_cross_reference` kind and keep the existing public `analytical-review` CLI flow as the contract under test.</action>
  <verify>python -m pytest research/knowledge-hub/tests/test_aitp_service.py::AITPServiceTests::test_audit_analytical_review_writes_durable_artifact_and_updates_candidate research/knowledge-hub/tests/test_aitp_cli.py -k "analytical_review" -q</verify>
  <acceptance_criteria>
    - `test_aitp_service.py` fails until `checks[0]["source_anchors"]`, `checks[0]["assumption_refs"]`, `checks[0]["regime_note"]`, and `checks[0]["reading_depth"]` exist
    - analytical review fixtures accept `source_cross_reference` as a valid check kind
    - the existing `analytical-review` CLI path remains the entrypoint under test instead of a new command
  </acceptance_criteria>
  <done>A red contract exists for the richer analytical check-row payload.</done>
</task>

<task type="auto">
  <name>Task 2: Implement row-first analytical review normalization and compatibility rollups</name>
  <files>research/knowledge-hub/knowledge_hub/analytical_review_support.py, research/knowledge-hub/knowledge_hub/cli_review_handler.py, research/knowledge-hub/tests/test_aitp_service.py</files>
  <read_first>research/knowledge-hub/knowledge_hub/analytical_review_support.py, research/knowledge-hub/knowledge_hub/cli_review_handler.py, .planning/phases/168-analytical-check-rows-and-review-contract-expansion/168-CONTEXT.md, .planning/phases/71-analytical-review-artifacts-and-runtime-surfaces/71-CONTEXT.md</read_first>
  <action>Extend `ALLOWED_ANALYTICAL_CHECK_KINDS` with `source_cross_reference`. Change analytical-review normalization so every stored `checks[]` row includes `kind`, `label`, `status`, `notes`, `source_anchors`, `assumption_refs`, `regime_note`, and `reading_depth`. Preserve the current public `analytical-review` CLI call surface; existing review-level flags should continue working by supplying defaults copied into each row. Keep top-level `source_anchors`, `assumption_refs`, `regime_note`, `reading_depth`, counts, and `summary`, but generate them as compatibility rollups from the normalized row set.</action>
  <verify>python -m pytest research/knowledge-hub/tests/test_aitp_service.py::AITPServiceTests::test_audit_analytical_review_writes_durable_artifact_and_updates_candidate research/knowledge-hub/tests/test_aitp_service.py::AITPServiceTests::test_prepare_verification_analytical_uses_analytical_review_as_primary_bundle -q</verify>
  <acceptance_criteria>
    - `analytical_review.json` stores enriched `checks[]` rows with row-level context on every persisted check
    - top-level `source_anchors`, `assumption_refs`, `regime_note`, `reading_depth`, and summary fields still exist after the upgrade
    - `source_cross_reference` is accepted and persisted through the public analytical-review path
  </acceptance_criteria>
  <done>The durable analytical-review artifact becomes row-first without breaking current compatibility fields.</done>
</task>

<task type="auto">
  <name>Task 3: Align analytical-mode wording and keep the existing bundle path compatible</name>
  <files>research/knowledge-hub/knowledge_hub/aitp_service.py, research/knowledge-hub/tests/test_aitp_service.py, research/knowledge-hub/tests/test_aitp_cli_e2e.py</files>
  <read_first>research/knowledge-hub/knowledge_hub/aitp_service.py, research/knowledge-hub/knowledge_hub/validation_review_service.py, research/knowledge-hub/tests/test_aitp_service.py, .planning/phases/168-analytical-check-rows-and-review-contract-expansion/168-CONTEXT.md</read_first>
  <action>Update the analytical validation-mode wording in `prepare_verification(...)` so the required checks explicitly name limiting-case, dimensional-consistency, symmetry, self-consistency, and source-cross-reference artifacts. Keep `validation_review_bundle` behavior unchanged: analytical mode must still prefer `analytical_review` as the primary review kind when present. Do not add the richer runtime/read-path analytical surface in this phase; only make the minimal compatibility changes required to keep the current path green.</action>
  <verify>python -m pytest research/knowledge-hub/tests/test_aitp_service.py::AITPServiceTests::test_prepare_verification_analytical_uses_analytical_review_as_primary_bundle research/knowledge-hub/tests/test_aitp_cli_e2e.py::AITPCLIE2ETests::test_analytical_review_cli_writes_artifact_and_becomes_primary_bundle_surface -q</verify>
  <acceptance_criteria>
    - `aitp_service.py` analytical `required_checks` text names source-cross-reference alongside the existing analytical check families
    - analytical mode still chooses `analytical_review` as the primary review kind when present
    - no new standalone runtime/read-path analytical surface is introduced in Phase `168`
  </acceptance_criteria>
  <done>The richer contract lands without smuggling `168.1` runtime work into this phase.</done>
</task>

<task type="auto">
  <name>Task 4: Run the targeted analytical-review regression slice and compatibility acceptance</name>
  <files>research/knowledge-hub/tests/test_aitp_cli.py, research/knowledge-hub/tests/test_aitp_service.py, research/knowledge-hub/tests/test_aitp_cli_e2e.py, research/knowledge-hub/runtime/scripts/run_analytical_judgment_surface_acceptance.py</files>
  <read_first>.planning/phases/168-analytical-check-rows-and-review-contract-expansion/168-VALIDATION.md, research/knowledge-hub/tests/test_aitp_cli.py, research/knowledge-hub/tests/test_aitp_service.py, research/knowledge-hub/tests/test_aitp_cli_e2e.py</read_first>
  <action>Run the validation commands declared in `168-VALIDATION.md`: the CLI analytical-review slice, the focused service slice, the production-CLI analytical-review e2e path, and the existing `run_analytical_judgment_surface_acceptance.py --json` compatibility script. If any regression appears, fix only files already in scope for this plan and rerun until all declared commands are green.</action>
  <verify>python -m pytest research/knowledge-hub/tests/test_aitp_cli.py -k "analytical_review" research/knowledge-hub/tests/test_aitp_service.py::AITPServiceTests::test_audit_analytical_review_writes_durable_artifact_and_updates_candidate research/knowledge-hub/tests/test_aitp_service.py::AITPServiceTests::test_prepare_verification_analytical_uses_analytical_review_as_primary_bundle research/knowledge-hub/tests/test_aitp_cli_e2e.py::AITPCLIE2ETests::test_analytical_review_cli_writes_artifact_and_becomes_primary_bundle_surface -q</verify>
  <acceptance_criteria>
    - CLI analytical-review tests exit 0
    - service analytical-review tests exit 0
    - the analytical-review e2e path exits 0
    - `python research/knowledge-hub/runtime/scripts/run_analytical_judgment_surface_acceptance.py --json` returns `success`
  </acceptance_criteria>
  <done>The analytical check-row contract lands on a green targeted regression and compatibility baseline.</done>
</task>

</tasks>
