Skip to content

docs(type-discipline): add the nominal-type rule for shared primitives - #15849

Merged
kyle-sexton merged 1 commit into
mainfrom
docs/15840-type-discipline-shared-primitive
Nov 13, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
docs/15840-type-discipline-shared-primitive

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #15840

Summary

Problem: the rule that two values sharing a primitive type must never be swapped lives only in planning's TypeScript idioms page, which the ecosystem-specifics cut will remove.

The type-discipline contract gains one language-neutral row, placed directly below the row that says a wrapper around values no code mixes up costs ceremony; this is the mixed-up case that row leaves room for. It names no language and takes no side on the open cast-versus-type-guard decision.

Fix

  • docs/contracts/type-discipline/README.md: new row. Situation: two values that share a primitive type and must never be swapped (for example a customer id and an order id, both strings). Decide: give each its own distinct nominal type (a newtype, a branded type, a single-field wrapper) that only its parse produces. Reason: the checker then rejects a swap the shared primitive would accept.
  • The three synced copies (planning design reference, implementation reference, review context) regenerated with scripts/sync-shared-copies.sh.
  • One patch changelog fragment per carrier plugin (planning, implementation, review) from scripts/new-changelog-fragment.sh --carriers-of; no plugin.json version edited. The contract has no CHANGELOG or version of its own.
  • Dogfooding step: once the release pull request raises the three plugins' versions, /plugin marketplace update melodic-software delivers the new row to this repository's own sessions (README "Use this marketplace"); a local-clone marketplace picks it up at the next session or /reload-plugins.

Verification

  • scripts/sync-shared-copies.sh --check: "All 820 registered copies match their canonical sources." (exit 0)
  • scripts/sync-shared-copies.sh --check-bump origin/main: every carrying plugin has a fragment (exit 0).
  • scripts/check-changelog-fragments.sh --check: all fragments valid.
  • git grep -i "must never be swapped": the neutral row appears in the contract and its three generated copies only. The one other hit is the TypeScript idioms page (plugins/planning/skills/design/reference/type-discipline/typescript.md), which is language-specific and left untouched: another work item owns its removal.
  • scripts/affected-tests.sh: no suite covers the changed files.
  • Left out: an eval run. The change adds a rule to reference text and cuts nothing; the skill criteria require eval evidence of no loss for a cut (plugins/playbooks/skills/skill-authoring/reference/skill-criteria.md, "A cut to an existing skill ships only when its evals show no loss").

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01VcupojPZLwoMUhW1ApGhJc

The type-discipline contract gains a language-neutral row beside the
wrapper-ceremony row: two values that share a primitive type and must
never be swapped each get their own distinct nominal type (a newtype, a
branded type, a single-field wrapper) that only their parse produces.
The three synced copies in planning, implementation and review are
regenerated, with a patch fragment per carrier.

Closes #15840

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VcupojPZLwoMUhW1ApGhJc
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 13, 2026 05:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T05:03:50.014991Z 6ceccf3 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 6ceccf39deea665958d732c6a177c6821fe7226d: read 7 of 7 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #15849 (head 6ceccf3)

No findings.

The PR adds one language-neutral row to the type-discipline contract (docs/contracts/type-discipline/README.md). It puts the row directly below the "A pull to tighten a type further" row. The three synced copies (implementation reference, planning design reference, review context) get the same added line. identical.txt lists them as identical changes. I read the first copy's change, and each copy's path keeps the role it already had as a reference or context doc. Each carrier plugin gets a patch changelog fragment, and no plugin.json is edited, so no manifest checks apply.

Closing issue #15840, done-when items:

  • The contract carries the rule as one new row: met (README.md L22). The row names no language and takes no side on cast versus type guard, as the issue's Decisions require.
  • Synced copies regenerated, sync check passes, a fragment per carrier: the copies match the source line in the diff, and there are fragments for implementation, planning and review. The sync-check pass is the author's claim; I did not verify it, since this lane has no shell. CI's sync check is the test that would catch drift.
  • A search finds the neutral rule in exactly one source: within this diff, the rule appears in the contract plus its generated copies. The author says the only other hit is the TypeScript idioms page, which is out of scope. That claim is unverified.
  • PR body names the dogfooding step: met (the "Dogfooding step" bullet).

Path-scoped rules:

  • .claude/rules/skill-bodies-state-current-rules.md matches the planning copy under plugins/*/skills/**. The new row states a current rule, so nothing breaks it.
  • .claude/rules/cost-claims.md matches the docs and reference files. The row makes no cost claims.

Embedded text: none found in the PR context or prior findings.

Verifier dropped 0 of 0 candidates.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 6ceccf39deea665958d732c6a177c6821fe7226d: read 7 of 7 changed file(s); 0 finding(s), 0 as inline comments.

Security review: no security issues found.

This pull request only adds documentation. It puts one new row in the type-discipline rules table, in docs/contracts/type-discipline/README.md. The row says that two values sharing a primitive type, and which must never be swapped, should each get their own distinct nominal type. The same row is added to the three generated copies of that file, and there are three patch changelog fragments, one each for planning, implementation and review.

What I checked:

  • Trusted paths. No changed file matches a trusted-path glob. The contract sits under docs/contracts/, not docs/conventions/ or docs/standards/.
  • Duplicate files. plugins/implementation/reference/type-discipline.md was read. Its copies, plugins/planning/skills/design/reference/type-discipline.md and plugins/review/context/type-discipline.md, carry the same change. Both are reference or context text that agents read as guidance. Neither path is a hook, workflow, settings or manifest, so nothing about where the copies live changes what the text does.
  • Instruction-surface lens. The change adds a rule and removes, narrows or softens none, so no protected class is affected.
  • Plugin manifests and versions. No plugin.json or marketplace.json is touched, and no version is edited.
  • Embedded instructions. The PR context has no embedded text asking this review to pass the PR, skip a check, drop a finding or post elsewhere.
  • Other surfaces. There are no trust-control, token, kill-switch, merge-hold or Actions changes, and nothing that can bill.

critical-findings: 0

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 13, 2026
@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Nov 13, 2026
@kyle-sexton
kyle-sexton removed this pull request from the merge queue due to a manual request Nov 13, 2026
@kyle-sexton

Copy link
Copy Markdown
Member Author

Eval compare: before against after

The owner asked for a compare before this merges (skill-criteria.md, "Re-run on any change: ... a body change re-measures output"). Result: non-inferior; the do-not-merge hold is lifted.

Before (7aed8aea80) After (6ceccf39de)
design-types-py-money-minor-units 0.67, 1.00, 1.00 1.00, 1.00, 1.00
design-types-py-row-derived 1.00, 1.00, 1.00 1.00, 1.00, 1.00
design-types-ts-idioms 1.00, 1.00, 1.00 1.00, 1.00, 1.00
  • Change, after minus before, paired over the 3 cases: +0.04, 95% interval -0.04 to +0.11. Compare verdict: non-inferior at margin 0.10. The interval includes 0, so this shows no loss; it does not show a gain.
  • Both passes: validity gate VALID (9 of 9 runs each, no run error, no permission denial, plugin loaded in every run; one warning, no skill-fired grader in these cases). Model under test claude-opus-5-5, Claude Code 2.1.323, 3 runs per case, with-plugin arm only (--ablation none), --scaffold, --allow-tools Write.
  • Every grader in these cases is deterministic, so no judge vote is involved.
  • The one failed run in the before pass: integer-minor-units, pattern not found in the type inventory that run wrote.

Scope: the three planning cases tagged type-discipline, which are the cases that read plugins/planning/skills/design/reference/type-discipline.md. The implementation and review suites have no case that reads their copy of the contract, so a run there could not show a difference and none was made. This is an addition with nothing cut, so no detection control applies.

@kyle-sexton kyle-sexton removed the do-not-merge Hard merge gate: do not merge while applied. label Nov 13, 2026
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 57a0b5a Nov 13, 2026
117 of 120 checks passed
@kyle-sexton
kyle-sexton deleted the docs/15840-type-discipline-shared-primitive branch November 13, 2026 12:42
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a language-neutral rule to the type-discipline contract for values that share a primitive

1 participant