ОРРКЕСТРАЦИЯ -Уточнить safety-policy оркестратора: останавливать loop на hard blockers и рискованных решениях, а не только по порогу 80%

This commit is contained in:
2026-04-14 08:12:12 +03:00
parent 2b48229312
commit 9048632d3e
24 changed files with 2790 additions and 36 deletions
@@ -0,0 +1,95 @@
# Domain D - Inventory Stock, Warehouse, Supplier Provenance
## Meaning
This domain covers one of the key business goals of the project:
- determine which items are currently on stock;
- understand which items form the balance on account `41.01`;
- trace the current stock back to supplier-side purchase provenance;
- continue the chain into purchase documents and later sale documents.
It should be treated as project scope, even when the current contour is not yet wired for every question.
## Question families
### Stock snapshot
- Какие товары сейчас лежат на складе
- Из каких товаров состоит остаток по 41 счету
- Какие товары числятся на 41 счете на дату ...
- Какие конкретно номенклатуры формируют остаток по складу на дату ...
### Purchase provenance
- От какого поставщика куплен товар ...
- У какого поставщика были куплены товары, которые сейчас лежат на складе
- По какому поставщику проходит текущий товарный остаток
- Когда был куплен товар ...
- По каким документам был куплен товар ...
- Какие товары от поставщика ... сейчас еще лежат на складе
- Какие товары по состоянию на дату ... были куплены у поставщика ...
### Aging and unresolved residue
- Какие остатки по товарам относятся к старым закупкам
- Какие товары сейчас висят в остатке без понятной привязки к поставщику
- Есть ли остатки товара, которые закупались очень давно
### Downstream sales trace
- Кому был продан товар ...
- Через какие документы прошел путь товара: закупка -> склад -> продажа
- Какие товары были куплены у поставщика ... и позже проданы покупателю ...
## Observed anchors
The domain pack now carries explicit observed anchors from real stock snapshots so that linked scenarios stay attached to business objects already seen in the system:
- warehouse: `Основной склад`
- organization: `ООО \Альтернатива Плюс\`
- current stock anchor: `Диван трехместный`
- historical stock anchor on `2020-03-31`: `Шкаф картотечный 1000*400*2100`
For supplier / buyer endpoints we only have candidate observed counterparties at the moment:
- supplier candidate: `Гамма-мебель, ООО`
- buyer candidate: `Департамент капитального ремонта города Москвы`
These candidate counterparties are used to keep the scenario realistic, but they must not be treated as confirmed provenance until an exact trace capability exists.
## Domain rules
- `stock snapshot` belongs to exact compute and should prefer confirmed balance routes.
- `supplier provenance` must not silently collapse multiple historical suppliers into one confirmed answer.
- If provenance is not uniquely provable, the system should surface that as unresolved or candidate provenance, not as a fabricated exact answer.
- Missing route, intent, capability, or domain bootstrap is enablement work, not out-of-scope rejection.
## Capability backlog
### Ready or near-ready
- `inventory_on_hand_as_of_date`
- `inventory_on_hand_on_account_41_as_of_date`
### Needs enablement
- `inventory_purchase_provenance_for_item`
- `inventory_purchase_documents_for_item`
- `inventory_supplier_stock_overlap_as_of_date`
- `inventory_sale_trace_for_item`
- `inventory_purchase_to_sale_chain`
## Scenario orchestration guidance
For linked user chains in this domain, prefer `run-scenario` over isolated one-off runs.
Recommended scenario state fields:
- `as_of_date`
- `organization_scope`
- `warehouse`
- `item`
- `supplier`
- `contract`
- `purchase_documents`
- `sale_documents`
- `active_result_set_id`
This domain is the reference use case for shared-session scenario capture.
The full question pool is fixed in:
- [domain_inventory_stock_supplier_trace_pack.json](/x:/1C/NDC_1C/docs/orchestration/domain_inventory_stock_supplier_trace_pack.json:1)
- [domain_inventory_stock_supplier_trace_pool.md](/x:/1C/NDC_1C/docs/orchestration/domain_inventory_stock_supplier_trace_pool.md:1)
@@ -0,0 +1,195 @@
{
"schema_version": "domain_scenario_pack_v1",
"pack_id": "inventory_stock_supplier_trace_pool",
"domain": "inventory_stock",
"title": "Inventory stock and supplier provenance question pool",
"description": "Full orchestration pack for the warehouse stock / supplier provenance domain question pool.",
"analysis_context": {
"as_of_date": "2026-04-13",
"source": "scenario_pack"
},
"bindings": {
"target_date": "2020-03-31",
"observed_warehouse": "Основной склад",
"observed_organization": "ООО \\Альтернатива Плюс\\",
"focus_item_current": "Диван трехместный",
"focus_item_historical": "Шкаф картотечный 1000*400*2100",
"observed_supplier_candidate": "Гамма-мебель, ООО",
"observed_customer_candidate": "Департамент капитального ремонта города Москвы"
},
"scenarios": [
{
"scenario_id": "inventory_snapshot_core",
"title": "Stock snapshot core",
"description": "Questions about current stock, account 41.01, and date-based snapshots.",
"steps": [
{
"step_id": "step_01_stock_now",
"title": "Current stock",
"question": "Какие товары сейчас лежат на складе",
"expected_capability": "confirmed_inventory_on_hand_as_of_date",
"expected_result_mode": "confirmed_balance"
},
{
"step_id": "step_02_account_41_now",
"title": "Account 41 composition",
"question": "Из каких товаров состоит остаток по 41 счету",
"expected_capability": "confirmed_inventory_on_hand_as_of_date",
"expected_result_mode": "confirmed_balance"
},
{
"step_id": "step_03_account_41_on_date",
"title": "Account 41 on chosen date",
"question": "Какие товары числятся на 41 счете на дату {{bindings.target_date}}",
"analysis_context": {
"as_of_date": "2020-03-31",
"source": "pack_binding_target_date"
},
"expected_capability": "confirmed_inventory_on_hand_as_of_date",
"expected_result_mode": "confirmed_balance"
},
{
"step_id": "step_04_stock_nomenclature_on_date",
"title": "Stock nomenclature on chosen date",
"question": "Какие конкретно номенклатуры формируют остаток по складу на дату {{bindings.target_date}}",
"analysis_context": {
"as_of_date": "2020-03-31",
"source": "pack_binding_target_date"
},
"expected_capability": "confirmed_inventory_on_hand_as_of_date",
"expected_result_mode": "confirmed_balance"
}
]
},
{
"scenario_id": "inventory_purchase_provenance",
"title": "Purchase provenance and supplier linkage",
"description": "Questions about suppliers, purchase dates, purchase documents, and supplier-scoped stock.",
"steps": [
{
"step_id": "step_01_stock_now",
"title": "Current stock",
"question": "Какие товары сейчас лежат на складе",
"expected_capability": "confirmed_inventory_on_hand_as_of_date",
"expected_result_mode": "confirmed_balance"
},
{
"step_id": "step_02_item_supplier",
"title": "Supplier for chosen item",
"question": "От какого поставщика куплен товар {{bindings.focus_item_current}} из текущего остатка на складе {{bindings.observed_warehouse}}",
"depends_on": ["step_01_stock_now"]
},
{
"step_id": "step_03_suppliers_for_current_stock",
"title": "Suppliers behind current stock",
"question": "У какого поставщика были куплены товары, которые сейчас лежат на складе {{bindings.observed_warehouse}} организации {{bindings.observed_organization}}",
"depends_on": ["step_01_stock_now"]
},
{
"step_id": "step_04_supplier_current_residue",
"title": "Supplier attribution of current residue",
"question": "По какому поставщику проходит текущий товарный остаток на складе {{bindings.observed_warehouse}}",
"depends_on": ["step_01_stock_now"]
},
{
"step_id": "step_05_item_purchase_date",
"title": "Purchase date for chosen item",
"question": "Когда был куплен товар {{bindings.focus_item_current}} из текущего остатка на складе {{bindings.observed_warehouse}}",
"depends_on": ["step_01_stock_now", "step_02_item_supplier"]
},
{
"step_id": "step_06_item_purchase_documents",
"title": "Purchase documents for chosen item",
"question": "По каким документам был куплен товар {{bindings.focus_item_current}} для остатка на складе {{bindings.observed_warehouse}}",
"depends_on": ["step_01_stock_now", "step_02_item_supplier"]
},
{
"step_id": "step_07_supplier_items_now",
"title": "Current stock by supplier",
"question": "Какие товары от поставщика {{bindings.observed_supplier_candidate}} сейчас еще лежат на складе {{bindings.observed_warehouse}}",
"depends_on": ["step_01_stock_now"]
},
{
"step_id": "step_08_supplier_items_on_date",
"title": "Supplier items on chosen date",
"question": "Какие товары по состоянию на дату {{bindings.target_date}} на складе {{bindings.observed_warehouse}} были куплены у поставщика {{bindings.observed_supplier_candidate}}",
"analysis_context": {
"as_of_date": "2020-03-31",
"source": "pack_binding_target_date"
}
}
]
},
{
"scenario_id": "inventory_aging_and_unresolved",
"title": "Aging and unresolved stock residue",
"description": "Questions about old purchases and stock with missing supplier linkage.",
"steps": [
{
"step_id": "step_01_stock_now",
"title": "Current stock",
"question": "Какие товары сейчас лежат на складе",
"expected_capability": "confirmed_inventory_on_hand_as_of_date",
"expected_result_mode": "confirmed_balance"
},
{
"step_id": "step_02_old_purchase_residue",
"title": "Old purchase residue",
"question": "Относится ли товар {{bindings.focus_item_historical}} в остатке на дату {{bindings.target_date}} к старым закупкам",
"depends_on": ["step_01_stock_now"],
"analysis_context": {
"as_of_date": "2020-03-31",
"source": "pack_binding_target_date"
}
},
{
"step_id": "step_03_unresolved_supplier_link",
"title": "Unresolved supplier linkage",
"question": "Есть ли на складе {{bindings.observed_warehouse}} товары с остатком без понятной привязки к поставщику",
"depends_on": ["step_01_stock_now"]
},
{
"step_id": "step_04_very_old_stock",
"title": "Very old stock",
"question": "Есть ли среди текущих остатков на складе {{bindings.observed_warehouse}} позиции, закупленные задолго до {{bindings.target_date}}",
"depends_on": ["step_01_stock_now", "step_02_old_purchase_residue"]
}
]
},
{
"scenario_id": "inventory_sale_trace",
"title": "Sale trace and purchase-to-sale chain",
"description": "Questions about buyers, sale documents, and full purchase -> stock -> sale chains.",
"steps": [
{
"step_id": "step_01_stock_on_date",
"title": "Historical stock anchor",
"question": "Какие товары числятся на 41 счете на дату {{bindings.target_date}} на складе {{bindings.observed_warehouse}}",
"analysis_context": {
"as_of_date": "2020-03-31",
"source": "pack_binding_target_date"
},
"expected_capability": "confirmed_inventory_on_hand_as_of_date",
"expected_result_mode": "confirmed_balance"
},
{
"step_id": "step_02_item_buyer",
"title": "Buyer for chosen item",
"question": "Кому был продан товар {{bindings.focus_item_historical}}",
"depends_on": ["step_01_stock_on_date"]
},
{
"step_id": "step_03_item_purchase_stock_sale_chain",
"title": "Full document chain for chosen item",
"question": "Через какие документы прошел путь товара {{bindings.focus_item_historical}}: закупка -> склад -> продажа",
"depends_on": ["step_01_stock_on_date", "step_02_item_buyer"]
},
{
"step_id": "step_04_supplier_to_buyer_chain",
"title": "Supplier to buyer overlap",
"question": "Есть ли документально подтвержденная цепочка: поставщик {{bindings.observed_supplier_candidate}} -> товар {{bindings.focus_item_historical}} -> покупатель {{bindings.observed_customer_candidate}}"
}
]
}
]
}
@@ -0,0 +1,73 @@
# Inventory Question Pool - Orchestration Map
## Purpose
This file fixes the full user question pool for the warehouse stock / supplier provenance domain in orchestration format.
The runnable pack is:
- [domain_inventory_stock_supplier_trace_pack.json](/x:/1C/NDC_1C/docs/orchestration/domain_inventory_stock_supplier_trace_pack.json:1)
## Scenario map
## Observed anchors
These anchors are taken from the live stock snapshots already captured by the orchestration run and are used to keep provenance / trace scenarios grounded in real observed objects:
- warehouse: `Основной склад`
- organization: `ООО \Альтернатива Плюс\`
- current focus item: `Диван трехместный`
- historical focus item on `2020-03-31`: `Шкаф картотечный 1000*400*2100`
- supplier candidate from observed counterparty artifacts: `Гамма-мебель, ООО`
- customer candidate from observed counterparty artifacts: `Департамент капитального ремонта города Москвы`
The supplier/customer anchors above are still `candidate` observations, not confirmed purchase-to-sale truth.
### Scenario 1 - `inventory_snapshot_core`
- Какие товары сейчас лежат на складе
- Из каких товаров состоит остаток по 41 счету
- Какие товары числятся на 41 счете на дату ...
- Какие конкретно номенклатуры формируют остаток по складу на дату ...
### Scenario 2 - `inventory_purchase_provenance`
- От какого поставщика куплен товар ...
- У какого поставщика были куплены товары, которые сейчас лежат на складе
- По какому поставщику проходит текущий товарный остаток
- Когда был куплен товар ...
- По каким документам был куплен товар ...
- Какие товары от поставщика ... сейчас еще лежат на складе
- Какие товары по состоянию на дату ... были куплены у поставщика ...
### Scenario 3 - `inventory_aging_and_unresolved`
- Какие остатки по товарам относятся к старым закупкам
- Какие товары сейчас висят в остатке без понятной привязки к поставщику
- Есть ли остатки товара, которые закупались очень давно
### Scenario 4 - `inventory_sale_trace`
- Кому был продан товар ...
- Через какие документы прошел путь товара: закупка -> склад -> продажа
- Какие товары были куплены у поставщика ... и позже проданы покупателю ...
This scenario is now anchored to the observed historical item `Шкаф картотечный 1000*400*2100` rather than to an arbitrary item from the current stock list.
## Current readiness
### Exact now
- stock snapshot questions on current date or chosen date
- account `41.01` stock composition and nomenclature snapshot
### Partial now
- some document-oriented questions can route into existing `documents_drilldown`, but this is not yet a true item purchase provenance chain
### Needs exact capability
- supplier attribution for current residue
- supplier-scoped current stock overlap
- purchase provenance date / supplier trace for one item
- old purchase aging over current residue
- unresolved supplier linkage over current stock
- downstream sale trace and purchase -> stock -> sale chain
## Operational rule
This pool is not treated as out-of-scope.
Every unresolved question in this pack is domain enablement work inside the project contour.
@@ -0,0 +1,80 @@
# Domain Scenario Loop - Repo Adapter
## Purpose
This repository now supports two outer-loop capture modes:
- `run-case` for one concrete domain question;
- `run-scenario` for a linked multi-step domain chain that should reuse one assistant session.
- `run-pack` for a whole domain question pool grouped into several scenarios.
- `run-pack-loop` for an autonomous analyst/coder loop over a whole domain pack.
`run-scenario` is the preferred capture mode for domains where the user's next question depends on the previous result set.
`run-pack` is the preferred capture mode when the user brings a full domain pool that should be kept in one aggregate backlog.
## Runtime contract
The scenario runner does not introduce a new product runtime.
It reuses:
- `POST /api/assistant/message`
- `GET /api/assistant/session/:session_id`
- current backend LLM/profile configuration
- current address/deep routing inside the product
## Artifact contract
Scenario artifacts live under:
`artifacts/domain_runs/<scenario_id>/`
Top-level artifacts:
- `scenario_brief.md`
- `scenario_manifest.json`
- `scenario_state.json`
- `scenario_summary.md`
- `scenario_output.md`
- `final_status.md`
Per-step artifacts:
- `steps/<step_id>/output.md`
- `steps/<step_id>/debug.json`
- `steps/<step_id>/turn.json`
- `steps/<step_id>/session.json`
- `steps/<step_id>/assistant_response.json`
- `steps/<step_id>/step_state.json`
Pack artifacts live under:
`artifacts/domain_runs/<pack_id>/`
- `pack_manifest.json`
- `pack_state.json`
- `pack_summary.md`
- `final_status.md`
- `scenarios/<scenario_id>/...`
## Placeholder contract
Scenario questions can reference earlier step outputs with placeholders such as:
- `{{step_01_inventory.entries[0].item}}`
- `{{semantic_memory.active_result_set_id}}`
This keeps carryover explicit and machine-readable.
## Status contract
Scenario capture uses four operational statuses:
- `accepted`
- `partial`
- `blocked`
- `needs_exact_capability`
`partial` means the scenario executed, but one or more steps still need route hardening, evidence hardening, or presentation hardening.
`needs_exact_capability` means the scenario is valid for the project, but the current contour still lacks the exact route or capability needed to answer it.
In autonomous pack-loop mode, `partial` and `needs_exact_capability` are non-terminal by default. The loop should continue domain enablement work until one of these happens:
- analyst quality reaches the configured acceptance gate, normally `>= 80`;
- the analyst marks `requires_user_decision = true` because the next step would otherwise require guessing a missing required observation, making an architecture-risky change, accepting a hacky/brittle workaround, or choosing a business-critical tradeoff without enough evidence;
- the runtime is truly blocked;
- the loop reaches `max_iterations`.
@@ -0,0 +1,92 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Domain Loop Analyst Verdict",
"type": "object",
"additionalProperties": false,
"required": [
"summary",
"quality_score",
"loop_decision",
"requires_user_decision",
"user_decision_type",
"user_decision_prompt",
"unresolved_p0_count",
"regression_detected",
"priority_targets",
"acceptance_criteria",
"notes"
],
"properties": {
"summary": {
"type": "string"
},
"quality_score": {
"type": "integer",
"minimum": 0,
"maximum": 100
},
"loop_decision": {
"type": "string",
"enum": ["accepted", "continue", "partial", "blocked", "needs_exact_capability"]
},
"requires_user_decision": {
"type": "boolean",
"description": "Set true only when the autonomous loop must stop and ask the user because the next step is an architecture fork, important business question, scope tradeoff, or another non-autonomous decision."
},
"user_decision_type": {
"type": "string",
"enum": ["none", "architecture_fork", "important_business_question", "scope_tradeoff", "data_truth_gap", "missing_required_observation", "risky_workaround", "risky_complexity", "other"],
"description": "Explain why the loop needs user input. Use none when requires_user_decision is false."
},
"user_decision_prompt": {
"type": ["string", "null"],
"description": "Short user-facing question to unblock the loop when requires_user_decision is true, otherwise null."
},
"unresolved_p0_count": {
"type": "integer",
"minimum": 0
},
"regression_detected": {
"type": "boolean"
},
"priority_targets": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["scenario_id", "step_id", "severity", "problem_type", "fix_goal"],
"properties": {
"scenario_id": {
"type": "string"
},
"step_id": {
"type": ["string", "null"]
},
"severity": {
"type": "string",
"enum": ["P0", "P1", "P2"]
},
"problem_type": {
"type": "string",
"enum": ["route_gap", "capability_gap", "evidence_gap", "presentation_gap", "regression", "other"]
},
"fix_goal": {
"type": "string"
}
}
}
},
"acceptance_criteria": {
"type": "array",
"items": {
"type": "string"
}
},
"notes": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
@@ -0,0 +1,37 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Domain Loop Coder Result",
"type": "object",
"additionalProperties": false,
"required": [
"status",
"summary",
"changed_files",
"notes",
"patch_summary_path"
],
"properties": {
"status": {
"type": "string",
"enum": ["patched", "no_changes", "blocked"]
},
"summary": {
"type": "string"
},
"changed_files": {
"type": "array",
"items": {
"type": "string"
}
},
"notes": {
"type": "array",
"items": {
"type": "string"
}
},
"patch_summary_path": {
"type": ["string", "null"]
}
}
}