Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ YAML source (.brd)

Two frontends coexist during migration:
- **The normative YAML frontend** (`frontend::YamlCompiler::compile`, `compiler/frontend`) is
the production path. It is import-free and feeds normalized YAML directly through symbols,
semantic validation, layout, and Schema IR.
the production path. It loads the root and transitive relative-import closure, then feeds
normalized YAML through shared symbols, semantic validation, layout, and Schema IR.
- **A legacy declaration-syntax lexer/parser** (`compiler/parser`, `compiler/ast`) exists only
for parser/AST compatibility testing. It is not wired into the production pipeline, and
import declarations it parses are syntax only — nothing resolves them.
Expand All @@ -124,7 +124,7 @@ treats architecture docs as authoritative "what" and expects code to match them.
| `schema_ir/` | Schema IR builder/validator (`proto/quarry/schema_ir.proto`) |
| `frontend/` | `YamlCompiler` — orchestrates YAML → Schema IR |
| `backend/` | Schema IR → generated C++ output planning and rendering |
| `imports/` | Reserved; no active import-resolution pass exists yet |
| `imports/` | Reserved; production relative-import graph loading lives in `frontend/` |

Each CMake target in `compiler/CMakeLists.txt` corresponds 1:1 to one of these directories
(`quarry_compiler_<name>`), with dependencies flowing strictly downstream along the
Expand Down Expand Up @@ -156,16 +156,16 @@ schema compiler's `--print-generated-code-api-version` query.
### `tools/` — `quarry-schema-compiler`

The CLI entry point (`tools/schema_compiler`) built on the compiler libraries above. It
compiles exactly one `.brd` file through `YamlCompiler` and the backend, and writes generated
files. Supports `--list-outputs` (print planned generated paths without writing),
compiles one `.brd` root and its complete relative-import closure through `YamlCompiler`,
then emits selected namespaces for C, C++ owning/C-storage, Python or Go. Supports `--list-outputs` (print planned generated paths without writing),
`--print-generated-code-api-version` (machine-readable compatibility query used by CMake),
`--version`, `--help`. Full CLI contract and exit codes are documented in `tools/README.md` —
treat that file as the source of truth for flag behavior rather than re-deriving it from code.

### Distribution boundary

Only two things are installed/exported: `Quarry::runtime` (header-only) and
`Quarry::schema_compiler` (executable), plus CMake package files
Installed/exported targets are `Quarry::runtime` (C++ header-only), `Quarry::runtime_c`
(compiled C runtime) and `Quarry::schema_compiler` (executable), plus CMake package files
(`QuarryConfig.cmake`, `QuarryGenerate.cmake`, etc.) and the
`quarry_generate_cpp()` helper. Everything else under `compiler/` (compiler libraries,
Schema IR protobuf), `tests/`, `fuzz/` is a source-tree implementation detail, not a public
Expand Down
13 changes: 12 additions & 1 deletion compiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ and `backend::CodegenOptions` and returns generated files or a backend error.
The compiler does not currently provide:

* a file-loading source compiler facade
* an import resolver
* a package/network import resolver (production YAML relative imports are supported)
* a declaration-syntax production frontend
* a combined source-to-backend facade
* install or export rules for compiler libraries
Expand Down Expand Up @@ -83,3 +83,14 @@ libraries remain source-tree implementation details. There are currently no
for compiler libraries. External compiler-library API shape, package layout,
and stability guarantees are deferred until a real embedding consumer or
packaging requirement exists.

## Stage A configuration boundary

