ext(00-08): RFC-EXT-0003 core/extension boundary, math detach and release stdlib
Implements issue #3 (RFC-EXT-0003) slices on the post-3.0.0-beta.1 tree. PR-00/01/H-06: reproduce and fix sibling heading mode inheritance. build_units now pops the current and same-or-higher-level headings from the ancestor stack before deriving the inherited mode, so an unmarked heading can never inherit the previous sibling. Covered by the units matrix, conformance fixtures 22/23, and black-box heading_inheritance through check --emit/run/call. PR-02/H-08: the deterministic release archive now ships the complete verified stdlib/ tree. package.py and smoke.py recompute the runtime tree/alias digests, record them in RELEASE_INFO.json.stdlib, and fail on mismatch; smoke removes the bundle and requires a fail-closed run. Release discovery no longer falls back to the compile-time source tree (debug builds keep that development convenience). PR-03/H-04: one marqdo_host::CORE_RESOURCE_KINDS registry is used by both the CLI provider-manifest validator and every trusted host registration path; all six core kinds are rejected as provider name or declared kind before registration. H-03: docs/architecture/resource-operations.md records every reviewed resource_request operation and architecture_boundaries pins the exact allowlist; new domain operations are forbidden in core (ADR-0062). PR-04/H-01: remove math.parse/eval/substitute/simplify/differentiate from BUILTINS, HostOp, the runtime, the host kernel and the workspace (crates/marqdo-math deleted). Formula stays inert; Int/Float arithmetic stays. Math algorithms are a pure examples/math-library package plus an optional examples/math-backend ABI plugin that requests the math.compute capability (ADR-0061). Removed calls are static symbol.unknown; the math import namespace is released again. Tests/examples/specs migrated; new math_library black-box test. PR-05/06 Step A: ADR-0060 classifies @exec/@knowledge as the closed Core Modes and specifies the Proposed metadata-only Heading Annotations v1 (target 3.1, sem.invalid_mode_marker unchanged, Analysis v2 unchanged). ADR-0063 records the foreign F-A retention and deferred F-B removal. Docs/status/compatibility/changelog and the RFC-EXT-0003 evidence file are updated. Full local gate: cargo fmt PASS, clippy -D warnings PASS, workspace tests 586 passed/0 failed/2 ignored, python tools/ci 28 passed.
This commit is contained in:
1 parent
0fe5f42a62
commit
a67f344b6b
88 files changed
+2633
-3503
No files matched your search
@@ -0,0 +1,74 @@
|
||||
# ADR-0060: Heading modes are core; heading annotations are declarative metadata
|
||||
|
||||
Status: Accepted (RFC-EXT-0003 H-05/H-07/H-13, post-`3.0.0-beta.1`).
|
||||
Implementation status: **core-mode classification is implemented and tested;
|
||||
Heading Annotations v1 is Proposed and not implemented in this build** (targeted
|
||||
at `3.1.x`). This ADR does not itself make annotations available.
|
||||
Related: RFC-LANG-0002, ADR-0052, [`spec/mapping.md`](../../spec/mapping.md),
|
||||
[`spec/heading-annotations-v1.md`](../../spec/heading-annotations-v1.md).
|
||||
|
||||
## Context
|
||||
|
||||
`@exec`/`@knowledge` look like decorators, which invites the idea that a plugin
|
||||
could redefine them, or add `@agent`/`@test` decorators that change whether a
|
||||
section executes. That would make the same document executable in one installation
|
||||
and inert in another, break `check` ↔ `run` binding equality, and let third-party
|
||||
code affect capability and safety. At the same time, tools genuinely need
|
||||
non-executable heading metadata (test selection, View folding, proof
|
||||
obligations).
|
||||
|
||||
The current parser (`crates/marqdo-frontend/src/units.rs::heading_declaration`)
|
||||
already treats a heading's first plain `Text` prefix as a closed mode token and
|
||||
rejects any other leading `@foo` with `sem.invalid_mode_marker`
|
||||
(`tests/negative/01-invalid-mode-marker-case.expected.json`). Analysis v2
|
||||
`units[]` projects only `id/kind/name/level/span/function`; a `section`,
|
||||
`knowledge` or `namespace` unit does not carry its effective mode or annotation
|
||||
source.
|
||||
|
||||
## Decision
|
||||
|
||||
1. **Two layers, one executor.**
|
||||
- **Core Mode** is the closed set `{@exec, @knowledge}`. It alone decides
|
||||
whether a heading is callable/executable. Unmarked headings inherit the
|
||||
nearest ancestor mode (see `spec/mapping.md` §1.2, including the H-06
|
||||
bugfix). There is no third executable mode and no plugin-defined mode.
|
||||
- **Heading Annotations** are an open, declarative, metadata-only extension
|
||||
layer. They never decide execution.
|
||||
2. **Annotation syntax v1** (Proposed): an ATX heading's first plain `Text` prefix
|
||||
may contain at most one core mode followed by zero or more
|
||||
`@namespace.identifier` annotations, then the semantic title. No parameters in
|
||||
v1; annotations do not inherit; `semantic_name`/`FunctionId`/anchors are derived
|
||||
only from the core mode + normalized title. A malformed/unknown annotation is a
|
||||
static error (`annotation.unknown` or `annotation.malformed`), not silently
|
||||
plain prose; ordinary body text may discuss `@foo`, and a heading-only spelling
|
||||
escape is part of the proposal.
|
||||
3. **No authority.** An annotation may not add/remove callability, rewrite the AST
|
||||
or IR, reorder statements, change budgets, grant a capability, load native code
|
||||
or change an already-bound CallBinding. The runtime ignores annotations.
|
||||
4. **Registration is data, not parse-time code.** Allowed annotations come from
|
||||
explicitly declared, version-pinned project/dependency resources (a static
|
||||
manifest referenced from `marqdo.yaml`), bound to project/lock identity and
|
||||
digest. Duplicate ownership, conflicting names, unknown versions and digest
|
||||
mismatches fail at `check` without executing anything.
|
||||
5. **Analysis projection is versioned.** Do **not** silently add
|
||||
`effective_mode`, `mode_origin` or `annotations` to Analysis v2 `units[]`.
|
||||
Use a new Analysis v3 or a separate `heading-annotations.v1` sidecar carrying
|
||||
unit id, effective core mode, explicit/inherited origin, annotations, source
|
||||
module/span, function/unit id, and manifest owner/digest. Existing
|
||||
Analysis v2 consumers continue to validate unchanged.
|
||||
6. **Step split.** Step A (accepted here) is this contract + parser test design +
|
||||
identity/schema prototype; Step B (3.1) implements descriptor loading, index,
|
||||
conflict checks, the sidecar/v3 projection and independent consumers. Until Step B
|
||||
ships, docs/STATUS must say Proposed/not implemented.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Core-mode behaviour (`@exec`/`@knowledge` + ancestor inheritance) is stable and
|
||||
cannot be overridden by installed tools; the H-06 fix changes only the buggy
|
||||
sibling case.
|
||||
- Tool authors get a safe metadata channel without a plugin parse hook; the runtime
|
||||
never needs to know tool names.
|
||||
- Analysis v2 stays byte-compatible; new metadata needs a versioned sidecar/v3 and an
|
||||
independent black-box consumer before it can be claimed.
|
||||
- `check` and `run` still agree on every call site regardless of which tools are
|
||||
installed.
|
||||
@@ -0,0 +1,64 @@
|
||||
# ADR-0061: Detach the domain math kernel from the core
|
||||
|
||||
Status: Accepted (post-`3.0.0-beta.1`, RFC-EXT-0003 H-01/H-10/H-11).
|
||||
Related: RFC-LANG-0002, ADR-0025, ADR-0032, ADR-0052, ADR-0062.
|
||||
This ADR is an intentional **prerelease incompatibility**; it does not promise
|
||||
zero-cost migration for `3.0.0-beta.1` users.
|
||||
|
||||
## Context
|
||||
|
||||
The core exposed five domain functions as first-class builtins:
|
||||
|
||||
- `math.parse`, `math.eval`, `math.substitute` over an exact-rational subset;
|
||||
- `math.simplify`, `math.differentiate` declared but returning
|
||||
`math.unsupported`.
|
||||
|
||||
They required a core crate (`crates/marqdo-math`) in the host dependency graph,
|
||||
reserved the `math` import namespace forever, made the `HostOp` enum grow with a
|
||||
domain, and were not a complete CAS. Every new math algorithm would either grow
|
||||
the core or be blocked by the reserved namespace. The beta audit (H-01, T-MATH-05/06)
|
||||
recorded this as unintended domain ownership.
|
||||
|
||||
## Decision
|
||||
|
||||
1. **Remove the API from the core surface.** Delete the five `Builtin` entries,
|
||||
the five `HostOp` variants, their dispatch/runtime arms, the reserved
|
||||
`math` namespace as a builtin, and the `marqdo-math` workspace crate. A call
|
||||
to `math.parse/eval/substitute/simplify/differentiate` is a static
|
||||
`symbol.unknown`; there is no `math.unsupported` runtime fallback and no old
|
||||
compatibility parser.
|
||||
2. **Keep only language primitives.** `Int`/`Float` literals, ordinary
|
||||
arithmetic/comparison/control flow, and the inert Markdown `Formula` value
|
||||
(a `$$...$$` block referenced with `ref("#anchor")`) stay in the core. The
|
||||
core never evaluates a `Formula`.
|
||||
3. **Algorithms move out.**
|
||||
- Preferred: a pure `.mq.md` package exposing ordinary Exec H2 functions
|
||||
(`examples/math-library/` shows gcd + a consumer importing it as `math` now
|
||||
that the namespace is released).
|
||||
- Hot path / external data: an explicitly selected Plugin ABI v1 backend that
|
||||
requests the `math.compute` capability (`examples/math-backend/`). Selection
|
||||
is not authorization: native needs `--trust-native-plugin` and every plugin
|
||||
needs `--allow-plugin NAME`; without the grant it is `permission.denied`.
|
||||
4. **`math.compute` stays.** `CORE_CAPABILITIES` may continue to name
|
||||
`math.compute` as a capability **category** requested by an ABI compute
|
||||
backend. It is not a promise that the core ships a solver, parser or evaluator,
|
||||
and pure language arithmetic never requires it.
|
||||
5. **One binding, no fallback.** `check`, `run` and `call` see the same static
|
||||
result for a removed name. New math functions require neither `BUILTINS`,
|
||||
`HostOp`, `Host`, `Value`, `resource_request` nor a CLI rebuild.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Beta users of `math.*` must migrate; `CHANGELOG`/`spec/math.md` carry the
|
||||
removed-name list, the `symbol.unknown` behaviour and a pure-package example.
|
||||
- A `math` import alias is accepted again because no builtin namespace reserves it;
|
||||
`ext.import_namespace_conflict` no longer fires for `math`.
|
||||
- The host no longer links `marqdo-math`; `cargo tree -p marqdo-host`/`-p marqdo-cli`
|
||||
contain no math crate. An architecture gate
|
||||
(`architecture_boundaries.rs`) fails if the crate or `HostOp::Math*` returns.
|
||||
- The exact-rational engine is deleted rather than kept as dead core code. External
|
||||
libraries own their numeric contracts; API and precision are their responsibility.
|
||||
- No Analysis v2, Trace v2, Value wire or capability wire version changes: only a
|
||||
builtin/HostOp surface and one crate are removed, and the static error code is
|
||||
the existing `symbol.unknown`.
|
||||
- No OS sandbox, performance or CAS claim is made.
|
||||
@@ -0,0 +1,62 @@
|
||||
# ADR-0062: Resource-operation ownership and core resource kinds
|
||||
|
||||
Status: Accepted (post-`3.0.0-beta.1`, RFC-EXT-0003 H-03 / H-04).
|
||||
Supersedes nothing; refines ADR-0025, ADR-0033, ADR-0041–0050 and
|
||||
[`spec/resource-provider-v2.md`](../../spec/resource-provider-v2.md).
|
||||
|
||||
## Context
|
||||
|
||||
`Host::resource_request` had grown a mixed catalogue: operating-system
|
||||
primitives (`process.run`, `fs.*`, `env.get`, `clock.now`, `random.bytes`) next to
|
||||
convenience services implemented inside the host (`regex.*`, `compress.*`).
|
||||
Nothing recorded which entries were intentional core surface and which were domain
|
||||
convenience that should become external extensions. Separately, six resource kinds
|
||||
were reserved by `spec/resource-provider-v2.md`, but the trusted host registration
|
||||
path only rejected `stdio` and `file`; only the CLI manifest validator had the full
|
||||
list. A host caller (`register_resource_provider`, `register_c_resource_provider`,
|
||||
`register_worker_resource_provider`, `register_provider_package`) could therefore
|
||||
register a provider named `tcp` or declaring `tls` and shadow core dispatch.
|
||||
|
||||
## Decision
|
||||
|
||||
### 1. One core resource-kind registry
|
||||
|
||||
`marqdo_host::CORE_RESOURCE_KINDS` is the single source of truth:
|
||||
`stdio`, `file`, `tcp`, `tls`, `udp`, `tcp-listener`. Both the CLI provider
|
||||
manifest validator and every host registration path use it. A provider whose `name`
|
||||
is a core kind, or which declares a core kind, is rejected before it enters the
|
||||
resource table with `ResourceUnsupported` (CLI: `ext.manifest_invalid`). A change
|
||||
to the list requires this ADR and the spec to change with it.
|
||||
|
||||
### 2. Two operation classes
|
||||
|
||||
`resource_request` is closed over the following reviewed operations:
|
||||
|
||||
| Class | Operations | Owner |
|
||||
|---|---|---|
|
||||
| Core OS primitive | `process.run`, `env.get`, `clock.now`, `random.bytes`, `fs.read_at`, `fs.append`, `fs.walk`, `fs.exists`, `fs.metadata`, `fs.list`, `fs.mkdir`, `fs.remove`, `fs.rename` | host / OS |
|
||||
| Host-held built-in service | `regex.match`, `regex.captures`, `compress.gzip`, `compress.gunzip` | host library, existing grants |
|
||||
|
||||
`regex.*` and `compress.*` are existing host-held services with their own
|
||||
ADRs; they are not a precedent for adding more domain functions to the host.
|
||||
Project mode and the corresponding capability grant are required for every entry.
|
||||
|
||||
### 3. Extension boundary rule
|
||||
|
||||
New business or domain operations **must not** be added to `resource_request`.
|
||||
A domain function belongs in a pure `.mq.md` package, a Callable Plugin ABI
|
||||
backend, or a Resource Provider — selected and authorized through the normal
|
||||
extension path. Adding an operation to the core table requires a new accepted ADR and
|
||||
an update to [`docs/architecture/resource-operations.md`](../architecture/resource-operations.md),
|
||||
`spec/resource-provider-v2.md` and the architecture gate
|
||||
`crates/cli/tests/architecture_boundaries.rs`.
|
||||
|
||||
## Consequences
|
||||
|
||||
- A host-side provider can no longer shadow a core kind even when it did not pass
|
||||
through the CLI validator; the CLI and host fail with consistent wording.
|
||||
- The reviewed operation list is executable evidence: the architecture test extracts
|
||||
the literals from `resource_request` and fails on unrecorded additions.
|
||||
- `regex.*` / `compress.*` keep working unchanged; moving them out is a separate
|
||||
ADR and is not implied by this one.
|
||||
- No CLI flag, language keyword, wire version or Analysis/Trace schema changes.
|
||||
@@ -0,0 +1,56 @@
|
||||
# ADR-0063: Foreign kernel transition — retain F-A, defer F-B
|
||||
|
||||
Status: Accepted (RFC-EXT-0003 H-02/H-12, post-`3.0.0-beta.1`).
|
||||
Related: ADR-0020, ADR-0044, ADR-0062, [`spec/foreign.md`](../../spec/foreign.md).
|
||||
|
||||
## Context
|
||||
|
||||
The core exposes permission-gated one-shot `foreign.run`/`foreign.call` plus a
|
||||
`KernelRegistry` whose default descriptors are Python/Node but which already
|
||||
accepts dynamically registered languages. The audit (H-02) observed that:
|
||||
`foreign.*` is a controlled **OS process boundary**, not a domain function; the
|
||||
high-level batching/validation/orchestration around it should be a `.mq.md` package;
|
||||
and removing the primitive before a generic process/stream capability exists would
|
||||
push OS behaviour into an unregulated worker without improving safety.
|
||||
|
||||
Two legitimate but conflicting goals: "the frontend/runtime should not know each
|
||||
external language API" (already true — registration is dynamic) versus "Foreign must
|
||||
disappear from the core to count as decoupled" (not automatically true — some layer
|
||||
must own the real OS process/IO boundary).
|
||||
|
||||
## Decision
|
||||
|
||||
**F-A (current, retained):** keep the existing permission-gated one-shot
|
||||
`foreign.run`/`foreign.call` and the dynamic `KernelRegistry` as the controlled
|
||||
OS-boundary primitive.
|
||||
|
||||
- No new language-specific `Builtin`, `HostOp` or runtime branch may be added.
|
||||
New languages register through `KernelRegistry::register`; Python/Node are only
|
||||
default descriptors, not the only extension channel.
|
||||
- High-level orchestration (sequencing, batching, validation, error normalization)
|
||||
belongs in `.mq.md` packages, not in the host.
|
||||
- Grants, digest/target checks, timeout, output caps, typed wire and environment
|
||||
binding stay exactly as `spec/foreign.md` specifies; the security negatives are
|
||||
not weakened by this ADR. Without `--allow-foreign` the call is
|
||||
`permission.denied`; `pure`/`strict` fail closed.
|
||||
|
||||
**F-B (deferred, needs its own ADR + release):** removing `foreign.*` from the
|
||||
core requires first a versioned generic Process/Worker capability contract with at
|
||||
least: program/argv, controlled stdio, isolation level, timeout and process-tree
|
||||
reaping, output budget, environment identity, lifecycle and cancellation
|
||||
semantics. It must demonstrate frozen-binary behavioural equivalence and keep the
|
||||
same permission, digest, timeout, wire and output-limit negatives. Until then the
|
||||
core keeps the primitive and we do not claim it was removed.
|
||||
|
||||
**Forbidden in both phases:** persistent Python/Node sessions, Notebook-cell
|
||||
execution, `@python`-style heading auto-execution, and a second foreign runtime
|
||||
inside View; streaming stays in Execution Events, not a second network protocol.
|
||||
|
||||
## Consequences
|
||||
|
||||
- The core is honest: it owns a controlled foreign primitive and documents it.
|
||||
- Adding a new language needs zero Rust/core changes (T-FOREIGN-01 remains the
|
||||
acceptance test); the default descriptor table may later become a verified static
|
||||
config, but that is not required to decouple domains.
|
||||
- F-B stays open and tracked; docs/STATUS records it as deferred rather than as
|
||||
implemented.
|
||||
+13
-1
@@ -46,4 +46,16 @@ Files: `0001`–`0050`, plus:
|
||||
print magic;
|
||||
* `0059-runtime-observability-and-execution-events.md` — typed host
|
||||
observation facade, Execution Events v1 JSONL boundary, frame identity and
|
||||
selected-value policy.
|
||||
selected-value policy;
|
||||
* `0060-heading-modes-and-extensible-annotations.md` — `@exec`/`@knowledge`
|
||||
are the closed Core Modes; metadata-only Heading Annotations v1 is Proposed
|
||||
(target 3.1), Analysis v2 unchanged;
|
||||
* `0061-detach-domain-math-kernel-from-core.md` — remove `math.*` builtins,
|
||||
`HostOp` variants and `marqdo-math`; pure package + optional ABI backend take
|
||||
over; `Formula`/`math.compute` boundaries;
|
||||
* `0062-resource-operation-ownership-and-core-kinds.md` — single
|
||||
`CORE_RESOURCE_KINDS` registry, two `resource_request` operation classes and
|
||||
the reviewed architecture gate;
|
||||
* `0063-foreign-kernel-transition-fa.md` — retain the permission-gated one-shot
|
||||
foreign primitive as F-A; F-B removal requires a versioned generic
|
||||
process/worker capability.
|
||||
Reference in new issue
Block a user