Skip to content

Add rule templates (abstract, extends, semantic.criterion) - #237

Draft
mindsocket wants to merge 1 commit into
claude/project-thread-ipaubtfrom
claude/project-thread-ipaubt-templates
Draft

mindsocket wants to merge 1 commit into
claude/project-thread-ipaubtfrom
claude/project-thread-ipaubt-templates

Conversation

@mindsocket

Copy link
Copy Markdown
Owner

🤖 Generated with Claude Code

https://claude.ai/code/session_019XphpcQHEAB9KwJ5Ltiomb

Slice 4 of the semantic rule primitives plan, stacked on #233. This is a draft to inform the dialect decision. The Rule surface is not agreed yet.

Summary

  • Templates. A rule with "abstract": true is a template, and it never runs. A rule with extends: "<template id>" takes the template's fields, then sets its own. Top-level fields replace the template's. Fields inside semantic replace the template's one at a time.
  • Checks. The resolved rule is checked against the full rule schema, so the existing checks (custom verdicts need a severity map, and so on) apply to what actually runs. The load fails before any work when:
    • the template id is unknown;
    • extends names a rule that isn't abstract;
    • a template extends another template (one level only).
  • semantic.criterion. The judge reads it after the rubric. It is folded into the judge spec's rubric, so all three provider shapes (chat, Jev, OpenAI decisions) get it with no provider-specific code.
  • sctx://core/_semantic_patterns. This new bundled partial holds four templates. Seven slice 3 rules now extend them:
    • children-distinct: opportunities-distinct, goals-distinct
    • children-cover-parent: goals-cover-parent
    • refines-parent: opportunity-refines-parent, goal-advances-parent
    • serves-ancestors: solution-serves-outcome, opportunity-serves-ancestors
  • Rules left as plain rules. solution-addresses-opportunity stays plain, because means-to-need is a different test from refining a parent. The type-specific rules stay plain too.
  • Public types. Only Rule.semantic.criterion is new. abstract and extends exist only on the declared form (DeclaredRule, internal), because resolved metadata never contains them.

Choices for review

  • Severity maps are replaced whole. A rule that sets semantic.severity replaces the template's whole map, not single entries.
  • goal-advances-parent verdict renamed. Its passing verdict is now refines, shared with the template, and its eval labels are updated.
  • No schemas show change. It lists resolved rules, which is what runs. It doesn't print rubrics, so templates add nothing to its output.
  • Generic rubrics plus criteria. The template rubrics are generic, and each rule's criterion carries the type-specific test. The live evals are the regression check against the feat(schemas): bundled semantic rules with evals #233 wording. They have not been run on this branch yet.

Test plan

  • bun run test, typecheck, lint, test:hook, test:mod
  • bun run eval:semantic --check
  • New tests/schema/rule-templates.test.ts: resolution, reuse, unknown and concrete targets, the resolved-rule check, no nested templates, and bundled rules
  • Live evals against feat(schemas): bundled semantic rules with evals #233's results (jev packed and per-node, openai, Haiku)

Generated by Claude Code

A rule with "abstract": true is a template that never runs. A rule that
names it in "extends" takes its fields, then sets its own; semantic
fields replace the template's one at a time. The resolved rule is checked
as a full rule. semantic.criterion is read after the rubric, so a
template's rubric can stay generic.

The bundled sctx://core/_semantic_patterns partial holds four templates
(children-distinct, children-cover-parent, refines-parent,
serves-ancestors), and seven bundled rules now extend them.
goal-advances-parent's passing verdict is now "refines".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019XphpcQHEAB9KwJ5Ltiomb
@mindsocket
mindsocket added this pull request to stack #238 November 14, 2026 04:39

@mindsocket mindsocket left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Interim thoughts - these are more encouragements to keep exploring the solution space and running comparisons and iterating on wording and shape before zeroing in on a final solution.

Comment thread docs/semantic-rules.md
| `refines-parent` | The node is one part, cause, case or means of its parent | The child | `parent` | `opportunity-refines-parent`, `goal-advances-parent` |
| `serves-ancestors` | The node serves the intent of the levels above | The child | `ancestors` | `solution-serves-outcome`, `opportunity-serves-ancestors` |

```json

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Considerations as part of the review of this PR and the one it's stacked on:

  • Is criterion needed?
  • Is criterion a good name? Is "criterion gets tacked onto rubric" a valid and reasonably understandable statement to a user?
  • How does a custom rule (no template, hand-coded in top-level schema) vs a template rule with criterion vs a template rule without criterion compare in evals, for the same intent? That informs where we might focus attention on the shape, composition and wording used in rules.

Comment thread docs/semantic-rules.md
| `serves-ancestors` | The node serves the intent of the levels above | The child | `ancestors` | `solution-serves-outcome`, `opportunity-serves-ancestors` |

```json
{ "id": "goals-distinct", "extends": "children-distinct", "description": "Sibling goals are distinct",

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This doesn't feel like a great example yet. We need to prove that criterion is useful vs not having one at all for a given use of a bundled template.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I think a good example might emerge where the criterion clarifies the interpretation of the language in a rule. eg "refines" means {blah} in this context

"id": "children-distinct",
"abstract": true,
"category": "coherence",
"description": "A node's children are distinct: achieving or addressing one does not achieve or address another",

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

We'll probably need to experiment with:

  • language - 'achieve' or 'address' may be too specific, too vague, orthogonal, or risks misinterpretation by models
  • additional "keywords" that might help guide models - eg KAOS, MECE, minto pyramid etc - referencing established research and concepts that would help the model interpret the rubric as intended
  • skills (for schema authoring) to steer criterion overlay tips that build on the core rules

}
},
{
"id": "serves-ancestors",

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

These rules could be fine, but I wonder if they've wandered from the more rigid and research backed rule ideas from the original analysis in artifact.

"category": "coherence",
"description": "A node belongs under its parent: it is one part, cause, case or means of the parent",
"semantic": {
"rubric": "Judge only how the item relates to its parent. Something worthwhile in the same area as the parent does not refine the parent unless it passes the criterion's test.",

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Some rules sound quite alike. That could be fine when the nuance matters, but those nuances might need describing. Hold that thought until we've converged on working evaluations.

{
"id": "goals-cover-parent",
"category": "best-practice",
"extends": "children-cover-parent",

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

A/B test the original rules vs these new ones.

Also consider an AI improvement loop to hillclimb on this (get my approval on approach first)

This branch has not been deployed

No deployments
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.

2 participants