---
phase: 63-consultation-context-and-artifact-maturity
plan: 01
type: execute
wave: 1
depends_on:
  - 62-graph-traversal-and-retrieval-foundation
files_modified:
  - research/knowledge-hub/consultation/schemas/consult-request.schema.json
  - research/knowledge-hub/consultation/schemas/consult-result.schema.json
  - research/knowledge-hub/knowledge_hub/aitp_service.py
  - research/knowledge-hub/knowledge_hub/cli_l2_graph_handler.py
  - research/knowledge-hub/knowledge_hub/l2_consultation_support.py
  - research/knowledge-hub/tests/test_schema_contracts.py
  - research/knowledge-hub/tests/test_aitp_service.py
  - research/knowledge-hub/tests/test_aitp_cli.py
  - research/knowledge-hub/tests/test_aitp_cli_e2e.py
autonomous: true
requirements:
  - REQ-L2RET-03
  - REQ-L2RET-05
must_haves:
  truths:
    - consultation artifacts must be durable and reviewable
    - consultation must stay bounded and explicit about stage and run context
    - maintainability budgets remain binding during artifact-maturity work
---

<objective>
Make bounded `L2` consultation recordable and reviewable through production
service and CLI entrypoints.
</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/63-consultation-context-and-artifact-maturity/63-CONTEXT.md
@.planning/REQUIREMENTS.md
@research/knowledge-hub/knowledge_hub/aitp_service.py
@research/knowledge-hub/knowledge_hub/cli_l2_graph_handler.py
@research/knowledge-hub/tests/test_aitp_service.py
</context>

<tasks>

<task type="auto">
  <name>Task 1: Add failing tests for durable consultation artifacts</name>
  <files>research/knowledge-hub/tests/test_schema_contracts.py, research/knowledge-hub/tests/test_aitp_service.py, research/knowledge-hub/tests/test_aitp_cli.py, research/knowledge-hub/tests/test_aitp_cli_e2e.py</files>
  <read_first>research/knowledge-hub/tests/test_aitp_service.py, research/knowledge-hub/knowledge_hub/aitp_service.py</read_first>
  <action>Add red tests that require `consult-l2` to persist stage-aware consultation protocol files and CLI/runtime context.</action>
  <verify>python -m pytest research/knowledge-hub/tests/test_schema_contracts.py research/knowledge-hub/tests/test_aitp_service.py research/knowledge-hub/tests/test_aitp_cli.py research/knowledge-hub/tests/test_aitp_cli_e2e.py -q</verify>
  <acceptance_criteria>
    - tests fail before implementation
    - failures prove consultation context is not yet durable
  </acceptance_criteria>
  <done>A red contract exists for Phase `63`.</done>
</task>

<task type="auto">
  <name>Task 2: Implement consultation recording through production code</name>
  <files>research/knowledge-hub/knowledge_hub/aitp_service.py, research/knowledge-hub/knowledge_hub/cli_l2_graph_handler.py, research/knowledge-hub/knowledge_hub/l2_consultation_support.py</files>
  <read_first>research/knowledge-hub/knowledge_hub/aitp_service.py, research/knowledge-hub/knowledge_hub/l2_graph.py</read_first>
  <action>Reuse `_record_l2_consultation(...)`, extend `consult-l2` inputs, and write traversal-aware consultation result artifacts without breaking maintainability budgets.</action>
  <verify>python -m pytest research/knowledge-hub/tests/test_aitp_service.py research/knowledge-hub/tests/test_aitp_cli.py research/knowledge-hub/tests/test_aitp_cli_e2e.py -q</verify>
  <acceptance_criteria>
    - service can persist request/result/application/index artifacts
    - CLI can opt into recorded consultations with explicit topic/stage/run context
    - `aitp_service.py` remains under watch budget
  </acceptance_criteria>
  <done>Consultation recording lands through the real service/CLI path.</done>
</task>

<task type="auto">
  <name>Task 3: Re-run consultation-maturity regressions</name>
  <files>research/knowledge-hub/tests/test_schema_contracts.py, research/knowledge-hub/tests/test_aitp_service.py, research/knowledge-hub/tests/test_aitp_cli.py, research/knowledge-hub/tests/test_aitp_cli_e2e.py, research/knowledge-hub/tests/test_maintainability_budgets.py</files>
  <read_first>.planning/REQUIREMENTS.md</read_first>
  <action>Re-run the consultation slice and the full knowledge-hub suite before advancing to graph reports.</action>
  <verify>python -m pytest research/knowledge-hub/tests -q</verify>
  <acceptance_criteria>
    - consultation slice exits 0
    - maintainability budgets stay green
    - no full-suite regression is introduced
  </acceptance_criteria>
  <done>Phase `63` lands on a stable verified baseline.</done>
</task>

</tasks>
