Skip to content

feat: P0/M0 foundation - #15

Merged
viethqb merged 8 commits into
mainfrom
feat/p0-m0-foundation
Oct 24, 2026
Merged

viethqb merged 8 commits into
mainfrom
feat/p0-m0-foundation

Conversation

@viethqb

@viethqb viethqb commented Oct 24, 2026

Copy link
Copy Markdown
Member

Summary

Implements milestone M0 Foundation of the P0 roadmap, following the M0 plan.

  • Workspace and CI: Cargo workspace on Rust 1.99.0 (edition 2024). CI runs fmt, clippy -D warnings and test, all with --locked.
  • egret-engine-common: the Role type, plus configuration loaded from defaults, then a TOML file, then EGRET_ENGINE__* environment variables (figment, deny_unknown_fields).
  • egret-engine-pgwire: serves the PostgreSQL simple query protocol, with one DataFusion SessionContext per connection.
    • Statements in a query run sequentially. If one fails, the client gets the results of the earlier statements, then the error, and the rest of the batch is skipped.
    • SQLSTATE: 42601 for syntax errors, XX000 for everything else.
    • CREATE EXTERNAL TABLE and COPY ... TO are rejected with 0A000, including inside EXPLAIN ANALYZE, because M0 has no authentication.
  • egret-engine-server: the egret-engine binary, with --config and --role (the worker role is rejected until M2), tracing logs, and graceful shutdown on Ctrl-C or SIGTERM.
  • README: a Getting started section. The example binds to localhost and warns that M0 has no authentication.

Changes beyond the plan text, from the final review

  • Sequential execution. The plan's handler started every statement before sending any results, so DML did not run in order: INSERT followed by SELECT count(*) in one query returned a stale count. It now runs and sends one statement at a time.
  • File access. The plan did not cover CREATE EXTERNAL TABLE or COPY ... TO. With no authentication, any client could use them to read or write local files, so both are now rejected.
  • README. The plan's example bound 0.0.0.0; it now uses 127.0.0.1.
  • Ctrl-C. If the Ctrl-C handler cannot be registered, the server keeps running instead of shutting down at once.

Design follow-ups are recorded on #8 (M1: build the session after startup, share one RuntimeEnv, 42P01) and #12 (M5: PostgreSQL compatibility gaps).

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo test --workspace --locked: 31 passed (common 9, pgwire 5 unit + 11 protocol, server 3, cli 3)
  • Manual exit criterion: psql -c "SELECT 1 AS one, 'hello' AS greeting" against the binary returns 1 row; Ctrl-C logs egret-engine stopped and exits 0
  • CI green on this PR

Closes #7

🤖 Generated with Claude Code

viethqb and others added 8 commits October 24, 2026 14:43
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
…ment

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
…taFusion sessions

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… graceful shutdown

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…r results

Each statement of a simple query is now planned, executed and sent to the
client before the next one is planned, so DML and SELECTs observe the effects
of earlier statements. When a statement fails, the results already sent stay
with the client, followed by the ErrorResponse; the remaining statements are
skipped, matching PostgreSQL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without authentication in M0, these statements let any client read and
write arbitrary local files. Tables come from Iceberg catalogs, so neither
is product surface. Plans containing either node, including under
EXPLAIN ANALYZE, are rejected before execution with feature_not_supported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ssing auth

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failed registration completed the shutdown future immediately and stopped
the server with exit code 0. Log a warning and wait forever instead, as the
SIGTERM branch does, which now logs its failure too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@viethqb
viethqb merged commit d0130bc into main Oct 24, 2026
1 check passed
@viethqb
viethqb deleted the feat/p0-m0-foundation branch October 24, 2026 08:53
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.

P0/M0: Foundation

1 participant