Skip to content

[codex] Support PICT-compatible inline schema definitions#187

Merged
eviltester merged 1 commit into
masterfrom
163-pict-compatible-enums
Jun 12, 2026
Merged

[codex] Support PICT-compatible inline schema definitions#187
eviltester merged 1 commit into
masterfrom
163-pict-compatible-enums

Conversation

@eviltester

Copy link
Copy Markdown
Owner

Summary

  • add support for PICT-style inline schema definitions using name: rule alongside the existing two-line schema format
  • preserve inline formatting when schema tokens are round-tripped back to text
  • add regression coverage for generation, amend flows, parser behavior, and safe faker validation, and document the new syntax

Why

Issue #163 requested compatibility with PICT-style enum definitions so schemas can be copied over without rewriting each field into the two-line format.

Validation

  • pnpm run verify:local

Copilot AI review requested due to automatic review settings June 11, 2026 15:37
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@eviltester, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 59 minutes and 35 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 10576409-7298-4b99-b283-f14f8dbf98c4

📥 Commits

Reviewing files that changed from the base of the PR and between dca460f and d323962.

📒 Files selected for processing (9)
  • README.md
  • docs-src/docs/040-test-data/018-Schema-Definition.md
  • packages/core/js/data_generation/rulesParser.js
  • packages/core/js/data_generation/schema-conversion.js
  • packages/core/src/index.js
  • packages/core/src/tests/core-api/amendFromTextSpecAndData.test.js
  • packages/core/src/tests/core-api/generateFromTextSpec.test.js
  • packages/core/src/tests/data_generation/schema-rules-adapter.test.js
  • packages/core/src/tests/data_generation/unit/rulesParser.test.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 163-pict-compatible-enums

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for PICT-style inline schema definitions (name: rule) across the core parsing and rendering pipeline, allowing users to copy PICT schemas directly while still supporting the existing two-line format.

Changes:

  • Extend schema parsing to accept inline name: rule definitions and tag parsed schema tokens as inline for round-trip fidelity.
  • Update schema rendering to preserve inline formatting when schema tokens indicate an inline rule.
  • Add regression tests (parser, schema adapter, generate/amend flows, and safe faker validation) and document the new syntax.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Documents the new inline name: rule schema form alongside the existing two-line format.
packages/core/src/tests/data_generation/unit/rulesParser.test.js Adds parser coverage for inline definitions, inline round-trip rendering, and a non-inline colon edge case.
packages/core/src/tests/data_generation/schema-rules-adapter.test.js Ensures inline tokens round-trip through schemaText/dataRules adapters.
packages/core/src/tests/core-api/generateFromTextSpec.test.js Verifies generation + safe faker validation accept inline schema definitions.
packages/core/src/tests/core-api/amendFromTextSpecAndData.test.js Verifies amend flows accept inline schema definitions.
packages/core/src/index.js Updates safe-mode faker rule scanning to recognize inline schema definitions.
packages/core/js/data_generation/schema-conversion.js Renders rules inline when schema tokens specify inline, using token separator when available.
packages/core/js/data_generation/rulesParser.js Implements inline name: rule parsing and emits inline-aware schema tokens; updates token-based rendering for inline rules.
docs-src/docs/040-test-data/018-Schema-Definition.md Adds user-facing docs for the inline PICT-style schema syntax.

Comment thread packages/core/js/data_generation/rulesParser.js
Comment thread packages/core/src/index.js
@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds support for PICT-style inline schema definitions (name: rule) alongside the existing two-line format, with round-trip fidelity so the compact syntax is preserved when schemas are re-serialized.

  • rulesParser.js gains looksLikeInlineRuleSpec and parseInlineRuleDefinition to detect and parse inline tokens; both renderSpecFromRulesWithTokens implementations (parser and schema-conversion.js) are updated to emit the original inline form when the token carries inline: true.
  • extractRuleLines in index.js is rewritten from a naïve every-other-line walk to a state-machine that understands blank lines, comments, constraints, and inline PICT — fixing the pre-existing limitation in validateSafeFakerRules for commented or mixed schemas.
  • Tests cover generation, amend, round-trip token preservation, negative colon-in-name disambiguation, and safe-faker inline validation.

Confidence Score: 4/5

Safe to merge; the core parsing and rendering paths are well-tested and the inline detection heuristic is conservative enough to avoid false positives in realistic schemas.

The inline detection heuristic is duplicated verbatim across rulesParser.js and index.js. The two copies are currently in sync, but a future change to either without touching the other would silently produce different behaviour between the parser and the safe-faker validator. No correctness bugs were found in the changed paths.

packages/core/src/index.js — the duplicated heuristic lives here alongside the rewritten extractRuleLines.

Important Files Changed

Filename Overview
packages/core/js/data_generation/rulesParser.js Adds looksLikeInlineRuleSpec heuristic, parseInlineRuleDefinition helper, and inline-token handling in parseText and renderSpecFromRulesWithTokens; logic is correct and well-tested
packages/core/js/data_generation/schema-conversion.js Adds inline token rendering path to renderSpecFromRulesWithTokens, mirroring the parser change; synthesizeTokensFromRules intentionally omits inline, so new columns added via amend still use two-line format — acceptable fallback
packages/core/src/index.js Rewrites extractRuleLines to handle inline PICT and blank/comment/constraint lines correctly; introduces looksLikeInlineSchemaRule, a near-exact duplicate of looksLikeInlineRuleSpec from rulesParser.js
packages/core/src/tests/data_generation/unit/rulesParser.test.js Adds parser unit tests for inline PICT rules, round-trip preservation, and the negative case (colon in name, not inline); good regression coverage
packages/core/src/tests/data_generation/schema-rules-adapter.test.js Adds round-trip test confirming inline schema tokens survive parse → render intact
packages/core/src/tests/core-api/generateFromTextSpec.test.js Adds inline PICT generation test and validateSafeFakerRules inline test; covers happy-path flows
packages/core/src/tests/core-api/amendFromTextSpecAndData.test.js Adds amend-flow test for inline PICT schema; correctly validates headers and per-row values
README.md Updates column-definition description and adds a compact PICT-style example to the reference block
docs-src/docs/040-test-data/018-Schema-Definition.md Adds inline-format section with an example and a note that both formats can be mixed

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Input line] --> B{blank or comment\nor constraint?}
    B -- yes --> C[emit token, pendingName = null]
    B -- no --> D{looksLikeInlineRuleSpec\nmatches after colon?}
    D -- yes --> E[emit inline rule token\nkind=rule, inline=true]
    D -- no --> F{pendingName set?}
    F -- no --> G[pendingName = trimmed]
    F -- yes --> H[emit two-line rule token\nkind=rule, inline=false]
    E --> R[renderSpecFromRulesWithTokens]
    H --> R
    R --> I{token.inline = true?}
    I -- yes --> J[output: name + separator + rule]
    I -- no --> K[output: name line then rule line]
Loading

Reviews (1): Last reviewed commit: "Support PICT-compatible inline schema de..." | Re-trigger Greptile

Comment thread packages/core/src/index.js
@eviltester eviltester merged commit f0834db into master Jun 12, 2026
15 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