Skip to content

Add editor projection CLI - #115

Merged
flyingrobots merged 6 commits into
mainfrom
projection/edict-cli
Jul 2, 2026
Merged

Add editor projection CLI#115
flyingrobots merged 6 commits into
mainfrom
projection/edict-cli

Conversation

@flyingrobots

Copy link
Copy Markdown
Owner

Summary

Adds the Edict-side editor projection surface for dirty .edict buffers. The CLI now supports operation: "project" over existing JSONL stdin/source records and can emit syntax, diagnostics, Core, and Target IR projection records.

Projection review JSON is display data for editor tooling. Canonical digest fields are computed from the existing Core and Target IR canonical encoders; this PR does not define Echo execution, admission execution, bundle assembly behavior, or canonical manifest bytes.

What changed

  • Added projection schema constants and checked-in JSON Schemas for syntax, diagnostics, Core, and Target IR projection records.
  • Extended compiler settings schema with project, emit, explicit compiler facts, and explicit target facts.
  • Added syntax-only projection as the cheap/live path over dirty source without running parse/Core/Target IR.
  • Added authoritative projection for diagnostics, Core review plus digest, and Echo Target IR review plus digest.
  • Emitted compiler and lowering failures as structured projection records on stdout instead of process failures.
  • Updated CLI and developer-tooling topic shelves plus CHANGELOG.

RED

  • cargo test -p edict-cli project_ failed before implementation because project was unsupported.
  • cargo test -p edict-cli project_syntax_only_does_not_run_authoritative_compiler_path failed during self-review because syntax-only projection still counted hidden parse diagnostics.

GREEN

  • cargo test -p edict-cli
  • cargo xtask contract-check
  • cargo xtask verify

Docs impact

Updated CLI and developer-tooling topic shelves, projection schemas, xtask schema guards, and CHANGELOG.

Issue

No issue closes in this PR.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@flyingrobots, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b463d391-053b-49e4-a190-351b94e86065

📥 Commits

Reviewing files that changed from the base of the PR and between 3a0ce62 and 471f346.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • crates/edict-cli/src/main.rs
  • crates/edict-cli/tests/jsonl_cli.rs
  • docs/schemas/edict.compiler-settings.v1.schema.json
  • docs/topics/cli/test-plan.md
  • xtask/src/tests.rs

Walkthrough

Introduces a project CLI operation alongside check, emitting editor-facing JSONL projection records (syntax spans, diagnostics, Core/Target IR review JSON with canonical digests) even for dirty/unsaved sources. Adds projection schema constants, four new JSON Schema contracts, command-attribution across CLI failure paths, extensive tests, and documentation updates.

Changes

edict CLI project operation

