Skip to content

Teach the native agent to author plays: a Play Authoring skill and typed get_play / update_play tools - #3551

Merged
malibio merged 4 commits into
mainfrom
issue-3519-play-authoring-skill
Oct 4, 2026
Merged

malibio merged 4 commits into
mainfrom
issue-3519-play-authoring-skill

Conversation

@malibio

@malibio malibio commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

Closes #3519. Implements ADR-090 §6.

What changed

  • get_play (seeded tool-native): takes a play id and returns the typed play (rules with their descriptions, enabled, the engine's suspension when there is one) plus schemas: the fields and relationships of every type the rules reference. A play whose stored rules no longer decode is still returned, with rules_error.
  • update_play (seeded tool-native): takes a play id and any of rules (whole), description, enabled. It decodes the rest of the call as the typed PlayNodeUpdate and writes through update_play_node, so a call naming lifecycle_status, a suspension field or anything else is refused whole. A rejected write is a tool result the model can repair from: it names the rule, the component and its index, and for a path the name that is wrong. Its parameter schema states the rule shape, descriptions included.
  • Play Authoring skill: a built-in seeded skill with a fixed UUID, linked applies_to → play on every open (link_seeded_skills). Its body is plain Markdown and holds procedure only: find, read first, check names against the schemas, say what will change and ask, write the list whole, repair a rejection, on/off. Steps that name how they are done are rule fragments with a form per audience, and the two description rules are the fragments the shipped command reference already renders.
  • playbook::referenced_types (core): the types a play's rules reference, through its selectors (and their filters), condition paths, for_each paths, {binding} paths and the types its actions create or retype to.

Tests

  • Agent turns over the real tools and a real store, routed to the seeded skill and held to play: a turn that changes a condition writes rules with updated descriptions; a turn whose first write is rejected for a stale description repairs it and succeeds; "turn this play off" sets enabled = false.
  • Tool tests (tests/it/play_tools.rs): the typed play and its schemas, the suspension, non-play ids, each rejection (stale description, broken path, bare condition, missing description) naming what to fix and writing nothing, the switch, the refusal of lifecycle and suspension fields, and the seeded skill's link (made once across repeated opens).
  • Prompt goldens: the two skill-name lists gain Play Authoring, and a new stage2_play_authoring golden pins the skill's candidate block and its held tool surface, update_play's rule shape included.
  • Live retrieval guards (embedding model): play-change and on/off requests reach Play Authoring; "why hasn't it fired" still reaches Play Workflow State.

Retrieval and evals

With the new skill seeded, all 24 existing live_skill_retrieval_stability guards pass on the locked embedding model, so no existing skill lost a place it is guarded on. The routing and decisions eval results (main vs this branch) are posted in a comment below.

Notes for review

  • update_play is in SINGLE_OWNER_BY_DESIGN: like create_schema, rule authoring is its own intent with its own guidance, and no other skill is a plausible second home.
  • bun run test:changed currently stops at node-types:check on this machine because the shared docs checkout's node-types.md lists a cli_command field on tool-native that the schema does not declare. This PR changes no node type; the Rust tiers were run directly (4,658 passed) along with skill:check.

🤖 Generated with Claude Code

@malibio

malibio commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #3551

Review Type

Initial review (no prior reviews). Reviewed by reading commit f0adb70 against origin/main, the issue, ADR-090 §6 and ADR-064. Nothing was built or run: the machine is busy with release builds, so every statement below comes from the code and the tests as written.

Summary

A net improvement, and a well-scoped one. The tools write only through the typed PlayNodeUpdate (which is deny_unknown_fields), so the lifecycle and the suspension fields are refused by decoding rather than by a hand-kept deny list. The rule shape lives on the update_play parameter schema, the skill body is procedure, and every registry classification for the two new tools is stated in the exhaustive matches. No Critical issues. Four improvements, none of which blocks the merge on its own.

Legend: ✅ met, ⚠️ met with a gap, ⏳ pending or not verified here. 🔴 Critical, 🟡 Important, 🟢 Suggestion.

Requirements Check

# Acceptance criterion Status Notes
1 Skill seeded with a fixed UUID and a Markdown body, linked applies_to → play ✅ Row in SKILL_SEEDS (id 3e9a7c14-…7c0c), body in seeds/skills/play-authoring.md, link_seeded_skills called from seed_agent_nodes. linked_schemas in skill_ops.rs keeps core schemas, so the link does reach schemas_linked in production. the_play_authoring_skill_is_seeded_and_linked_to_the_play_schema runs the seed and the link twice.
2 get_play / update_play are seeded tool-native tools with handlers; schemas state the argument shape ✅ Both in Tool::ALL with fixed ids, definitions and handlers. The rule shape is on the update_play schema and matches nodespace_types::play (trigger tag type, on values, class values, action types). The one restatement in prose is the shared play-rule-descriptions fragment, which the issue asks to share. See the first nit for an untested example.
3 get_play returns the typed play plus the schema metadata of every referenced type ⚠️ True for trigger types, selector filter hops, top-level condition paths, for_each paths, bindings and action-named types. Not true for types reached only inside a comprehension body or a .where(...) predicate (finding 2), and misleading for a play whose rules do not decode (finding 1).
4 update_play: typed update only; errors name rule, component, index, field; enabled works; never writes lifecycle or suspension ✅ exec_update_play removes id and decodes the rest as PlayNodeUpdate; a refused call writes nothing (version asserted unchanged). See finding 3 on how the index is spelled.
5 Agent tests: condition change, rejected-then-repaired write, "turn this play off" ✅ Three turn tests over the real GraphToolExecutor and a real store, each asserting the stored play. The nits say what they do not cover.
6 Prompt golden updated and reviewed ✅ Two name lists gain Play Authoring; new stage2_play_authoring.golden pins the candidate block and the held tool surface. I read the golden: search_nodes.node_type is held to ["play"] and the offered tools are the four the skill whitelists.
7 Routing and decisions evals don't regress; results in the PR ⏳ In progress by the author; not a defect. Finding 4 is one thing for that run to answer.
8 quality:fix clean; test:changed passes ⏳ Not run here. The PR body reports test:changed stopping at node-types:check because of an unrelated drift in the shared docs checkout (cli_command on tool-native), with the Rust tiers run directly. This PR changes no node type, so that reading is plausible, but the merge gate reads the docs remote and will decide.

Code Review Findings

Critical Issues

None.

Suggested Improvements

1. 🟡 A play whose rules do not decode is reported as having no rules
📁 packages/agent/src/local_agent/tools.rs:652-681 (play_value)

When PlayFields::from_properties fails, play_value falls back to readable_from_properties, whose rules is unwrap_or_default(). The result is "rules": [] beside rules_error. The doc comment calls this the play "an agent is most likely asked to repair", but the agent is given nothing to repair from: the stored rules are not in the result, and rules_error names only the first rule that failed.

Failure scenario: a play synced or imported through the unchecked path holds three rules, one of which no longer decodes. get_play returns rules: []. The skill tells the model the result holds "the rules exactly as they are stored" and that "a rule left out is deleted". The model writes the one rule it was asked for, the write succeeds, and the two good rules are gone without anyone having seen them.

Two smaller points in the same function: from_properties also fails for a non-rules field (an unknown suspended_reason, a description of the wrong type), and that message is reported under rules_error too; and no test in play_tools.rs or anywhere else reaches this branch.

Recommendation: when decoding fails, don't emit an empty rules. Return the raw stored value (for example as stored_rules) with the error, name the error key for what it is, and add a test with a play stored through update_node_unchecked.
Principle: ADR-064 rule 4, a tool result is a fact. An empty list here states something false, and the next write acts on it.

2. 🟡 referenced_types skips types reached inside a comprehension or a .where(...) predicate
📁 packages/core/src/playbook/referenced_types.rs:36-49 (conditions) and :55-67 (for_each)

The condition loop walks extraction.paths and each collection path, but never CollectionPath::item_paths, which is where path_extractor puts every path rooted at the iteration variable. For for_each, the text inside where(...) is tokenised, but its paths are bare item fields with no trigger.node. or item. prefix, so binding_paths drops them.

Failure scenario: a rule on epic with the condition node.stories.all(s, s.assignee.active). story is added (the collection); person is not. On a turn held to play the model can't search for the schema it is missing, which is the case this function exists for.

Recommendation: resolve the collection's item type with declared_collection_type (already used for for_each) and walk item_paths from it; do the same for the free variables of a .where(...) predicate. Add one test per case next to for_each_items_and_reverse_names_are_followed.
Principle: the acceptance criterion says every type the conditions and actions reference; the tests cover only top-level paths.

3. 🟡 Rejections spell the same position three ways, zero-based and one-based
📁 packages/agent/tests/it/play_tools.rs:253-276 (the expectations pin all three); sources in packages/core/src/playbook/validation.rs and packages/nodespace-types/src/play.rs:661-684 (decode_rule_list)

A condition's position is named as rule `close epic`, condition 2 (stale description: one-based, by name), rule[0].condition[0] (path validation: zero-based, by index) and rule[0] ('close epic'): conditions[1] (decode: zero-based). Validation errors are joined with ; , so one result can carry both bases. The skill body tells the model the error names "that part's number", and its only worked example is the one-based form.

Failure scenario: a write with a broken path in the first condition and a stale description on the second returns rule[0].condition[0]: …; rule `close epic`, condition 2: …. A model that reads condition[0] with the one-based rule it was just taught edits nothing, or the wrong condition, and spends a repair iteration out of a budget of five.

Recommendation: pick one spelling (the ADR-090 §1 form: rule name plus one-based component number) and use it in PlayValidationError::location() and in decode_rule_list. The formats predate this PR, but this PR is what makes them a model-facing repair protocol, so it is cheapest to settle here.
Principle: ADR-056, the validation errors carry the repair loop; a protocol with two index bases is not one a small model follows reliably.

4. 🟡 Play Authoring leads a diagnostic question; consider an exclusion
📁 packages/agent/tests/it/live_skill_retrieval_stability.rs:1383-1396 (the control's comment); packages/agent/src/skill_pipeline.rs:497-528 (the Play Authoring row, exclusion: None)

The control's comment records that "why didn't the play trigger for that story?" now ranks Play Authoring first, 0.887 to 0.863, and the control was written as top-3 rather than rank 1 to accommodate that. The reasoning given (the read tool is still offered, and the turn stays open) is correct as far as it goes, but that turn now shows the model a write-capable skill as candidate 1 for a question that asks for no change, with update_play on its surface.

Recommendation: let the pending decisions eval answer whether that turn ever writes. If the margin matters, the seed table already has the mechanism for exactly this overlap: an exclusion on Play Authoring along the lines of "Why a rule has not fired, what is still missing before it runs", with a control like graph_editing_exclusion_leaves_completion_state_scores_unchanged. That keeps the description as the retrieval key and doesn't tune it to one sentence.
Principle: ADR-064 rule 3, a new skill competes with every other; a negation can't go in a description because an embedding has none.

Nitpicks

  • Nit: 🟢 packages/agent/src/local_agent/tools.rs (def_update_play, the cron description). The only cron example the model is given is a six-field form (0 0 9 * * *). Every cron in the repository's tests and seeds has seven fields, and a test comment in validation.rs says the engine requires seven. The six-field form is only ever decoded in this PR (an_unresolved_reference_contributes_nothing), never validated. Add one test that sends the schema's example through update_play, so the text the model copies is known to save.
  • Nit: 🟢 same schema, select. It says query_id is "for a scheduled trigger", but Selector accepts a saved query on either trigger, and inline filters are not mentioned. A play read through get_play can carry both and the model is told to copy them back exactly, so this only limits what it authors on its own. Likewise params omits node_type on update_node and edge_data on add_relationship.
  • Nit: 🟢 packages/agent/src/local_agent/agent_loop.rs:18884-18898 (PlayAuthoringExecutor::candidate). The turn tests hand-build the candidate with schemas_linked: true and a stub schema_metadata, so "held to plays" is true by construction. The pieces are each tested (the edge in play_tools.rs, linked core schemas in core), but nothing runs the seeded skill through find_skills and asserts schemas_linked with the play schema. One assertion in an existing embedding-backed test would close it.
  • Nit: 🟢 the three turn tests script the model, so they prove the tools and the hold, not the guidance. The first goes from get_play straight to update_play, skipping the ask the skill requires. That is fine for this criterion; the decisions eval is where the ask-first step gets measured, and one scenario there would be worth having.
  • Nit: 🟢 packages/agent/src/local_agent/tools.rs (fetch_play). CoreNodeType::Play.is_exactly refuses a subtype of play, while record_play_suspension uses type_is_a. It matches the write path today (update_typed_fields compares exactly), so nothing is broken; a one-line comment saying a subtype is refused on purpose would save the next reader the check.
  • Nit: 🟢 packages/agent/src/skill_pipeline.rs:620-645 (link_seeded_skills). The first failed create_relationship returns and skips the remaining rows. With one linked skill it can't matter; when a second is added, log and continue instead.
  • Nit: 🟢 GetPlayParams and exec_update_play both accept play_id as an undeclared alias for id. Harmless, but it is argument shape the schema doesn't state; if both keys are sent, update_play reports an unknown field play_id.

What is done well

  • Refusing lifecycle and suspension writes by decoding the typed update, and testing that a refused call leaves the version unchanged, is the right shape: there is no list to forget to extend.
  • update_play returns validation failures as tool results rather than failed calls, so the repair loop needs no special handling in the agent loop.
  • get_play builds its schemas from EntityTypeDescriptor::from_corpus, the same descriptor the candidate block uses, so a type reads the same wherever the model meets it.
  • The retrieval guards come with a control, and the control states what was measured, including the number that doesn't flatter the change.

Recommendation: APPROVE

No blockers. Findings 1 to 3 are worth folding into this PR, since each is small and same-shaped with what it already touches; finding 4 should be answered by the eval run still pending for criterion 7. Criterion 8 is for the merge gate to confirm.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@malibio

malibio commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

Review addressed (21fec9a)

Addressed

  1. Undecodable rules reported as an empty list — fixed. get_play now returns rules that fail to decode as stored, under stored_rules, with decode_error (renamed from rules_error, since another field can be what failed), and emits no rules key in that case. Test: get_play_hands_over_rules_that_do_not_decode_as_stored.
  2. referenced_types skipped a collection's item paths — fixed. Paths in a comprehension's body and in a .where(...) predicate are followed from the collection's item type. Test: paths_read_from_a_collections_items_are_followed.
  3. Play Authoring led a diagnostic question — fixed with an exclusion, as suggested. Measured on the locked embedding model: Play Workflow State now leads all four "why hasn't it fired" questions (Play Authoring drops out of the top 6 on three of them), and all eight change/switch requests still lead with Play Authoring. One measured cost: "make that rule fire only for high priority tasks" 0.883 → 0.838, still first. Both guards now assert rank 1, and all 26 live_skill_retrieval_stability tests pass.
  • Nits: the schema's cron example is now sent through update_play in a test (six fields is accepted); params lists node_type and edge_data; the seeded link is asserted through find_skills (schemas_linked, play); fetch_play says why it matches exactly; link_seeded_skills logs a failed link and carries on; the undeclared play_id alias is removed.

Partly addressed

  1. Two spellings of a position in rejections — the repair guidance now states both ("rule x, condition 2", counted from one; "rule[0].condition[1]", counted from zero) with an example of each. The error strings themselves are unchanged: PlayValidationError::location() is what the engine fingerprints suspensions on and what several thousand lines of validation tests assert, so unifying it is a wider change than this PR.

Not changed

  • select on the tool schema still says a saved query is for a scheduled trigger: a graph-event selector must be a bare type (test_graph_event_selector_must_be_a_bare_type), so that is accurate.
  • The scripted turn tests go from get_play straight to update_play; the ask-first step is guidance for a live model, not something a scripted model can prove.

Tests: 4,257 Rust tests pass across agent, core and daemon; rust:quality clean. Routing and decisions eval results to follow.

@malibio

malibio commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #3551

Review Type: Re-Review

Reviewed git diff f0adb70c..21fec9a5 (8 files, +270 −33) against the prior review, the author's response, issue #3519 and ADR-090 §6. Nothing was built or run (a release build holds this worktree, and the live retrieval tests are #[ignore] and need the embedding model), so every statement below comes from reading the code and tracing inputs through it. The retrieval scores quoted are the author's measurements; I could not reproduce them.

Legend: ✅ met, ⚠️ met with a gap, ⏳ pending. 🔴 Critical, 🟡 Important, 🟢 Suggestion.

Previous Review Summary

Count
Previous recommendations 11 (4 findings, 7 nits)
Addressed 8 (findings 1, 2, 4; five nits)
Partly addressed, justification sound 2 (finding 3; the select / params nit)
Declined, justification sound 1 (scripted turn tests skip the ask-first step)
Not addressed 0
New issues found 1 🟡, 2 🟢, 1 nit

Finding 1 (undecodable rules reported as []): addressed. play_value (packages/agent/src/local_agent/tools.rs:668-676) now emits the raw stored value under stored_rules, no rules key, and the error under decode_error. Traced:

  • three stored rules, one that no longer decodes: decode_rules fails as a whole, readable_from_properties gives an empty list, and the whole stored array is returned, so the two good rules are visible;
  • rules decode but another field doesn't (an unknown suspended_reason): fields.rules is non-empty, so rules is emitted as before, with decode_error naming the other field;
  • stored rules is null or absent: stored_field returns None, so rules: [], which is true.

The repair write is not blocked by the broken stored rules: validate_play_rules skips the stale-description comparison when the stored rules don't parse (crud.rs:2636-2638). One corner is left; see new finding 3.

Finding 2 (referenced_types skipped item paths): addressed for the cases named. Traced both new test inputs through the code:

  • node.stories.all(s, s.retro.summary != ''): the collection resolves epic → story, then the item path [s, retro, summary] is walked from story without its root and adds retro.
  • trigger.node.stories.where(retro.summary != ''): parse_where_chain gives base trigger.node.stories and one predicate; the base resolves to story; extract_paths gives [retro, summary], walked from story.

Both produce ["epic", "story", "retro"] in that order, as asserted. Chained .where(a).where(b), a .where inside a function-call binding (count(trigger.node.x.where(...))) and an item.-rooted base are handled by collect_where_chains and the (["item", rest @ ..], Some(item_type)) arm. A malformed chain is dropped by .flatten(), which matches the module's rule that an unresolved reference contributes nothing. Nested forms are still skipped; see new finding 2.

Finding 3 (two index bases in rejections): partly addressed, and the reason holds. The error strings are unchanged. PlayValidationError::location() is documented at validation.rs:404-411 as part of the identity the engine's sync_play uses for suspensions, and it has 17 format sites, so changing it is a wider change than this PR. The guidance (seeds/skills/play-authoring.md:17, regenerated into the golden) now gives both spellings with an example of each, and both examples match what the code emits (rule[{}].condition[{}]; the one-based form by name). The decode form (rule[0] ('close epic'): conditions[1]) is a third spelling, but it is zero-based and reads as the second one. Acceptable.

Finding 4 (Play Authoring led a diagnostic question): addressed with the mechanism suggested, and both live guards now assert rank 1. See new finding 1 for what the measured cost implies.

Nits.

  • Cron example: ✅ the_cron_example_on_the_tool_schema_saves reads the example out of the schema and sends it through update_play.
  • params: ✅ lists node_type and edge_data; the golden matches. select: the author is right and my earlier nit was wrong. A graph-event selector must be a bare type (playbook/tests.rs:186), so "a saved query is for a scheduled trigger" is accurate.
  • Seeded link through find_skills: ✅ asserts schemas_linked and schema_metadata of ["play"] after link_seeded_skills.
  • fetch_play comment: ✅.
  • link_seeded_skills: ✅ logs and carries on. the_play_authoring_skill_is_seeded_and_linked_to_the_play_schema still asserts the edge itself, so a link that silently fails is still caught in tests.
  • play_id alias: ✅ removed from both tools.
  • Scripted tests skipping the ask: declined, reasonably. A scripted model can't prove guidance; the decisions eval is where that is measured.

Requirements Check

# Acceptance criterion Status Notes
1 Skill seeded, fixed UUID, Markdown body, linked applies_to → play ✅ Unchanged; the link is now also asserted through find_skills.
2 get_play / update_play seeded with handlers; schemas state the argument shape ✅ The schema's cron example is now proven to save.
3 get_play returns the typed play plus the schema metadata of every referenced type ✅ Comprehension bodies and .where(...) predicates are followed. Nested comprehensions are not (new finding 2, minor).
4 update_play: typed update only; errors name rule, component, index, field; enabled; no lifecycle or suspension writes ✅ Unchanged. The guidance now explains both ways an index is spelled.
5 Agent tests for the three turns ✅ Unchanged.
6 Prompt golden updated and reviewed ✅ Two lines changed in stage2_play_authoring.golden, each matching its source edit (the repair paragraph, the params description). The exclusion does not appear in the Stage-2 prompt, as expected: it is spent on ranking.
7 Routing and decisions evals don't regress; results in the PR ⏳ Pending from the author, to be posted before merge. New finding 1 is one more thing for that run to answer.
8 quality:fix clean; test:changed passes ⏳ Author reports 4,257 Rust tests passing and rust:quality clean. Not run here; the merge gate decides.

Code Review Findings

Critical Issues

None.

Suggested Improvements

1. 🟡 The exclusion taxes one of Play Authoring's own requests, and by how much it still leads is not recorded
📁 packages/agent/src/skill_pipeline.rs:537 (the exclusion), :520-530 (the comment), :1510-1528 (the pin); packages/agent/tests/it/live_skill_retrieval_stability.rs:1357-1381

exclusion_penalized_score is score − max(0, exclusion_score − score): it changes a score only when the query sits closer to the exclusion than to the description. So the recorded drop on "make that rule fire only for high priority tasks" (0.883 → 0.838) means that change request matches "Why a rule has not fired…" better than it matches Play Authoring's description, by about 0.045. The shared word is "fire", which is ordinary vocabulary for asking to change when a rule runs.

That is different from the precedent. Graph Editing's exclusion has a control that requires identical scores on its intended requests (graph_editing_exclusion_leaves_completion_state_scores_unchanged), and the pin's own doc comment says a new exclusion needs a test "showing it leaves that skill's intended requests unchanged". Play Authoring's guard asserts rank 1 only, and the comment records the penalized score but not the runner-up's, so the remaining margin is unknown.

Failure scenario: a nearby phrasing ("stop that rule firing for low priority tasks", "make the rule not run on weekends") sits a little closer still to the exclusion. Play Authoring falls below another skill, and the turn has no update_play on its surface. I have not measured this; the point is that nothing in the PR measures it either, and the one data point shows the penalty is live on this skill's own vocabulary.

Recommendation: non-blocking, and for the pending eval run to settle. Add two or three change requests that use "fire" / "run" wording to play_change_requests_route_play_authoring, and record the runner-up's score for the penalized query next to the 0.838. If the margin is thin, reword the exclusion toward the diagnostic question and away from the verb (for example, "what is still unmet before a rule runs"), re-measured against the same four control questions. Then update the pin's doc comment to state the bar this exclusion was held to (rank 1 with a recorded cost), since "unchanged" is no longer true of every row in the list.
Principle: ADR-064 rule 3. The exclusion mechanism's stated contract is that it costs a skill nothing on the requests it serves; where that doesn't hold, the cost should be bounded by a test and not by one sentence.

2. 🟢 A nested comprehension, and a comprehension inside a .where(...) predicate, are still not followed
📁 packages/core/src/playbook/referenced_types.rs:52-70 and :227-235

handle_comprehension puts an inner comprehension's collection into collections with its own root, not into the outer item_paths. The new loop skips any collection whose root is not node (line 53), and the first loop filters on the same condition. In where_predicates only extraction.paths is walked, never extraction.collections.

Failure scenario: node.stories.all(s, s.tasks.exists(t, t.owner.active)) on epic adds story and nothing else: the inner collection s.tasks has root s, so neither task nor person is returned. Likewise trigger.node.stories.where(tasks.exists(t, t.done)) adds story but not task.

Recommendation: much rarer than the single-level case the last review raised, so it need not hold the PR. If it is folded in, resolve each collection's item type once, keyed by its iteration variable, and start an inner collection rooted at that variable from the outer item type; in where_predicates, walk extraction.collections from filtered_type as well. One more case in paths_read_from_a_collections_items_are_followed would cover both.
Principle: the acceptance criterion says every type the rules reference; on a turn held to play the model has no other way to read a schema.

3. 🟢 play_value infers "the rules did not decode" from an empty list
📁 packages/agent/src/local_agent/tools.rs:668-676

The guard is decode_error.is_some() && fields.rules.is_empty(). When the stored rules are a valid empty array and a different field fails to decode, both hold: the result carries stored_rules: [], no rules, and a decode_error about the other field. Nothing is lost (an empty list is an empty list), but the result says the rules failed to decode when they didn't, and the comment on line 671 is wrong for that input.

Two related gaps:

  • Neither get_play's description nor the skill body mentions stored_rules or decode_error, while the guidance still says get_play "returns the rules exactly as they are stored" under rules and to copy the others "exactly from get_play". The key names carry the meaning alone.
  • The new test covers a non-array value only ("not a rule list"). The case the fix exists for, an array where one rule is broken and the others must survive, is not exercised.

Recommendation: decide by decoding the rules on their own rather than by emptiness (a small PlayFields helper returning the rules' own decode result would do), add a few words to get_play's description ("rules that no longer decode come back as stored_rules with decode_error"), and add the three-rules-one-broken case to the test.
Principle: ADR-064 rule 4, a tool result is a fact; rule 1, the tool's own schema is where its shape is stated.

Nitpicks

  • Nit: 🟢 packages/core/src/playbook/validation.rs:3154. The comment "this engine requires 7 fields" is now contradicted by a passing test in this PR (six fields save) and by the schema's "six cron fields starting with seconds". The comment predates the PR; correcting it to "at least six" here would stop the next reader repeating my earlier nit.

What is done well

  • The response separates what was fixed, what was partly fixed and what was left, with a reason for each, and the reasons check out against the code, including the one where the earlier review was wrong.
  • The exclusion's measured cost is written down next to the exclusion and not left out, which is what made new finding 1 possible to raise.
  • where_predicates reuses collect_where_chains, the parser that validation and the runtime use, so the chain it reads is the chain that runs.

Recommendation: APPROVE

All four prior findings are resolved or soundly justified, and the new commit introduces no correctness, security or architectural problem. New finding 1 should be answered together with the eval results still owed for criterion 7; findings 2 and 3 are small and can be folded in at the author's discretion. No re-review is needed unless the exclusion's wording changes.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@malibio

malibio commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

Re-review addressed (12bbf22)

1. The exclusion taxed one of the skill's own requests — fixed by rewording it as the diagnosis rather than the verb: "Diagnose why nothing happened for a node: which conditions are still unmet." Measured on the locked embedding model:

  • All eight original change/switch requests score exactly what they did with no exclusion ("make that rule fire only for high priority tasks" is back at 0.883, from 0.838), so the pin's bar, "leaves that skill's intended requests unchanged", holds.
  • Play Workflow State still leads all four "why hasn't it fired" questions; the closest is "why didn't the play trigger for that story?", 0.863 to 0.846.
  • The guard gained three change requests worded with "fire" and "run". All lead with Play Authoring; the closest is "stop that rule firing for low priority tasks", 0.868 to Play Workflow State's 0.860, recorded in the test's comment. Both skills are in the top 3 there either way.
  • 26/26 live_skill_retrieval_stability tests pass.

3. play_value inferred undecodable rules from an empty list — fixed. It now decodes the stored rules on their own, so another field failing to decode no longer moves a valid list to stored_rules. get_play's description names stored_rules and decode_error.

Nit — the cron test comment now says at least six fields.

Not changed

  • 2. Nested comprehensions (node.stories.all(s, s.tasks.exists(t, …)), or a comprehension inside a .where(...)) are still not followed. This is rarer than the single-level case, and a type missed here is still reported by validation on the write.
  • A test for an array with one broken rule among good ones: the store has no raw JSON setter to plant one past validation, and the decision no longer depends on the list being empty.

Re-review decision: not needed. The changes are a reworded string with its measurements, a narrower condition in one function, and comments. 3,791 Rust tests pass, clippy clean.

@malibio

malibio commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

Eval results (gemma-4-e4b-q4km, n_ctx 32768, 1 rep, fresh isolated daemon per run)

Eval main (091fe0a) This branch (12bbf22)
Routing, 19 scenarios 19/19 19/19, no regressions vs the main baseline
Decisions, 25 scenarios 20/25 stopped after 9 scenarios: 8 passed, 1 failed

Routing is identical on both arms: load-bearing 8/8, mutating gate 4/4, compound → route_multi 2/2, single intent at length 2/2.

Decisions was run in full on main only. The branch run was stopped partway, at the maintainer's call, so there is no complete branch figure. In the nine scenarios it did score, its one failure (a single-instance request must NOT route to Schema Creation, calling create_nodes_from_markdown) is a scenario that fails the same way on main. Main's other four failures (a question about the agent's own skills; an existing name is an update; an unresolved name means create; a fact report that is not a change request) were not reached on the branch.

Retrieval (the mechanism by which a new skill can displace others): all 26 live_skill_retrieval_stability guards pass on the locked embedding model with Play Authoring seeded, including the two new ones for the play skills.

@malibio

malibio commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

Merge queue: #3551 was taken out of the queue — the merge gate failed on it, on top of main. Reproduce by merging or rebasing origin/main and running bun run test:changed, fix, push, and re-run bun run merge 3551.

Compiling reqwest v0.13.3
   Compiling reqwest v0.12.28
   Compiling opentelemetry-http v0.32.0
   Compiling opentelemetry-otlp v0.32.0
   Compiling nodespace-agent v0.3.3 (/Users/malibio/nodespace/nodespace-core/.claude/worktrees/_gate/packages/agent)
error[E0004]: non-exhaustive patterns: `tools::Tool::GetPlay` and `tools::Tool::UpdatePlay` not covered
    --> packages/agent/src/local_agent/tools.rs:2653:15
     |
2653 |         match self {
     |               ^^^^ patterns `tools::Tool::GetPlay` and `tools::Tool::UpdatePlay` not covered
     |
note: `tools::Tool` defined here
    --> packages/agent/src/local_agent/tools.rs:2429:10
     |
2429 | pub enum Tool {
     |          ^^^^
...
2451 |     GetPlay,
     |     ------- not covered
2452 |     UpdatePlay,
     |     ---------- not covered
     = note: the matched value is of type `tools::Tool`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
     |
2677 ~             Tool::GetWorkflowState => Some("nodespace playbook get-workflow-state"),
2678 ~             tools::Tool::GetPlay | tools::Tool::UpdatePlay => todo!(),
     |
For more information about this error, try `rustc --explain E0004`.
error: could not compile `nodespace-agent` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `nodespace-agent` (lib test) due to 1 previous error
error: command `cargo '--color=auto' test --no-run --message-format json-render-diagnostics --workspace --exclude nodespace-app --exclude nodespace-app-lib --exclude nodespace-app-test-support --lib --bins --tests` exited with code 101
error: script "rust:test:build" exited with code 101
[stage exited with code 101]

  full output: /var/folders/6c/mkxnmpkx5zqc9jwwy20tjkyr0000gn/T/nodespace-gate-logs/_gate-merge-2026-10-04T21-15-31-512Z/compile-rust-test-binaries.log

✗ compile Rust test binaries failed — merge blocked.
  Fix the failure, push, and re-run: bun run merge <PR#>

@malibio
malibio force-pushed the issue-3519-play-authoring-skill branch from 12bbf22 to 6fd2b86 Compare October 4, 2026 21:20
malibio and others added 4 commits October 4, 2026 23:26
…ped get_play / update_play tools (closes #3519)

- get_play returns the typed play (rules with descriptions, enabled, suspension)
  and the schema metadata of every type its rules reference
- update_play writes rules, description and enabled through the typed play
  update; a rejected write returns the errors naming rule, component and field
- Play Authoring is a seeded built-in skill linked applies_to -> play, with its
  procedure in shared rule fragments for both audiences
- Agent turn tests, tool tests, a prompt golden and live retrieval guards

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ead from a collection's items, separate the two play skills with an exclusion

- get_play no longer reports rules that fail to decode as an empty list: they
  are returned as stored, under stored_rules, with decode_error
- referenced_types follows paths inside a comprehension's body and a .where()
  predicate, from the collection's item type
- Play Authoring carries an exclusion, so a question about why a rule has not
  fired leads with Play Workflow State; both live guards now assert rank 1, and
  the seeded link is asserted through find_skills
- The repair guidance names both ways a rejection spells a position
- update_play's cron example is sent through the tool in a test; params lists
  node_type and edge_data; the undeclared play_id alias is gone
- link_seeded_skills logs a failed link and carries on

Not changed: the validation errors still spell a position two ways (by name,
one-based; by index, zero-based). Unifying them means rewriting every location
string the engine and its tests fingerprint on, which is wider than this change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…decide undecodable rules by decoding them alone

- The exclusion no longer shares the verbs a change request uses: every
  measured change request scores what it did with no exclusion, and Play
  Workflow State still leads each question about why a rule has not fired.
  The guard gains change requests worded with fire and run
- get_play decides whether rules decode from the rules alone, and its
  description names stored_rules and decode_error
- Correct a test comment on the cron field count

Not changed: a comprehension nested in another, or inside a .where()
predicate, is still not followed by referenced_types. It is rarer than the
single-level case and its types are reported by validation on a write.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@malibio
malibio force-pushed the issue-3519-play-authoring-skill branch from 6fd2b86 to 05df24c Compare October 4, 2026 21:26
@malibio
malibio merged commit ea6a7ae into main Oct 4, 2026
@malibio
malibio deleted the issue-3519-play-authoring-skill branch October 4, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Teach the native agent to author plays: a play-authoring skill and typed get_play / update_play tools

1 participant