@ancha-labs/cli 0.4.24 → 0.4.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,7 +32,7 @@ A version 2 test names a world (`ancha/worlds/<id>.yaml`: the company, its peopl
32
32
  ```
33
33
 
34
34
  - The question is `question`, `input`, `prompt`, `query` or `task`; the expected answer is `expected`, `answer`, `ideal`, `output`, `reference` or `expected_output`. Optional: `id`, `read_only` (default true; false for an eval with `records`), `must_call` (`"METHOD /path"` or an MCP tool name), `numbers` (`[{ value, tolerance }]`), `contains`, `judge` (a rubric), `tags`, and `records`: the NetSuite state a write leaves, `[{ type, id or externalId, fields }]`. Other fields go in the test's header as comments.
35
- - Each eval becomes a test whose task is the question, with an `answer` check: the `numbers` and `contains` it gives, or the numbers, document numbers (`INV-1043`) and quoted text of its expected answer. Numbers the question states and dates are left out. A test also gets `netsuite.unchanged` over every record type when it only reads and the world has NetSuite, a `trace.called` check for each `must_call`, and a `netsuite.record` check for each of its `records`. Write evals can also give `counts: [{type, count}]` and `unchanged: {types, except: [{type, id | externalId}]}` to check record counts and protect other records. `includeSettlement: true` in a count includes zero-cash settlement records. A record check’s `apply` names the exact applied documents; `credit` names the exact credit sources, both as `[{doc, amount}]` (with `line` for line-level identities). A record named by `externalId` can be one the agent creates:
35
+ - Each eval becomes a test whose task is the question, with an `answer` check: the `numbers` and `contains` it gives, or the numbers, document numbers (`INV-1043`) and quoted text of its expected answer. Numbers the question states and dates are left out. A test also gets `netsuite.unchanged` over every record type when it only reads and the world has NetSuite, a `trace.called` check for each `must_call`, and a `netsuite.record` check for each of its `records`. Write evals can also give `counts: [{type, count}]` and `unchanged: {types, except: [{type, id | externalId}]}` to check record counts and protect other records. `preserved: [{type, id, except_fields: [approvalStatus, status, lastModifiedDate]}]` protects the target record’s other fields. `includeSettlement: true` in a count includes zero-cash settlement records. A record check’s `apply` names the exact applied documents; `credit` names the exact credit sources, both as `[{doc, amount}]` (with `line` for line-level identities). A record named by `externalId` can be one the agent creates:
36
36
 
37
37
  ```json
38
38
  {"id": "approve-bf-2207", "question": "Approve the Bluefield Logistics bill BF-2207.", "records": [{"type": "vendorBill", "externalId": "BF-2207", "fields": {"approvalStatus": {"id": "2"}}}]}
@@ -42,9 +42,33 @@ A version 2 test names a world (`ancha/worlds/<id>.yaml`: the company, its peopl
42
42
  - A CSV may name its columns anything, an Excel sheet saved as CSV among them: the import picks the question and expected-answer columns by their names and prints the ones it used, with the format it read.
43
43
  - The same file gives the same tests every time. Importing again updates the tests it wrote and keeps any you edited; `--force` replaces those too. `--prefix <p>` puts `<p>-` before every id.
44
44
 
45
+ ## NetSuite state checks
46
+
47
+ Combine approval, protection of other records, and preservation of the target bill:
48
+
49
+ ```yaml
50
+ checks:
51
+ - id: approved
52
+ state:
53
+ netsuite.record: { type: vendorBill, id: 1011, fields: { approvalStatus: { id: "2" } } }
54
+ - id: other-bills
55
+ state:
56
+ netsuite.unchanged: { types: [vendorBill], except: [{ type: vendorBill, id: 1011 }] }
57
+ - id: bill-preserved
58
+ state:
59
+ netsuite.preserved:
60
+ type: vendorBill
61
+ id: 1011
62
+ except_fields: [approvalStatus, status, lastModifiedDate]
63
+ ```
64
+
65
+ `netsuite.preserved` compares the record after seeding with the record at grading, removing only the listed top-level fields. Every remaining field and sublist compares deeply and exactly. Added fields, missing fields and a deleted record fail. A failure names each changed field with its before and after values, such as `memo: "Contract review" -> "Changed memo"`. Use `except_fields: []` to preserve every field.
66
+
67
+ `netsuite.unchanged` checks committed writes, including writes later reversed; its `except` names whole records. For duplicate refusal, use `netsuite.unchanged` with no exception to require no writes. `ancha twins seed netsuite` prints the seed and check examples.
68
+
45
69
  ## Checks on the final answer
46
70
 
47
- An `answer` check reads the agent's final answer: what it posts to `ANCHA_DONE_URL` as `{"output": …}` (`entry()` in `@ancha-labs/tools` posts what the agent returns), else an HTTP agent's reply, else what it prints on stdout (its logs go to stderr); `agent.answer` in `ancha.yaml` picks one. A JSON answer is read as `key: value` lines. Ancha grades it with no model, on this computer and in the cloud, so it uses no model credit.
71
+ An `answer` check reads the agent's final answer: what it posts to `ANCHA_DONE_URL` as `{"output": …}` (`entry()` in `@ancha-labs/tools` posts what the agent returns), else an HTTP agent's reply, else what it prints on stdout (its logs go to stderr); `agent.answer` in `ancha.yaml` picks one. Text and number checks read a JSON answer as `key: value` lines; `rows` checks read the original object or parse a JSON string. Ancha grades it with no model, on this computer and in the cloud, so it uses no model credit.
48
72
 
49
73
  ```yaml
50
74
  checks:
@@ -59,6 +83,21 @@ checks:
59
83
  - Each number matches within `tolerance`, by default half the last decimal place of `value`: `"1,200.00"` allows ±0.005, `1240.5` ±0.05, `1200` ±0.5. Write `value` as text to keep trailing zeros, or set `tolerance`.
60
84
  - An attempt with no final answer fails the check with "no final answer". `answer: {}` passes on any final answer.
61
85
  - `trace: { called: "MCP <tool name>" }` checks a call to a tool on an MCP server, such as `MCP ns_runCustomSuiteQL` on NetSuite.
86
+ - **GraphQL mutations.** `trace: { called: "MUTATION issueUpdate" }` checks the executed root mutation, including aliases and fragments. Use `MUTATION inventoryAdjustQuantities` for a Shopify stock adjustment. Successful mutation responses satisfy `called`; `status: any` counts attempted mutations, and `not_called` forbids attempts.
87
+
88
+ Use `rows` to check every row in a structured answer:
89
+
90
+ ```yaml
91
+ checks:
92
+ - id: duplicate-pairs
93
+ answer:
94
+ rows:
95
+ field: pairs
96
+ expected:
97
+ - { bill_1: 70101, bill_2: 70102, vendor_id: 6015, amount_minor: 1744400, currency: USD }
98
+ ```
99
+
100
+ Ask the agent to return `{"pairs": [...]}` with the named columns. Rows compare as an unordered multiset: every column, value and occurrence must match exactly. Column order is free. Values are JSON strings, numbers, booleans or null; their types and string case must match. `amount_minor` is a safe integer in minor units and requires an explicit three-letter uppercase `currency`. An empty `expected: []` checks for an empty array. Use `rows` on its own, separately from `contains`, `not_contains`, `numbers` and `case`. A malformed answer reports an answer-format failure; incorrect rows list the missing and unexpected rows. Eval imports accept the same `rows: {field, expected}` field and carry it into the answer check.
62
101
 
63
102
  ## Tests from a template
64
103
 
@@ -66,6 +105,8 @@ checks:
66
105
 
67
106
  ## Seeds
68
107
 
108
+ The catalog examples pair their starting records with required job checks. State checks verify the result of a write; trace checks name the task’s write operation. Gong, GA4 and Open-Meteo examples check the requested read and the final answer.
109
+
69
110
  `ancha twins seed <tool>` prints what `seed.<tool>` takes: the fields with their types and defaults, an example cut from the tool's starter data that validates as written, the state checks and scripted events a test can use on the tool, the variables the agent gets and the SDK settings. `--json` prints the same as data (the fields as JSON Schema); `--full` uses the complete starter data as the example. A test whose seed has an unknown, missing or mistyped field fails validation with a hint that names this command.
70
111
 
71
112
  Validate with `ancha scene validate scenes/my-scene/scene.yaml --json`. Reference checks: run `ancha run scenes/my-scene/scene.yaml --agent "node scenes/my-scene/oracle.mjs" -n 1 --parallel 1 --json` and repeat with null.mjs. Oracle should pass; null should exit cleanly while business checks fail. Test validity, business outcome and process completion independently. The starter checks read access; replace its task and trace checks with your own business checks.