Layer / File(s) Summary
Schema constants
crates/edict-cli/src/lib.rs
Adds PROJECTION_SYNTAX_SCHEMA, PROJECTION_DIAGNOSTICS_SCHEMA, PROJECTION_CORE_SCHEMA, PROJECTION_TARGET_IR_SCHEMA constants.
Settings and type definitions
crates/edict-cli/src/main.rs
Extends CompilerSettings with emit/compilerContext/target, adds projection setting types (profiles, effects, budgets), and adds command field plus with_command to CliFailure.
Request/settings parsing with command attribution
crates/edict-cli/src/main.rs
Reworks parse_request/parse_settings/parse_compiler_input, stdin/env parsing, path/glob confinement, and diagnostic/status record generation so every CliFailure and diagnostic carries the correct check/project command; adds validate_operation_settings and validate_project_target.
Project execution and record emission
crates/edict-cli/src/main.rs
Adds run_project_request building a CompilerContext and emitting syntax/diagnostics/core/target-ir projection records including blocked/failed shapes; status_record is now command-aware.
JSON Schema contracts
docs/schemas/edict.cli-diagnostic.v1.schema.json, docs/schemas/edict.cli-event.v1.schema.json, docs/schemas/edict.compiler-settings.v1.schema.json, docs/schemas/edict.projection-*.v1.schema.json
Broadens command/type/operation enums to include project, adds emit/compilerContext/target schemas, and introduces four new projection record schemas with state-conditional validation.
Tests
crates/edict-cli/tests/jsonl_cli.rs, xtask/src/tests.rs
Adds end-to-end tests for project success, invalid source, target-lowering failure, syntax-only mode, invalid settings, plus schema-contract assertions for new projection schemas.
Documentation
CHANGELOG.md, docs/topics/cli/*, docs/topics/developer-tooling/*
Documents the project contract, stdout/stderr rules, exit codes, test plans, and future editor-adapter direction.

Estimated code review effort: 4 (Complex) | ~75 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant CLI as edict-cli
  participant CompilerContext
  participant ProjectionRecords

  Client->>CLI: JSONL request (operation: project)
  CLI->>CLI: parse_request / parse_settings (attach command)
  CLI->>CLI: validate_operation_settings / validate_project_target
  CLI->>CompilerContext: build from compilerContext/target facts
  CompilerContext-->>CLI: core/target-ir facts, or blocked/failed reason
  CLI->>ProjectionRecords: emit syntax, diagnostics, core, target-ir records
  ProjectionRecords-->>Client: stdout JSONL projection records + status
Loading

Possibly related PRs

  • flyingrobots/edict#67: Target-ir projection records/digests in this PR build directly on the Target IR lowering API and Echo facts added there.
  • flyingrobots/edict#74: Both PRs modify the same edict.cli-diagnostic/v1 and edict.cli-event/v1 schemas and their command enums.
  • flyingrobots/edict#108: Target-ir projection digests rely on the canonical Target IR artifact encoding/digest APIs introduced there.

Poem

A rabbit squints at every span,
"Where's your command field, if you can?"
Blocked, available, failed — pick one, don't cheat,
No stray property, no schema deceit. 🐇🔍
Ship it clean, or ship it not at all.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately captures the main change: adding editor projection support to the CLI.
Description check ✅ Passed The description is clearly related to the changeset and summarizes the new projection CLI, schemas, docs, and failure behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@flyingrobots

Copy link
Copy Markdown
Owner Author

@codex self-review found two issues that should be addressed before this projection contract lands.

ID Severity File / lines Infraction Evidence Recommended mitigation prompt
SELF-001 P2 crates/edict-cli/src/main.rs:653-708 Hidden projection diagnostics for syntax-only lexical failure project_source records a lex diagnostic when syntax_projection_record fails, but only emits a diagnostics record when emit explicitly contains diagnostics. A syntax-only request can therefore return status.errors = 1 with no syntax record and no diagnostics record. Local probe: emit:["syntax"] over an unterminated string produced only {"command":"project","errors":1,...,"type":"status"}. Add a regression for emit:["syntax"] with a lexical error. Fix the projection contract so no status error is hidden: either emit a diagnostics projection record when syntax lexing fails, even if not requested, or extend the syntax schema with an explicit failed/blocked state and emit that. Keep status errors aligned with visible structured records.
SELF-002 P3 crates/edict-cli/src/main.rs:1587-1596, crates/edict-cli/src/main.rs:1771-1776, docs/schemas/edict.cli-diagnostic.v1.schema.json:16-18, xtask/src/tests.rs:1919-1922 Invalid project settings are mislabeled as check CLI failures CliFailure has no command field, cli_diagnostic hardcodes COMMAND_CHECK, and write_cli_failure hardcodes a check status. Local probe with operation:"project" and uppercase profileDigest exited 2 but emitted both diagnostic and status with command:"check". The event schema already permits project; the diagnostic schema still forces check. Add a regression for invalid project settings, such as uppercase target.profileDigest, expecting command:"project" on the CLI diagnostic and status. Thread the parsed operation/command into CliFailure where known, update the diagnostic schema from const:"check" to an enum covering check and project, and update the schema guard accordingly.

No additional issues found in the changed projection schemas, topic-shelf rows, or whitespace checks during this pass.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3a8f8dad19

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/edict-cli/src/main.rs
Comment thread crates/edict-cli/src/main.rs
Comment thread docs/schemas/edict.compiler-settings.v1.schema.json
Comment thread crates/edict-cli/src/main.rs Outdated
Comment thread crates/edict-cli/src/main.rs
@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

Testing

  • cargo fmt && cargo test -p edict-cli project_syntax_only_lex_failure_emits_visible_diagnostics project_invalid_settings_emit_project_cli_failure diagnostic_schema_declares_jsonl_contract (agent error: invalid Cargo test invocation with multiple positional filters)
  • cargo test -p edict-cli project_
  • cargo test -p xtask diagnostic_schema_declares_jsonl_contract
  • git diff --check && cargo xtask verify (agent error: first full verify caught an intermediate schema-guard mistake before the final fix)
  • cargo fmt && cargo xtask verify

View task →

@flyingrobots

Copy link
Copy Markdown
Owner Author

Resolved the self-review findings in commit 3a0ce62.

ID Outcome Evidence
SELF-001 Fixed syntax-only lexical failures so they emit visible edict.projection.diagnostics/v1 data instead of a status error with no structured payload. Added project_syntax_only_lex_failure_emits_visible_diagnostics.
SELF-002 Fixed known project CLI-input failures so diagnostic and terminal status records carry command: "project"; updated edict.cli.diagnostic/v1 schema and xtask guard. Added invalid_project_settings_report_project_command; updated diagnostic_schema_declares_jsonl_contract.

RED: cargo test -p edict-cli project failed with both new regressions.

GREEN:

  • cargo test -p edict-cli project
  • cargo test -p xtask diagnostic_schema_declares_jsonl_contract
  • cargo test -p edict-cli
  • cargo xtask contract-check
  • cargo xtask verify

Self-review after the fix found no additional actionable issues in the final diff.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 2, 2026
@flyingrobots

Copy link
Copy Markdown
Owner Author

Code Lawyer Activity Summary

Consolidated audit queue for this pass. All actionable PR review threads are resolved, and the local gate is green on head 471f346.

ID Source Severity File Commit Outcome
PR-001 PR review P2 crates/edict-cli/src/main.rs 3a0ce62 Syntax-only lex failures now emit visible projection diagnostics and exit deterministically.
PR-002 PR review P2 crates/edict-cli/src/main.rs d006c27 Explicit null projection/check settings are rejected as invalid settings instead of silently defaulting.
PR-003 PR review P2 docs/schemas/edict.compiler-settings.v1.schema.json bba1c48 emit now requires at least one requested projection record in the public settings schema.
PR-004 PR review P2 crates/edict-cli/src/main.rs 3a0ce62 Project command CLI failures now report command: "project" instead of check.
PR-005 PR review P2 crates/edict-cli/src/main.rs 810e4f6 Help exit-code documentation now scopes exit code 1 to the check operation.
SELF-001 Self-audit P5 crates/edict-cli/src/main.rs 471f346 Clippy manual_find finding removed without changing behavior.

Verification evidence:

Gate Result
cargo test -p edict-cli project_syntax_only_lex_failure_emits_visible_diagnostics GREEN
cargo test -p edict-cli invalid_project_settings_report_project_command GREEN
cargo test -p edict-cli projection_object_settings_null_reject_as_invalid_settings GREEN
cargo test -p xtask compiler_settings_schema_declares_jsonl_contract GREEN
cargo test -p edict-cli help_flag_emits_info_record GREEN
cargo test -p edict-cli GREEN
cargo xtask contract-check GREEN
cargo xtask verify GREEN

No new unresolved self-discovered issues remain from the origin/main...HEAD audit.

@flyingrobots

Copy link
Copy Markdown
Owner Author

Self-Discovered Issue Disclosure

@codex please confirm the self-discovered audit item below is fully addressed.

ID Severity File Evidence Fix commit Status
SELF-001 P5 crates/edict-cli/src/main.rs cargo xtask verify reported clippy manual_find in projection settings null-field detection. 471f346 Fixed; final cargo xtask verify is green.

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

  • Confirmed SELF-001 is fully addressed in the current HEAD (471f346). The null-field detection now uses iterator .find(...) directly, which removes the clippy manual_find pattern while preserving the explicit rejection for inputRoot, compilerContext, and target set to JSON null. crates/edict-cli/src/main.rsL384-L440
  • Confirmed regression coverage exists for compilerContext and target null handling across both check and project, including assertions that the CLI emits InvalidSettings, exits with code 2, writes no stdout, and preserves the operation command in diagnostics. crates/edict-cli/tests/jsonl_cli.rsL488-L537
  • Confirmed the public schema also rejects null projection objects by requiring compilerContext to be an object when present; the projection emit contract also requires at least one item. docs/schemas/edict.compiler-settings.v1.schema.jsonL19-L30
  • No repository changes were needed, so I did not create a new commit or call the PR tool.

Testing

  • ⚠️ codex-think --remember --json && pwd && rg --files -g 'AGENTS.md' -g '!target' && git status --short && git log --oneline -5 — warning: codex-think is unavailable in this environment.
  • pwd; find .. -name AGENTS.md -print; git status --short; git log --oneline -8
  • cargo xtask verify
  • git status --short && nl -ba crates/edict-cli/src/main.rs | sed -n '380,445p' && nl -ba crates/edict-cli/tests/jsonl_cli.rs | sed -n '480,535p'
  • nl -ba crates/edict-cli/tests/jsonl_cli.rs | sed -n '535,550p'; nl -ba docs/schemas/edict.compiler-settings.v1.schema.json | sed -n '1,35p'

View task →

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.

1 participant