Skip to content

feat(docs): truth-sync intentional syntax contracts and UFCS docs#126

Merged
joshcramer merged 4 commits into
mainfrom
feat/doc-claims-ufcs
Jun 13, 2026
Merged

feat(docs): truth-sync intentional syntax contracts and UFCS docs#126
joshcramer merged 4 commits into
mainfrom
feat/doc-claims-ufcs

Conversation

@larimonious

@larimonious larimonious commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements a narrowed DD-063 Rec 2 slice: truth-sync the stale agent-facing syntax docs, embrace UFCS dot-call as intentional sugar, and add tests only for syntax contracts we actually want to treat as stable.

After review, this PR deliberately does not lock every current CLAUDE.md behavior. Current-but-questionable behavior should remain available for language improvement, not be fossilized because a test happened to observe it.

What this keeps

Intentional syntax contract tests

  • tests/doc_claims_tests.rs has 8 focused tests instead of the earlier broad snapshot.
  • Tests cover only the “yes, this is a real language/agent contract” items:
    • map literals require the map keyword
    • #{expr} interpolation works
    • JavaScript-style ${expr} is diagnosed with a repair hint
    • UFCS dot-call works for builtin/imported/user functions
    • imports used via UFCS are not flagged unused
    • otherwise recovery blocks must diverge
    • template strings interpolate {{expr}}
    • contract clauses go after the return type and before the body

Doc corrections

  • CLAUDE.md, CODEX.md, and .github/copilot-instructions.md now describe actual behavior instead of stale rules:
    • dot-call is UFCS sugar; free functions remain canonical
    • semicolons parse but lint-warn; they do not corrupt parser state
    • mut is currently partial: indexed mutation requires it, plain reassignment does not
    • old module-level-map warning was stale
    • for..in on strings warns instead of failing silently
  • docs/AI_AGENT_GUIDE.md and generated syntax docs document UFCS as first-class sugar.

Small code/doc fixes required by review

  • collect_used_names counts dot-call method names as function usage, so imports used only through UFCS (" hi ".trim()) are not incorrectly reported as unused_import.
  • IAL_REFERENCE.md now includes a generated primitive status column so agent-facing docs do not present stubs as implemented:
    • Sql: Not implemented
    • InvariantCheck: Resolver marker only; direct execution fails unless expanded

What was removed from this PR

Removed tests that locked behavior we may want to reconsider:

  • partial mut semantics
  • string iteration skipping with warning
  • route functions being global-only / not importable
  • semicolon permissiveness details
  • range() absence
  • pipe-closure absence
  • module-level map behavior
  • truthiness details
  • missing map key behavior
  • map iteration behavior
  • UFCS edge gaps like map-stored closures not being dot-callable

Also removed the optional dot-call typo suggestion work. That belongs in a follow-up diagnostic PR, not this lighter syntax-doc slice.

Test plan

  • cargo fmt --check
  • cargo build --profile dev-release --locked
  • cargo test --test doc_claims_tests
  • ./target/dev-release/ntnt docs --generate
  • git diff --check

Notes

This PR’s invariant is now: agent-facing docs must match implementation for intentional syntax contracts. It is not: “every current behavior is forever.”

…e UFCS dot-call

DD-063 Rec 2. The agent-facing docs had drifted from the implementation —
agents were being steered away from valid code by stale rules. This locks
every behavioral claim with a test so the docs can never silently drift again.

Tests:
- tests/doc_claims_tests.rs: 32 tests, one per CLAUDE.md Critical Syntax Rule,
  asserting on error codes (E002/E005/E006/E007) and stable fragments. A
  failure means the language changed — update the docs in the same PR.

Doc corrections (CLAUDE.md, CODEX.md, .github/copilot-instructions.md — all
three carried the identical stale claims):
- Rule 3: dot-call is UFCS sugar (x.f(a) == f(x, a)), not "WRONG". Documents
  the real gaps: parens disambiguate call vs property/key read; closures
  stored in map values are not dot-callable.
- Rule 5: semicolons parse fine and lint-warn — they do not "corrupt parser
  state".
- Rule 8: mut is enforced for indexed mutation only; plain rebinding currently
  succeeds without mut (documented, with a test locking the actual behavior).
- Rule 10: module-level map literals work now; replaced in place (numbering
  kept stable) with the map-closure UFCS caveat.
- Rule 11: the for..in-on-string skip emits a warning; it is not silent.

UFCS support:
- collect_used_names: dot-call method names now count as import usage, so an
  import used only via s.trim() is no longer flagged unused_import.
- Method-call miss (E007) now suggests a near-match free function, so dot-call
  typos like 5.doubl() get a "did you mean" hint.
- docs/AI_AGENT_GUIDE.md + syntax.toml document UFCS as first-class sugar.

IAL honesty:
- ial.toml gains a status field for the Sql (not implemented) and
  InvariantCheck (partial) primitives; generate_ial_markdown renders a Status
  column. IAL_REFERENCE no longer advertises capabilities that do not exist.
@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates the agent-facing syntax and IAL docs to match current language behavior. It changes:

  • Narrows syntax contract tests to intentional stable behavior.
  • Documents UFCS dot-call as supported sugar for free functions.
  • Updates generated syntax and IAL reference content.
  • Marks incomplete IAL primitive support in the generated primitive table.
  • Fixes unused-import accounting for UFCS method names.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Reviews (4): Last reviewed commit: "docs: mark incomplete IAL primitives in ..." | Re-trigger Greptile

Comment thread src/interpreter.rs Outdated
…sses

The method-call E007 suggestion drew from every environment binding, so a
nearby non-callable variable could be suggested as the fix for a dot-call
typo (5.doubl() -> a variable that still can't be called). New
Environment::function_names() filters to Function/NativeFunction bindings;
the suggestion now only ever names something callable.
@larimonious larimonious changed the title feat(docs): lock CLAUDE.md syntax rules with regression tests; embrace UFCS dot-call feat(docs): truth-sync intentional syntax contracts and UFCS docs Jun 13, 2026
@larimonious

Copy link
Copy Markdown
Contributor Author

Addressed Greptile’s IAL status issue in c12aaf2: the generated primitive table now has a Status column, Sql is explicitly marked Not implemented, and InvariantCheck is marked as resolver-marker-only/direct execution fails unless expanded. Regenerated docs/IAL_REFERENCE.md and reran the local checks.

@joshcramer joshcramer merged commit 1c00590 into main Jun 13, 2026
9 checks passed
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