ARCH: добавить value-flow pilot MCP discovery

This commit is contained in:
2026-04-20 18:15:26 +03:00
parent e85d456576
commit 49fd08652c
21 changed files with 1100 additions and 66 deletions
@@ -1091,6 +1091,69 @@ Validation:
- `npm run build` passed;
- `python scripts/domain_truth_harness.py run-live --spec docs/orchestration/address_truth_harness_phase19_mcp_discovery_response_gate.json --output-dir artifacts/domain_runs/address_truth_harness_phase19_mcp_discovery_response_gate_live_rerun3 --timeout-seconds 180` passed 4/4, final status `accepted`.
## Progress Update - 2026-04-20 MCP Discovery Value-Flow Pilot And Deep Response Gate
The sixteenth implementation slice of Big Block 5 extends guarded MCP discovery from lifecycle evidence to the first bounded value-flow evidence path:
- `assistantMcpDiscoveryTurnInputAdapter.ts`
- `assistantMcpDiscoveryPilotExecutor.ts`
- `assistantMcpDiscoveryAnswerAdapter.ts`
- `assistantMcpDiscoveryResponseCandidate.ts`
- `assistantMcpDiscoveryResponsePolicy.ts`
- `assistantDeepTurnResponseRuntimeAdapter.ts`
- `address_truth_harness_phase19_mcp_discovery_response_gate.json`
The new path is deliberately narrow.
It does not turn the assistant into a free-form autonomous 1C agent yet. It adds a guarded pilot for counterparty value-flow questions when the exact route does not own the current turn:
- raw Russian/English value-flow signals such as `денежный поток`, `оборот`, `выручка`, `оплата`, `turnover`, and `revenue`;
- Cyrillic-safe signal detection instead of JavaScript `\w` assumptions;
- organization-shaped targets can be reinterpreted as counterparty candidates for this contour when no explicit counterparty was extracted;
- the planner may choose value-flow primitives, but the pilot executes only the guarded `query_movements` branch through the existing `customer_revenue_and_payments` recipe;
- the pilot derives `derived_value_flow` from confirmed movement rows: counterparty, period scope, matched rows, rows with amount, total amount, first movement date, latest movement date, and `inference_basis=sum_of_confirmed_1c_value_flow_rows`;
- the user-facing answer says what was found, what was calculated, and what is not proven outside the checked period;
- internal terms such as primitive names, query ids, runtime/planner/catalog mechanics, and `pilot_` reason codes are filtered from the final answer.
The deep response adapter now preserves the MCP discovery entry point in deep runtime meta and can replace a bad deep/partial answer with a guarded discovery candidate only when:
- the entry point is `bridge_executed`;
- discovery was attempted;
- `turn_input.should_run_discovery=true`;
- the current reply source is `deep_analysis`, `partial_coverage`, or `normalizer_v2_0_2`;
- the response candidate passes the same guarded text checks as the living-chat gate.
Live replay finding:
- `address_truth_harness_phase19_mcp_discovery_response_gate_live_rerun4` failed after adding the value-flow question because the visible answer still came from the deep partial path and drifted into unrelated store/asset/amortization wording;
- after preserving the discovery entry point for deep packaging and allowing the guarded deep candidate, `address_truth_harness_phase19_mcp_discovery_response_gate_live_rerun5` passed 5/5;
- after the punctuation cleanup, `address_truth_harness_phase19_mcp_discovery_response_gate_live_rerun6` also passed 5/5, final status `accepted`.
The value-flow replay answer for `какой денежный поток был у Группа СВК за 2020 год?` now states:
- found 1C money-movement rows for `Группа СВК`;
- period: `2020`;
- calculated sum: `47 628 853,03 руб.`;
- rows with amount: `44 из 44`;
- first movement date: `2020-01-09`;
- latest movement date: `2020-12-30`;
- full turnover outside the checked period is not confirmed by this search.
Validation:
- `npm test -- assistantMcpDiscoveryTurnInputAdapter.test.ts assistantMcpDiscoveryPilotExecutor.test.ts assistantMcpDiscoveryAnswerAdapter.test.ts assistantMcpDiscoveryResponseCandidate.test.ts assistantMcpDiscoveryResponsePolicy.test.ts assistantDeepTurnResponseRuntimeAdapter.test.ts assistantMcpDiscoveryRuntimeEntryPoint.test.ts assistantMcpDiscoveryRuntimeBridge.test.ts` passed 37/37;
- `npm run build` passed;
- `python scripts/domain_truth_harness.py run-live --spec docs/orchestration/address_truth_harness_phase19_mcp_discovery_response_gate.json --output-dir artifacts/domain_runs/address_truth_harness_phase19_mcp_discovery_response_gate_live_rerun6 --timeout-seconds 180` passed 5/5, final status `accepted`;
- step-level human answer review confirmed no `query_documents`, `query_movements`, `runtime_`, `planner_`, `catalog_`, `primitive`, or `pilot_` leak in lifecycle/value-flow user-facing answers.
Known remaining boundary:
- this slice covers incoming customer value-flow through `customer_revenue_and_payments`; supplier payouts, bidirectional money flow, arbitrary cross-register discovery, and multi-axis aggregation are still future MCP semantic discovery work.
Module progress:
- Big Block 5 MCP Semantic Data Agent: `97%`.
## Execution Rule
Do not implement this plan as: