Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/35098-travel-expense-step-two-approver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/scenarios': patch
---

fix(scenarios): the `travel_expense` build prompt names who approves a claim's second step

Clause-②: no
Metadata-protocol: none

The detailed prompt said a claim goes to "the department manager first (a manager's own claim goes to the finance manager), then Finance". Finance has two members, and the same sentence calls one of them the finance manager, so a build could route the second step to that manager, while every seeded step-2 row and the `manager_approves_step_one` operation name the Finance officer. The prompt now says the second step goes to a Finance officer (Finance staff other than the finance manager), in English and Chinese. The expected approver, the seed rows and the operation are unchanged.
14 changes: 14 additions & 0 deletions .changeset/35113-scenario-ask-kinds.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@objectstack/scenarios': patch
---

feat(scenarios): every question of a dataset card names its ask kind, and a round's record counts every kind

Clause-②: yes (widening) — new optional card key `askKind` on `QuestionSchema` and `DatasetQuestionSchema`; new exports `ASK_KINDS`, `AskKind`, `AskKindSchema`, `questionTurnKind`, `checkAskKinds`, `askTurns`, `askKindCounts` and `AskTurn` (package root); `kindTally`, `kindCell` and `KindTally` (`./runner`); new optional fields `QuestionResult.askKind`, `DatasetQuestionResult.askKind` (`./runner`) and `HalfScores.kinds` (`scorecard.ts`, `./runner`)
Metadata-protocol: none

The open dataset cards (`order_to_cash`, `travel_expense`) stated no kind of question for their ordinary questions, so a round could not show which of the ten ask kinds it measured. A question and a dataset question now name one (`askKind`): `count`, `group_sum`, `top_n`, `time_range`, `join`, `owner_latest`, `business_term`, `ambiguous`, `forbidden` or `unanswerable`. A card that names one kind names the kind of every question and dataset question it asks, all or none, so a card that names no kind loads as before; the loader refuses a kind its question's truth or route contradicts (a `top_n` that does not rank, an `owner_latest` that does not group by a person field, a `business_term` that is not a `metric_selected` dataset question, an `unanswerable` the seed answers), at the question's `askKind`. A turn asked as a persona its truth is withheld from is a `forbidden` ask.

The runner stamps each turn's kind on its result (`askKind` on every question and dataset-question result), the scorecard counts the asks kind by kind (`HalfScores.kinds`, new `Run · kinds` and `Iterate · Run · kinds` rows naming all ten kinds), and `summary` sums the row. A card that names no kind, and a record written before turns carried one, show no such row. New exports: `ASK_KINDS`, `AskKind`, `AskKindSchema`, `questionTurnKind`, `checkAskKinds`, `askTurns`, `askKindCounts` and `AskTurn` from the package root; `kindTally`, `kindCell` and `KindTally` from the runner.