`YamlCompiler::compile` resolves the complete transitive relative-import closure,
rejects cycles and imported configuration documents, and plans all namespaces
before selecting outputs. Multiple files may contribute to one namespace.
The CLI's configuration preparation shares one layout and wire identity with all
backends. Native gid then identifies normalized definitions and dependencies,
independently of schema_id and epochs. Compiler QBS accessors remain internal
tooling. See the [normative contract](../docs/specifications/configuration-and-code-identity.md)
and [readiness evidence](../docs/release-readiness-v0.1.31-rc.1.md).
10 changes: 10 additions & 0 deletions compiler/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,13 @@ storage-policy options still use canonical namespace names. Unprefixed output
is pinned byte for byte in `tests/fixtures/name_prefix/unprefixed_sha256.json`.
See the [source naming contract](../../tools/README.md#deliberate-source-naming-isolation)
and [multi-configuration example](../../examples/truck/multi_configuration/README.md).

## Stage A contract and release migration

Generate dependent namespaces from one authoritative configuration root. Selection
changes emission only; `--name-prefix` isolates deliberately coexisting sets without
changing wire identity. The [normative identity contract](../../docs/specifications/configuration-and-code-identity.md)
and [release notes](../../docs/release-notes-v0.1.31-rc.1.md) distinguish wire
schema_id, native gid and runtime epochs. Regenerate old bindings and rebuild
consumers; equal epochs do not certify native ABI compatibility. Python has
configuration import checks; the native per-namespace gid applies only to C/C++.
10 changes: 10 additions & 0 deletions compiler/backend_c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,13 @@ C++/C-storage wrappers use the same encoded stem; callback language linkage and
identity-bearing external names retain their established rules. Unprefixed
legacy C spellings and #119's general migration remain unchanged. The existing
format-1 generated-code identity hashes the changed definitions normally.

## Stage A contract and release migration

Generate dependent namespaces from one authoritative configuration root. Selection
changes emission only; `--name-prefix` isolates deliberately coexisting sets without
changing wire identity. The [normative identity contract](../../docs/specifications/configuration-and-code-identity.md)
and [release notes](../../docs/release-notes-v0.1.31-rc.1.md) distinguish wire
schema_id, native gid and runtime epochs. Regenerate old bindings and rebuild
consumers; equal epochs do not certify native ABI compatibility. Python has
configuration import checks; the native per-namespace gid applies only to C/C++.
10 changes: 10 additions & 0 deletions compiler/backend_python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,13 @@ storage-policy options still use canonical namespace names. Unprefixed output
is pinned byte for byte in `tests/fixtures/name_prefix/unprefixed_sha256.json`.
See the [source naming contract](../../tools/README.md#deliberate-source-naming-isolation)
and [multi-configuration example](../../examples/truck/multi_configuration/README.md).

## Stage A contract and release migration

Generate dependent namespaces from one authoritative configuration root. Selection
changes emission only; `--name-prefix` isolates deliberately coexisting sets without
changing wire identity. The [normative identity contract](../../docs/specifications/configuration-and-code-identity.md)
and [release notes](../../docs/release-notes-v0.1.31-rc.1.md) distinguish wire
schema_id, native gid and runtime epochs. Regenerate old bindings and rebuild
consumers; equal epochs do not certify native ABI compatibility. Python has
configuration import checks; the native per-namespace gid applies only to C/C++.
15 changes: 7 additions & 8 deletions compiler/parser/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Parser

Owns lexical scanning and syntax parsing for the current schema language.
Owns the legacy declaration-syntax lexer/parser compatibility surface. The
production schema language uses the YAML frontend.

## Lexer Responsibility

Expand Down Expand Up @@ -46,12 +47,11 @@ errors through the diagnostics framework.
Current implementation status:

* the normative `.brd` grammar is defined in `docs/specifications/schema-language.md`
* the current parser implementation is transitional scaffolding for that YAML
grammar
* this declaration parser is legacy compatibility infrastructure, not the YAML grammar
* the repository also contains a separate generic YAML syntax layer under
`compiler/yaml`; it preserves YAML order and source ranges but does not yet
decode Quarry schema vocabulary
* the production-facing YAML orchestration layer now compiles import-free YAML
`compiler/yaml`; its parser preserves YAML order/source ranges, and the separate
schema decoder interprets Quarry vocabulary
* the production-facing YAML orchestration layer resolves transitive YAML relative imports and compiles the configuration
through validated Schema IR without a compatibility AST hop after source-
schema normalization
* the legacy declaration parser and AST remain compatibility infrastructure for
Expand All @@ -61,8 +61,7 @@ Current implementation status:
shape, source identity, source ranges, and parser diagnostics; they do not
require symbol construction or semantic validation
* import declarations remain parser syntax only on the legacy declaration
path; there is no import resolver or multi-file import graph in the current
compiler
path; production YAML has its own multi-file relative-import graph loader
* the current temporary declaration grammar, annotation parsing, and
fixed-size array handling are not normative language contracts
* current annotations are transitional string-valued metadata; the normative
Expand Down
6 changes: 3 additions & 3 deletions compiler/schema_ir/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ Implementation status:

* the normative `.brd` source contract is defined in
`docs/specifications/schema-language.md`
* the production-facing YAML frontend now orchestrates the import-free YAML
pipeline through validated Schema IR directly from the normalized
source-schema model
* the production-facing YAML frontend resolves the complete relative-import
closure and orchestrates validated Schema IR directly from the combined
normalized source-schema model
* direct normalized-source-schema tests under
`tests/yaml/normalized_source_schema_pipeline_test.cpp` provide the primary
Schema IR builder unit coverage
Expand Down
9 changes: 8 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Version resolution and release cleanliness are documented in
[`versioning.md`](versioning.md).

Quarry is a language-neutral schema compiler and BRF serialization system with
production C++, strict-C99 C, and Python backends. The documentation records
production C++, strict-C99 C, Python and Go backends. The documentation records
current behavior and stable architecture decisions separately from deferred
work.

Expand Down Expand Up @@ -213,3 +213,10 @@ When adding or changing documentation:

When two documents need the same concept, keep the full explanation in the most
specific architecture document and add a short reference from the other.

## Stage A release candidate

- [Normative configuration and generated identity](specifications/configuration-and-code-identity.md)
- [Executable CLI guide](stage-a-cli.md)
- [v0.1.31-rc.1 release notes](release-notes-v0.1.31-rc.1.md)
- [Readiness and unresolved release gates](release-readiness-v0.1.31-rc.1.md)
21 changes: 17 additions & 4 deletions docs/compiler-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ separate from the compact runtime manifest.

## Import Resolution Policy

There is no active import-resolution stage in the current repository.
Import declarations remain legacy parser syntax only and are ignored by the
current downstream compiler pipeline.
Production YAML compilation resolves transitive relative imports through the
frontend graph loader before shared symbols, semantics and layout. Canonical paths
are loaded once and cycles are rejected. Legacy declaration-syntax imports remain
parser-only compatibility syntax; no package/network import resolver exists.

---

Expand Down Expand Up @@ -385,7 +386,8 @@ C/C++ backends additionally compute generated-code identity for each namespace
and variant over the complete configuration in dependency order. Format 1 hashes
normalized generated definitions, the supplied wire configuration identity and
direct dependency identities, including unselected namespaces and their effective
storage policies. `--generate` and output naming do not affect the result. This
storage policies. `--generate`, output directories, extensions and root-file stems do not affect
the result. `--name-prefix` can change emitted definitions and therefore gid. This
is generation-time metadata, with no runtime Schema IR interpretation or hashing.
It is distinct from both wire `schema_id` and the generated/runtime API epoch;
see [the identity specification](design/configuration-identity.md#161-computation)
Expand All @@ -406,3 +408,14 @@ Open questions for later specifications or implementation documents:
* whether Schema IR should remain an in-memory compiler structure only, or also
have a serialized debug/tooling representation for documentation generators,
compatibility checkers, visualization tools, and IDE integrations

## Stage A implementation boundary

A1–A5 are merged; A6 reconciles specifications and release evidence. The
[normative identity contract](specifications/configuration-and-code-identity.md)
defines configuration, generated definitions and epochs separately. QBS identity
accessors read stored metadata without introducing runtime hashing or Schema IR
dependencies. `--describe` reports resolved IDs, identity, formats and epochs;
exact release tags are informational build metadata. Discovery, descriptors,
partial images and translation remain Stage B proposals. See the
[readiness report](release-readiness-v0.1.31-rc.1.md).
44 changes: 27 additions & 17 deletions docs/compiler-passes.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,16 @@ validation as an unsupported v0.1 construct; see `compiler/backend/README.md`
for the exact supported array element type set.

The `compiler/frontend` orchestration layer now exposes a production-facing
import-free YAML compilation path through validated Schema IR. That layer now
import-aware YAML compilation path through validated Schema IR. That layer now
builds symbols, semantic state, and Schema IR directly from the normalized
source-schema model. AST remains in use only for the independent legacy
declaration-syntax parser and AST tests. The legacy declaration parser remains
available during the migration.

Source loading remains outside the compiler passes. Callers register source
text with `SourceManager`, receive a `SourceFileId`, and parse exactly one
registered source file per parser invocation. There is no import-resolver
pass in the current repository; import declarations remain syntax only on the
legacy AST path and are ignored by downstream passes.
Root source registration remains caller-owned: callers register text with
`SourceManager` and receive a `SourceFileId`. Production `YamlCompiler` loads
relative imports through its graph loader. Each parser invocation parses one
registered unit. Legacy AST imports remain syntax only.
There is no production root-source loading facade for declaration syntax yet;
file loading and source registration remain caller-owned.
The legacy declaration-syntax frontend is compatibility infrastructure rather
Expand Down Expand Up @@ -173,15 +172,15 @@ or layout computation.

---

## 2. Import Resolution Status
## 2. Production YAML import loading

There is no import-resolver pass in the current repository. Import
declarations remain legacy AST syntax only. The parser retains them for
compatibility with historical `.brd` files, but downstream passes ignore them
and no production stage loads imported files, resolves import names to files,
or builds a document graph.

---
`frontend::YamlCompiler` loads the root's transitive relative-import graph,
canonicalizes paths, loads each once and rejects cycles before downstream layout.
A configuration root (`configuration` and `imports` only) owns no declarations
and cannot be imported. A record root also defines a configuration. Every source
unit contributes to the shared normalized/symbol/semantic models; namespaces may
span files. The legacy declaration parser retains imports as syntax only and is
not the production loader. No package or network import resolver is implied.

## 3. Namespace Builder

Expand Down Expand Up @@ -216,8 +215,7 @@ Required by:

### Assumptions on Input

The schema has already had unsupported YAML imports rejected and normalized
identifiers validated.
The complete YAML import closure has been loaded and normalized identifiers validated.

### Responsibilities

Expand All @@ -234,7 +232,7 @@ identifiers validated.
* every registered declaration has a fully qualified name
* namespace nesting is represented canonically
* duplicate symbols have been rejected
* import declarations remain syntax only and do not produce symbols
* imported declarations participate in the shared symbol index; import directives do not become symbols

### Diagnostics Emitted

Expand Down Expand Up @@ -585,3 +583,15 @@ Internal compiler errors indicate compiler defects rather than user errors.
Schema IR is produced only if all compilation passes complete successfully.

Backends are never invoked after fatal compilation failures.

## Configuration preparation and generation

After validated Schema IR, `tools/schema_compiler/configuration_preparation.hpp`
prepares the canonical BRF layout and algorithm-1 wire configuration identity once.
QBS and every backend consume those values; listing outputs uses planning without
hashing. Native backends then compute per-namespace format-1 gid in dependency
order, including unselected dependencies and effective storage policies. Selection
controls emission, never the resolved configuration or record IDs. Prefixing is a
backend naming projection. See [compiler architecture](compiler-architecture.md#configuration-preparation),
[the identity contract](specifications/configuration-and-code-identity.md) and
[CLI verification](stage-a-cli.md).
13 changes: 8 additions & 5 deletions docs/design/c-backend.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# C Backend

> Current status (PR-139): the C backend supports compiler-resolved
> cross-namespace enum and record fields, including arrays, by consuming
> `OutputPlan` dependency metadata and emitting deterministic generated-header
> includes. Referenced namespaces are generated from the same compilation root.
> Nested arrays and recursive by-value records remain out of scope.
> Stage A status: C/C++-storage epoch 7, header bindings backed by the shared C
> codec, with include-only compatibility `.c`/`.cpp` stubs. Relative-import
> dependencies, configuration/gid checks, per-namespace storage and explicit
> prefixes are implemented. The original proposal and milestone history below
> (including epoch-2 and split-source recommendations) are historical, not the
> current generation contract. See `compiler/backend_c/README.md` and
> `docs/specifications/configuration-and-code-identity.md`. Nested arrays and
> recursive by-value records remain unsupported.

## Implementation Status

Expand Down
Loading
Loading