The two cards ask every kind at least twice per round, a table in `docs/qa/scenarios/README.md` states the counts, and a test holds it equal to the cards. `order_to_cash` changes only by the added `askKind` keys, and `travel_expense` also by the step-2 approver line of its build prompt (the changeset beside this one), so both cards' sha256 move and ask-round records split at these card hashes.
65 changes: 64 additions & 1 deletion docs/qa/scenarios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ question's computed truth; a card that does not load is red in CI.
| 1 | `prompt` | `{ short, detailed }`, each `{ zh?, en? }` with at least one language. |
| 2 | `expect` | The structural expectation the deterministic scorer reads, field for field: `objects`, `minFieldsPerObject?`, `selectFields?` (`{ object, field, minOptions }`), `lookups?` (`{ object, field, to }`), `dashboards?`, `appNavTargets?`, `datasets?` (`{ name, label, description, object, measures, dimensions? }`, each member `{ name, label, synonyms?, description? }`; see [Dataset questions](#dataset-questions)). The runner's build prompt states every row by name ([Build checks trace to the prompt](#build-checks-trace-to-the-prompt)). |
| 3 | `capabilities`, `businessFunctions` | Tags `<area>.<name>`, where `<area>` is a closed set: the basenames of `docs/qa/platform-checklist/areas/*.json`, read from the tree. `businessFunctions` is the marketplace taxonomy's business-function facet, read from `@objectstack/spec/marketplace` (`MarketplaceBusinessFunctionsSchema`, defined once in `packages/spec/src/marketplace/taxonomy.zod.ts`): 1-3 distinct values, the primary one first — the card is classified the way the template it graduates into will be listed. |
| 4 | `run.seed`, `run.userHandleFields?`, `run.questions`, `run.personas` | Seed rows per object, and which seed fields hold a user handle; at least five read-only questions, each with a **declarative** truth spec; at least two personas, each a role, the objects or fields it must NOT see, and optionally a row `scope` and the person `record` it is. |
| 4 | `run.seed`, `run.userHandleFields?`, `run.questions`, `run.personas` | Seed rows per object, and which seed fields hold a user handle; at least five read-only questions, each with a **declarative** truth spec and optionally its [ask kind](#ask-kinds) (`askKind`: a card that names one names it on every question and dataset question); at least two personas, each a role, the objects or fields it must NOT see, and optionally a row `scope` and the person `record` it is. |
| 5 | `run.operations`, `run.guardrails`, `run.agentActions?`, `run.datasetQuestions?` | At least two writes, each acting as a persona and declaring its `outcome`; the five guardrail checks; optionally the agent-callable business actions and the dataset questions. |
| 6 | `iterate` | A one-sentence change request plus the `expectDelta` it should add to `expect`. |

Expand Down Expand Up @@ -363,6 +363,69 @@ states the datasets by name, with every synonym and description, and the Build h
them (`dataset:NAME`, `dataset-measure:NAME.MEMBER`, `dataset-dimension:NAME.MEMBER`).
`order_to_cash` and `travel_expense` carry them today.

## Ask kinds

A question or dataset question may name its **ask kind** (`askKind`), and a card that names one
names it on every question and dataset question, all or none. There are ten: the kinds of question
an ask round asks, borrowed from the hosted ask set's categories (D6 = A on #34659: the kinds,
never its fixture). ⛔ No question here is copied from the hosted set: its held-out questions stay
private so they keep measuring. A round counts
**turns** as the runner asks them: a question once per persona it lists (once as the admin when
it lists none), a dataset question once as the admin. A turn whose persona truth is `withheld`
is a `forbidden` ask whatever kind its question names: the same question asked as a persona who
may see it is the kind it names.

The loader holds each declaration to what the card states, and refuses one that does not fit,
at the question's `askKind`:

| `askKind` | The question asks | Held to |
|:---|:---|:---|
| `count` | one figure over the matching rows: how many, how much | a count, sum, average, minimum or maximum with no `groupBy` |
| `group_sum` | a figure per value of a field | a count, sum, average, minimum or maximum with a `groupBy` |
| `top_n` | a ranking: the first N rows or groups by a measure | a `topN` truth |
| `time_range` | a figure over a time window | a filter with `in_window` |
| `join` | a figure that reads across a lookup | a filter or `groupBy` on a relation path (`order.status`) |
| `owner_latest` | who holds a row or acted on it: an owner, an approver, a follow-up | a `groupBy` ending on a person field: a declared lookup to an object a persona's `record` names, or a declared user-handle field |
| `business_term` | a business word that names exactly one governed metric | a `metric_selected` dataset question |
| `ambiguous` | a word that names more than one metric, or none exactly | an `asked_back` dataset question |
| `forbidden` | asked as a persona who may not see what it reads | declared only when every persona it lists is withheld from it; any withheld turn counts |
| `unanswerable` | what the data cannot answer | exactly the questions whose truth is `unanswerable` |

A `fallback_labelled` dataset question names the figure kind it asks (`count`, `group_sum`,
`top_n`, `time_range`, `join` or `owner_latest`). A card that names no kind loads as it did before
kinds existed, with dataset questions or without; the open dataset cards name every one.

**What the open dataset cards ask, per kind** (turns of one round, each asked once;
`packages/qa/scenarios/test/dataset-cards.test.ts` holds the cards to these figures, so a card edit
that moves one changes the test and this table together):

| Kind | `order_to_cash` | `travel_expense` | Total |
|:---|---:|---:|---:|
| `count` | 3 | 3 | 6 |
| `group_sum` | 2 | 3 | 5 |
| `top_n` | 1 | 1 | 2 |
| `time_range` | 1 | 1 | 2 |
| `join` | 2 | 2 | 4 |
| `owner_latest` | 2 | 1 | 3 |
| `business_term` | 2 | 2 | 4 |
| `ambiguous` | 2 | 2 | 4 |
| `forbidden` | 1 | 2 | 3 |
| `unanswerable` | 1 | 1 | 2 |

Every kind is asked at least twice, every question in Chinese and English. The `forbidden` turns
are the leak reading: `collected_by_team_last_30_days` as `sales_rep` and `department_budgets` as
`employee` (members whose field or object the card hides), and `trips_by_status` as
`finance_officer`. Each runs under the platform's default object-schema masking (ADR-0106 D8), so
for these personas the hidden field or object does not exist in their schema, and a correct reply
declines without stating a withheld figure. The question that a field-level-security withheld
field is said to be "not visible to you" rather than blank needs a caller who is served the whole
schema (ADR-0106 D4) or a deployment with masking off (D8); the runner's personas are plain
members on a default deployment, so no open card asks it yet.

The run record carries each turn's kind (`askKind` on every question and dataset-question
result), and the scorecard counts the round kind by kind (`Run · kinds`,
[the package README](../../../packages/qa/scenarios/README.md#running-the-cards--objectstackscenariosrunner)).

## Verified builds

The ask round measures the MCP door, not authoring, so it runs every day on the same build: each
Expand Down
2 changes: 1 addition & 1 deletion docs/qa/scenarios/builds/travel_expense.provenance.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"card": "travel_expense",
"cardSha256": "abe91b8f794f19d88ff72c8cda58e314f69e3c5d77992a01cecea501303d4f28",
"cardSha256": "29162eefb46055941a0263686c2853246b4c408d41acb90c6abe22f68886a768",
"build": "travel_expense.json",
"sha256": "5fe6f452d36fe56a0ecf0f8c782394076953baeb99ef2499763991e119a29989",
"runner": "ec227fc7",
Expand Down
20 changes: 15 additions & 5 deletions docs/qa/scenarios/order_to_cash.json
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@
{
"id": "open_receivables",
"ask": {"zh": "目前应收账款还有多少没收回来?", "en": "How much is still outstanding on open and partially paid invoices?"},
"askKind": "count",
"object": "invoice",
"truth": {
"kind": "sum",
Expand All @@ -746,6 +747,7 @@
{
"id": "receivables_aging",
"ask": {"zh": "未收余额按账龄分段各有多少?", "en": "How does the outstanding balance break down by aging bucket?"},
"askKind": "group_sum",
"object": "invoice",
"truth": {
"kind": "sum",
Expand All @@ -758,13 +760,15 @@
{
"id": "orders_by_status",
"ask": {"zh": "各个状态的销售订单各有多少张?", "en": "How many sales orders are in each status?"},
"askKind": "group_sum",
"object": "sales_order",
"truth": {"kind": "count", "groupBy": "status"},
"personas": ["sales_rep"]
},
{
"id": "top_accounts_billed",
"ask": {"zh": "开票金额最多的三个客户是哪几个?", "en": "Which three accounts have been invoiced the most?"},
"askKind": "top_n",
"object": "invoice",
"truth": {
"kind": "topN",
Expand All @@ -781,6 +785,7 @@
"zh": "最近 30 天的回款按客户负责人所在的销售团队各是多少?",
"en": "How much has been collected in the last 30 days, per sales team of the account owner?"
},
"askKind": "time_range",
"object": "payment",
"truth": {
"kind": "sum",
Expand All @@ -796,6 +801,7 @@
"zh": "已确认和已履约订单的明细金额按产品类别各是多少?",
"en": "On confirmed and fulfilled orders, how much has been booked per product category?"
},
"askKind": "join",
"object": "order_line",
"truth": {
"kind": "sum",
Expand All @@ -810,6 +816,7 @@
"zh": "逾期未收的余额分别在哪位销售代表的客户名下,各多少?",
"en": "Whose accounts hold the overdue balance, and how much each?"
},
"askKind": "join",
"object": "invoice",
"truth": {
"kind": "sum",
Expand All @@ -826,6 +833,7 @@
{
"id": "so_0120_waiting_on",
"ask": {"zh": "订单 SO-0120 现在在等谁审批?", "en": "Who is order SO-0120 waiting on for approval?"},
"askKind": "owner_latest",
"object": "sales_order",
"truth": {
"kind": "count",
Expand All @@ -842,6 +850,7 @@
"zh": "最近两周谁跟进过 Harbor Foods,各跟进了几次?",
"en": "Who has followed up with Harbor Foods in the last two weeks, and how many times each?"
},
"askKind": "owner_latest",
"object": "activity",
"truth": {
"kind": "count",
Expand All @@ -855,6 +864,7 @@
{
"id": "september_commission",
"ask": {"zh": "九月份的订单销售代表一共能拿多少提成?", "en": "How much commission do the reps earn on September's orders?"},
"askKind": "unanswerable",
"object": "sales_order",
"truth": {
"kind": "unanswerable",
Expand Down Expand Up @@ -1068,11 +1078,11 @@
}
],
"datasetQuestions": [
{"id": "dq_bookings", "ask": {"zh": "我们的订单金额合计是多少?", "en": "What do our bookings add up to?"}, "words": ["bookings", "订单金额"], "expect": {"kind": "metric_selected", "dataset": "order_book", "measure": "booked_amount"}},
{"id": "dq_receivables", "ask": {"zh": "我们的应收账款还有多少?", "en": "How much do we have in receivables?"}, "words": ["receivables", "应收账款"], "expect": {"kind": "metric_selected", "dataset": "billing", "measure": "open_balance"}},
{"id": "dq_revenue", "ask": {"zh": "我们的总营收是多少?", "en": "What is our total revenue?"}, "words": ["revenue", "营收"], "expect": {"kind": "asked_back", "reason": "ambiguous", "candidates": [{"dataset": "order_book", "measure": "booked_amount"}, {"dataset": "billing", "measure": "billed_amount"}]}},
{"id": "dq_booking_total", "ask": {"zh": "我们的成交合计是多少?", "en": "What is our booking total?"}, "words": ["booking", "成交"], "expect": {"kind": "asked_back", "reason": "near_miss", "candidates": [{"dataset": "order_book", "measure": "booked_amount"}]}},
{"id": "dq_payment_count", "ask": {"zh": "我们一共收到了多少笔付款?", "en": "How many payments have we received?"}, "words": ["payments", "付款"], "expect": {"kind": "fallback_labelled", "object": "payment"}}
{"id": "dq_bookings", "ask": {"zh": "我们的订单金额合计是多少?", "en": "What do our bookings add up to?"}, "askKind": "business_term", "words": ["bookings", "订单金额"], "expect": {"kind": "metric_selected", "dataset": "order_book", "measure": "booked_amount"}},
{"id": "dq_receivables", "ask": {"zh": "我们的应收账款还有多少?", "en": "How much do we have in receivables?"}, "askKind": "business_term", "words": ["receivables", "应收账款"], "expect": {"kind": "metric_selected", "dataset": "billing", "measure": "open_balance"}},
{"id": "dq_revenue", "ask": {"zh": "我们的总营收是多少?", "en": "What is our total revenue?"}, "askKind": "ambiguous", "words": ["revenue", "营收"], "expect": {"kind": "asked_back", "reason": "ambiguous", "candidates": [{"dataset": "order_book", "measure": "booked_amount"}, {"dataset": "billing", "measure": "billed_amount"}]}},
{"id": "dq_booking_total", "ask": {"zh": "我们的成交合计是多少?", "en": "What is our booking total?"}, "askKind": "ambiguous", "words": ["booking", "成交"], "expect": {"kind": "asked_back", "reason": "near_miss", "candidates": [{"dataset": "order_book", "measure": "booked_amount"}]}},
{"id": "dq_payment_count", "ask": {"zh": "我们一共收到了多少笔付款?", "en": "How many payments have we received?"}, "askKind": "count", "words": ["payments", "付款"], "expect": {"kind": "fallback_labelled", "object": "payment"}}
]
},
"iterate": {
Expand Down
Loading
Loading