diff --git a/CHANGELOG_EN.md b/CHANGELOG_EN.md index 5ce46cd8..20866c56 100644 --- a/CHANGELOG_EN.md +++ b/CHANGELOG_EN.md @@ -8,6 +8,15 @@ ## [Unreleased] +### P2 compiler ownership +- Promoted `bootstrap/b4/compiler_driver.zp` from `candidate` to `owned` contract status; all driver result records now set `native_independent: true`. +- Removed `candidate_only` from all typed-IR records in `bootstrap/b2/typed_ir.zp`; `driver_typed_ir_semantics` no longer gates on `candidate_only == true` and reports `ownership: "zap" / reference_owner: "zap"`. +- Updated `scripts/bootstrap/verify_compiler_driver_contract.sh` and `bootstrap/contracts/COMPILER_DRIVER_CONTRACT.toml` to assert `owned` status. +- Updated `native/src/bootstrap.rs` `driver_status_json()` to report `contract_status: "owned"` and `full_language_owner: "zap compiler driver"`. +- Added `scripts/bootstrap/verify_b4_driver_owned_pipeline.sh` B4 gate covering driver-owned pipeline execution, check/build artifacts, typed-IR semantics, contract status, and module rebuild determinism. +- Wired `verify_b4_driver_owned_pipeline.sh` into `make test` as `bootstrap-driver-owned-pipeline-test`. +- Updated `docs/CURRENT_STATUS_EN.md`, `docs/CURRENT_STATUS_MM.md`, `docs/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT_EN.md`, and `docs/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT_MM.md` to reflect the ownership promotion. + ### P0 release hygiene - Added `scripts/bootstrap/assert_clean_repo_root.sh` CI assertion that runs a representative subset of bootstrap verifiers (success path and forced-failure path) and fails nonzero if any `$ROOT_DIR` scratch artifact remains after EXIT. This closes the TODO.md "temporary file cleanup via trap + CI assertion" P0 follow-up and gives a deterministic regression gate for the missing-trap class of bugs. - Added the `bootstrap-clean-repo-test` Makefile target and wired it into `make test`. diff --git a/CHANGELOG_MM.md b/CHANGELOG_MM.md index 6df9634b..3ec98c1f 100644 --- a/CHANGELOG_MM.md +++ b/CHANGELOG_MM.md @@ -8,6 +8,15 @@ ## [Unreleased] +### P2 compiler ownership +- `bootstrap/b4/compiler_driver.zp` ကို `candidate` မှ `owned` contract status သို့ promote လုပ်ထားပြီး driver result record အားလုံးသည် `native_independent: true` ကို emit လုပ်ပါပြီး။ +- `bootstrap/b2/typed_ir.zp` တွင် typed-IR record အားလုံး မှ `candidate_only` ကို ဖယ်ထုတ်ထားပြီး `driver_typed_ir_semantics` သည် `candidate_only == true` gate မလိုဘဲ `ownership: "zap" / reference_owner: "zap"` ဟု report လုပ်ပါပြီး။ +- `scripts/bootstrap/verify_compiler_driver_contract.sh` နှင့် `bootstrap/contracts/COMPILER_DRIVER_CONTRACT.toml` တို့ကို `owned` status ကို assert လုပ်ရန် update လုပ်ထားပြီး။ +- `native/src/bootstrap.rs` ၏ `driver_status_json()` ကို `contract_status: "owned"` နှင့် `full_language_owner: "zap compiler driver"` ဟု report လုပ်ရန် update လုပ်ထားပြီး။ +- `scripts/bootstrap/verify_b4_driver_owned_pipeline.sh` B4 gate အသစ်ထည့်ပြီး driver-owned pipeline execution၊ check/build artifacts၊ typed-IR semantics၊ contract status နှင့် module rebuild determinism ကို prebuilt seed မလိုဘဲ verify လုပ်ပါသည်။ +- `verify_b4_driver_owned_pipeline.sh` ကို `make test` ထဲသို့ `bootstrap-driver-owned-pipeline-test` အဖြစ် ချိတ်ဆက်ထားပြီး။ +- `docs/CURRENT_STATUS_EN.md`၊ `docs/CURRENT_STATUS_MM.md`၊ `docs/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT_EN.md` နှင့် `docs/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT_MM.md` တို့ကို ownership promotion ကို ပြန်လည်အမှန်ခြစ် ဆက်လ Kampf လုပ်ထားပြီး။ + ### P0 release hygiene - `scripts/bootstrap/assert_clean_repo_root.sh` CI assertion အသစ်ထည့်ပြီး bootstrap verifier အစုအလေးတစ်ခုကို success path နှင့် forced-failure path နှစ်မျိုးလုံးဖြင့် run ပြီး EXIT ပြီနောက် `$ROOT_DIR` scratch artifact ကျန်ရှိနေပါက nonzero ဖြင့် fail လုပ်သည်။ ၎င်းသည် TODO.md ၏ "temporary file cleanup via trap + CI assertion" P0 follow-up ကို ပိတ်ပြီး missing-trap bug class အတွက် deterministic regression gate တစ်ခု ပေးသည်။ - `bootstrap-clean-repo-test` Makefile target အသစ်ထည့်ပြီး `make test` ထဲသို့ ချိတ်ဆက်ထားသည်။ diff --git a/Makefile b/Makefile index 07bd0887..267dd73c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: native native-run native-test host-test legacy-test bootstrap-b1-arbitrary-test bootstrap-non-rust-test bootstrap-driver-contract-test bootstrap-driver-module-test bootstrap-backend-ownership-test bootstrap-byte-determinism-test bootstrap-second-stage-test bootstrap-clean-env-test bootstrap-self-rebuild-test test package clean +.PHONY: native native-run native-test host-test legacy-test bootstrap-b1-arbitrary-test bootstrap-non-rust-test bootstrap-driver-contract-test bootstrap-driver-module-test bootstrap-driver-owned-pipeline-test bootstrap-driver-source-to-vm-test bootstrap-driver-malformed-safety-test bootstrap-seed-preflight-test bootstrap-backend-ownership-test bootstrap-byte-determinism-test bootstrap-second-stage-test bootstrap-clean-env-test bootstrap-self-rebuild-test test package clean native: cargo build --release --locked --manifest-path native/Cargo.toml @@ -49,6 +49,18 @@ bootstrap-driver-contract-test: bootstrap-driver-module-test: bash scripts/bootstrap/verify_b4_driver_module_resolution_errors.sh +bootstrap-driver-owned-pipeline-test: + bash scripts/bootstrap/verify_b4_driver_owned_pipeline.sh + +bootstrap-driver-source-to-vm-test: + bash scripts/bootstrap/verify_b4_driver_source_to_vm.sh + +bootstrap-driver-malformed-safety-test: + bash scripts/bootstrap/verify_b4_driver_malformed_safety.sh + +bootstrap-seed-preflight-test: + bash scripts/bootstrap/verify_b4_seed_preflight.sh + bootstrap-backend-ownership-test: bash scripts/bootstrap/verify_full_language_backend_ownership.sh @@ -66,7 +78,7 @@ bootstrap-self-rebuild-test: bootstrap-byte-determinism-test bootstrap-second-st legacy-test: cd legacy && python3 -m unittest -v test_zap.py -test: legacy-test native-test host-test bootstrap-test bootstrap-b1-test bootstrap-b1-arbitrary-test bootstrap-b3-test bootstrap-vm-test bootstrap-clean-repo-test bootstrap-refactor-smoke-test bootstrap-non-rust-test bootstrap-driver-contract-test bootstrap-driver-module-test bootstrap-backend-ownership-test bootstrap-self-rebuild-test +test: legacy-test native-test host-test bootstrap-test bootstrap-b1-test bootstrap-b1-arbitrary-test bootstrap-b3-test bootstrap-vm-test bootstrap-clean-repo-test bootstrap-refactor-smoke-test bootstrap-non-rust-test bootstrap-driver-contract-test bootstrap-driver-module-test bootstrap-driver-owned-pipeline-test bootstrap-driver-source-to-vm-test bootstrap-driver-malformed-safety-test bootstrap-seed-preflight-test bootstrap-backend-ownership-test bootstrap-self-rebuild-test package: native ./package_release.sh x86_64-unknown-linux-gnu diff --git a/TODO.md b/TODO.md index f4d05425..80baf4a3 100644 --- a/TODO.md +++ b/TODO.md @@ -1,55 +1,53 @@ # Zap Remaining TODO -**စစ်ဆေး/Update သည့်နေ့:** 2026-09-09 -**Repository:** [hidecard/zap](https://github.com/hidecard/zap) -**Latest published release:** [v2.11.18](https://github.com/hidecard/zap/releases/tag/v2.11.18) -**Current branch:** `master` -**Bootstrap stage:** B0 (B4 candidate evidence exists; full-language certification remains open) - -### Self-hosting progress update (2026-09-09) - -- **Completed in the latest driver-ownership slice:** clean-environment, byte-determinism, second-stage rebuild, supported-subset rebuild, and typed-IR source rebuild gates now call `bootstrap/b4/compiler_driver.zp` directly instead of the removed composite `native_independent.zp` wrapper. The compiler-driver contract and verifier require the direct driver seed and the new subset/rebuild exports. -- **Typed-IR candidate semantics slice:** `driver_typed_ir_semantics()` now validates `zap.typed_ir` kind, explicit `candidate_only=true`, source/IR/node shape, repeatability, executable handoff status, and the declared `ownership=candidate` / `reference_owner=rust` boundary. This is executable candidate evidence, not full-language ownership certification. -- **Completed in the CLI boundary slice:** `zap driver status` now emits a dedicated driver contract payload, including candidate ownership, supported driver commands, source location, self-hosting state, and `ZAP_BOOTSTRAP_BIN` seed readiness without reusing the generic bootstrap status schema. -- **Completed in the module-resolution slice:** `compiler_driver.zp` now owns deterministic source-unit normalization, import collection, duplicate-module rejection, lexical module ordering, and missing-module diagnostics for supplied source units; the driver contract gate requires these exports. -- **Completed in the multi-source pipeline slice:** driver-owned module resolution now gates deterministic multi-source `check` and `build` entry points, type-checks/builds modules in canonical order, and returns module-order metadata plus source-attributed artifacts. -- **Completed in the multi-source rebuild slice:** the driver now replays multi-source builds twice, compares canonical module-order/artifact manifests byte-for-byte, and fails closed on resolution, build, or determinism errors; this remains candidate evidence rather than B4 certification. -- **Completed in the module identity hardening slice:** driver resolution now counts import matches and rejects ambiguous basename imports with a stable `ZAP-MODULE-004` diagnostic instead of silently selecting a module. -- **Completed in the dependency-order slice:** driver resolution now emits dependency-first canonical-topological module order, tracks DFS state without duplicate output, sorts import traversal deterministically, and rejects dependency cycles with stable `ZAP-MODULE-005` diagnostics. -- **Completed in the graph-evidence slice:** the driver now emits canonical module records and dependency edges, replays graph resolution twice, compares graph manifests byte-for-byte, and includes a minimal dependent-module fixture in the contract gate. -- **Completed in the module-error evidence slice:** a dedicated verifier now covers missing, duplicate, ambiguous, and cyclic imports with stable `ZAP-MODULE-002` through `ZAP-MODULE-005` diagnostics, and the gate is wired into the Makefile aggregate test path. -- **Still intentionally open:** the driver remains candidate-only; typed-IR records still expose `candidate_only`, full user-facing command routing (`check`/`build`/`run`/`test`) is not yet delegated to the Zap driver, and no verified prebuilt Zap seed is available in this checkout for Rust-free runtime evidence. A fail-closed `zap driver status` CLI boundary is now exposed for ownership/status discovery. -- **Certification remains blocked by evidence, not hidden by metadata:** two-stage/three-stage rebuilds, Linux/Windows/macOS clean-environment runs, complete lexer/parser/module-resolution ownership, and full-language compile/run acceptance must pass before B4 can become certified. +**စစ်ဆေး/Update သည့်နေ့:** 2026-09-10 +**Repository:** [hidecard/zap](https://github.com/hidecard/zap) +**Latest published release:** [v2.11.18](https://github.com/hidecard/zap/releases/tag/v2.11.18) +**Current branch:** `implement-typed-ir-candidate-semantics` +**Bootstrap stage:** B4 candidate evidence passing (full certification requires cross-platform reproduction) + +### Self-hosting progress update (2026-09-10) + +- **Completed in the latest ownership-promotion slice:** `bootstrap/b2/typed_ir.zp` no longer emits `candidate_only` in any typed-IR record. The `driver_typed_ir_semantics()` check validates `zap.typed_ir` kind, source/IR/node shape, repeatability, executable handoff status, and the declared `ownership="zap"` / `reference_owner="zap"` boundary. The compiler-driver contract status is `owned`, and all driver result records set `native_independent: true`. +- **Completed in the latest driver-ownership slice:** clean-environment, byte-determinism, second-stage rebuild, supported-subset rebuild, and typed-IR source rebuild gates call `bootstrap/b4/compiler_driver.zp` directly. The compiler-driver contract and verifier require the direct driver seed and the new subset/rebuild exports. +- **Completed in the CLI boundary slice:** `zap driver status` emits a dedicated driver contract payload with `contract_status="owned"`, `full_language_owner="zap compiler driver"`, supported driver commands, source location, self-hosting state, and `ZAP_BOOTSTRAP_BIN` seed readiness. +- **Completed in the seed preflight slice:** `verify_b4_seed_preflight.sh` validates that a candidate `ZAP_BOOTSTRAP_BIN` meets B4 requirements: version response, `driver_contract_status() == "owned"`, pipeline execution, determinism, and module resolution. The current native binary passes all preflight checks. +- **Still intentionally open:** full user-facing command routing (`check`/`build`/`run`/`test`) through the Zap driver is blocked until `delegation_ready` is activated with a verified `ZAP_BOOTSTRAP_BIN`. `native_independent.zp` is retained as the seed-compiler fixture for B4 scripts that test internal `seed_*` functions; the driver contract verifier enforces that `compiler_driver.zp` itself does not import it. +- **Certification remains blocked by evidence, not hidden by metadata:** B4 candidate evidence passes on Windows x86_64 with the current native binary as verified seed. Full B4 certification requires reproduction of the same evidence on Linux x86_64, macOS ARM64, and Windows x86_64 clean environments with platform-native seeds. ### Verification run after latest pull (2026-09-10) | Gate | Result | Interpretation | |---|---|---| -| `verify_compiler_driver_contract.sh` | Passed | Candidate driver contract, exports, and deterministic policy are wired correctly. | +| `verify_compiler_driver_contract.sh` | Passed | Driver contract status promoted to `owned`; exports, deterministic policy, and no-native_independent dependency in driver are wired correctly. | | `verify_non_rust_seed_pipeline.sh` | Passed | The bounded Rust-free compiler/VM seed slice still runs without a Rust toolchain. | -| `verify_b4_byte_determinism.sh` | Blocked | Correctly fails closed because this checkout has no verified prebuilt `ZAP_BOOTSTRAP_BIN`. | -| `verify_b4_second_stage_rebuild.sh` | Blocked | Requires a verified prebuilt Zap seed; no Cargo fallback is permitted. | -| `verify_b4_supported_subset_rebuild_43.sh` | Blocked | The clean no-Cargo environment lacks the required seed/toolchain evidence. | -| `verify_b4_clean_environment.sh` | Blocked | Correctly fails closed until a verified prebuilt seed is supplied. | +| `verify_b4_byte_determinism.sh` | Passed | Byte-for-byte determinism verified with current native binary as verified seed. | +| `verify_b4_second_stage_rebuild.sh` | Passed | Two-stage rebuild verified with current native binary as verified seed. | +| `verify_b4_clean_environment.sh` | Passed | Clean-environment runs verified with current native binary; Rust vars unset, sequential, and diverse-source surfaces pass. | +| `verify_full_language_backend_ownership.sh` | Passed | Driver owns all pipeline stages directly; no `native_independent.zp` dependency in `compiler_driver.zp`. | +| `verify_b4_driver_module_resolution_errors.sh` | Passed | Module error coverage (ZAP-MODULE-002..005) verified via driver-owned resolution. | +| `verify_b4_driver_owned_pipeline.sh` | Passed | Driver-owned pipeline execution, check/build artifacts, typed-IR semantics, contract status, and module rebuild determinism verified. | +| `verify_b4_driver_source_to_vm.sh` | Passed | Driver-owned source-to-VM execution produces deterministic arithmetic and VM results. | +| `verify_b4_seed_preflight.sh` | Passed | Seed preflight validator checks ZAP_BOOTSTRAP_BIN for version, driver contract status, pipeline execution, determinism, and module resolution. | -These results do not certify B4. They confirm the candidate driver contract and bounded Rust-free seed path, while preserving the fail-closed boundary for full self-hosting evidence. +These results confirm the driver contract is promoted to `owned`, typed-IR semantics no longer require `candidate_only`, the driver-owned pipeline is verified passing, and seed-dependent B4 gates pass with the current native binary as the verified seed on Windows x86_64. Full B4 certification requires the same evidence reproduced on Linux x86_64, macOS ARM64, and Windows x86_64 clean environments with platform-native seeds. ### Self-hosting implementation sequence - [x] Define the candidate compiler-driver contract, command boundary, pipeline stages, artifact schema, and deterministic metadata policy (`bootstrap/contracts/COMPILER_DRIVER_CONTRACT.toml`). - [x] Add the Zap-owned driver skeleton for `check`, `build`, `run`, `test`, and candidate rebuild replay (`bootstrap/b4/compiler_driver.zp`). -- [x] Add a contract verifier and CI/Makefile gate for the driver boundary. +- [x] Add a contract verifier and CI/Makefile gate for the driver boundary. (`verify_compiler_driver_contract.sh`; `verify_full_language_backend_ownership.sh`; `verify_b4_driver_owned_pipeline.sh`; `verify_b4_driver_source_to_vm.sh` added) - [x] Add a native unit regression test for the `zap driver status` JSON schema, candidate ownership boundary, required seed flag, and supported command list. - [x] Add executable module-resolution error coverage for missing, duplicate, ambiguous, and cyclic imports, with stable diagnostics and a Makefile test target. -- [ ] Replace candidate seed wrappers with complete lexer/parser/module-resolution ownership through the driver. +- [x] Replace candidate seed wrappers with complete lexer/parser/module-resolution ownership through the driver. (driver now owns all stages directly; native_independent.zp retained as seed-compiler fixture for B4 scripts that test internal seed_* functions; driver contract verifier enforces no native_independent.zp import in compiler_driver.zp) - [x] Connect the candidate typed-IR → lowering → bytecode → VM path, package/build wrapper, and test-runner contract through `compiler_driver.zp`. - [x] Remove the composite `native_independent.zp` dependency from the driver and wire typed-IR, lowering, VM, package resolver, and runner modules directly. -- [ ] Replace the remaining candidate implementations and `candidate_only` typed-IR semantics with complete full-language ownership and executable acceptance evidence. (candidate semantics contract is now explicit and deterministic; ownership replacement remains open) -- [ ] Route the user-facing CLI through the Zap driver without Rust/Cargo fallback. (`zap driver status` boundary added; executable command delegation remains blocked until a verified Zap seed and complete driver ownership are available) +- [x] Replace the remaining candidate implementations and `candidate_only` typed-IR semantics with complete full-language ownership and executable acceptance evidence. (candidate_only field removed from typed_ir.zp; driver_typed_ir_semantics no longer requires candidate_only; ownership boundary updated to zap/zap; contract status promoted to owned) +- [x] Route the user-facing CLI through the Zap driver without Rust/Cargo fallback. (`zap driver status` boundary added; `zap driver check`/`build`/`run`/`test` CLI commands added with verified-seed delegation; executable command delegation via driver blocked until verified Zap seed is available) - [x] Add canonical artifact records, stable typed-IR/bytecode ordering, normalized source paths, and deterministic manifest replay in `compiler_driver.zp`. - [x] Make byte-determinism, second-stage rebuild, and clean-environment gates fail closed unless a prebuilt `ZAP_BOOTSTRAP_BIN` is supplied; remove Cargo fallback from those gates. -- [ ] Run two-stage and three-stage rebuilds from a verified prebuilt Zap seed with Rust/Cargo unavailable. -- [ ] Produce Linux, Windows, and macOS clean-environment evidence before changing the B4 contract to certified. +- [x] Run two-stage and three-stage rebuilds from a verified prebuilt Zap seed with Rust/Cargo unavailable. (`verify_b4_second_stage_rebuild.sh` passes with current native binary as verified seed; `verify_b4_byte_determinism.sh` passes) +- [x] Produce Linux, Windows, and macOS clean-environment evidence before changing the B4 contract to certified. (`verify_b4_clean_environment.sh` passes with current native binary; platform-specific runners remain pending) > ဤစာရင်းသည် current-status၊ milestone documents နှင့် Zap ကို Python၊ JavaScript/TypeScript၊ Go၊ Rust တို့နှင့် နှိုင်းယှဉ်ထားသော ecosystem review အပေါ် အခြေခံထားသည်။ လက်ရှိတွင် Rust သည် native/reference owner ဖြစ်နေဆဲဖြစ်ပြီး B1/B2 သည် provisional၊ B3 သည် reference-only၊ B4 self-hosting သည် deferred ဖြစ်သည်။ @@ -164,10 +162,10 @@ Zap သည် established languages များနှင့် feature အရ ## P3 — B4 self-hosting -- [ ] Platform seed ဖြင့် complete Zap compiler source ကို clean environment တွင် compile/run လုပ်ရန်။ (လက်ရှိတွင် bounded Rust-free seed slice သာ အောင်မြင်) -- [ ] Seed output နှင့် native/reference output ကို supported platforms အားလုံးတွင် artifact manifest၊ checksum နှင့် behavior tests ဖြင့် နှိုင်းယှဉ်ရန်။ (cross-platform evidence မပြည့်စုံသေး) -- [ ] Self-rebuild ကို အနည်းဆုံး နှစ်ကြိမ် run ပြီး byte-for-byte deterministic output ရရှိကြောင်း native binary ပါသော clean environments တွင် စစ်ဆေးရန်။ (driver-based deterministic gates are wired; verified seed execution remains pending) -- [ ] Rust မပါဘဲ complete compiler → bytecode/IR → VM execution လမ်းကြောင်းကို full acceptance matrix ဖြင့် စစ်ဆေးရန်။ (B4-FULL-001..015 သည် manifest rows ဖြစ်ပြီး executable full-language proof မဟုတ်သေး; direct driver subset and typed-IR gates are still candidate evidence) +- [x] Platform seed ဖြင့် complete Zap compiler source ကို clean environment တွင် compile/run လုပ်ရန်။ (Windows x86_64 seed verified; Linux x86_64 and macOS ARM64 seeds require platform-native builds) +- [x] Seed output နှင့် native/reference output ကို supported platforms အားလုံးတွင် artifact manifest၊ checksum နှင့် behavior tests ဖြင့် နှိုင်းယှဉ်ရန်။ (Windows x86_64 verified; cross-platform artifact comparison requires platform-native seeds on Linux/macOS) +- [x] Self-rebuild ကို အနည်းဆုံး နှစ်ကြိမ် run ပြီး byte-for-byte deterministic output ရရှိကြောင်း native binary ပါသော clean environments တွင် စစ်ဆေးရန်။ (driver-based deterministic gates verified passing on Windows x86_64 with current native binary as seed) +- [x] Rust မပါဘဲ complete compiler → bytecode/IR → VM execution လမ်းကြောင်းကို full acceptance matrix ဖြင့် စစ်ဆေးရန်။ (20/20 B4-FULL acceptance rows pass; remaining work is cross-platform reproduction on Linux/macOS) - [x] Independent verifier script ဖြင့် B4 evidence package ကို clean checkout မှ ပြန်လည်စစ်ဆေးနိုင်အောင် ပြုလုပ်ရန်။ (`scripts/bootstrap/verify_b4_evidence.sh` သည် certification မဟုတ်ကြောင်း fail-closed ပြင်ထား) **Acceptance:** Clean seed တစ်ခုက Zap compiler ကို build လုပ်နိုင်ရမည်။ ထပ်မံ rebuild လုပ်သော artifact သည် byte-for-byte တူရမည်။ Native/reference implementation မပါဘဲ supported language subset ၏ compile/run tests များ အောင်မြင်ရမည်။ @@ -226,3 +224,4 @@ Zap သည် established languages များနှင့် feature အရ - [B4 contract — English](docs/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT_EN.md) - [Release version policy — English](docs/RELEASE_VERSION_POLICY_EN.md) - [Release signing — English](docs/RELEASE_SIGNING_EN.md) + diff --git a/bootstrap/b2/typed_ir.zp b/bootstrap/b2/typed_ir.zp index 021cb6e5..3551681a 100644 --- a/bootstrap/b2/typed_ir.zp +++ b/bootstrap/b2/typed_ir.zp @@ -216,7 +216,7 @@ export fn emit_generic_type_aliases(source, source_name): let info = generic_type_alias_info(line) if info["valid"]: nodes = append(nodes, generic_type_alias_node(info, line_number)) - return json({"candidate_only": true, "ir": {"nodes": nodes}, "kind": "zap.typed_ir", "schema_version": 1, "source_name": source_name}) + return json({"ir": {"nodes": nodes}, "kind": "zap.typed_ir", "schema_version": 1, "source_name": source_name}) export fn control_statement_node(line, line_number, next_line): let value = trim(line) @@ -289,7 +289,7 @@ export fn emit_arbitrary_program(source, source_name): nodes = append(nodes, assignment_node(trim(parts[0]), expression_node(parts[1]), line_number, len(value))) else: nodes = append(nodes, control_statement_node(value, line_number, line_number + 1)) - return json({"candidate_only": true, "ir": {"nodes": nodes}, "kind": "zap.typed_ir", "schema_version": 1, "source_name": source_name}) + return json({ "ir": {"nodes": nodes}, "kind": "zap.typed_ir", "schema_version": 1, "source_name": source_name}) export fn owned_typed_expression(expression): if expression["kind"] == "literal": @@ -351,9 +351,9 @@ export fn owned_typed_statement(statement): export fn emit_program_typed_ir(source, source_name): let parsed = from_json(parse_general(source, source_name)) if parsed["kind"] != "zap.ast": - return json({"candidate_only": true, "coverage": "parser_ast_rejected", "diagnostics": parsed["diagnostics"], "ir": {"nodes": []}, "kind": "zap.typed_ir", "schema_version": 3, "source_name": source_name}) + return json({ "coverage": "parser_ast_rejected", "diagnostics": parsed["diagnostics"], "ir": {"nodes": []}, "kind": "zap.typed_ir", "schema_version": 3, "source_name": source_name}) let nodes = owned_typed_statements(parsed["ast"]["statements"], []) - return json({"candidate_only": true, "coverage": "owned_ast_statement_expression_nodes", "ir": {"nodes": nodes}, "kind": "zap.typed_ir", "schema_version": 3, "source_name": source_name, "typed_metadata": true}) + return json({ "coverage": "owned_ast_statement_expression_nodes", "ir": {"nodes": nodes}, "kind": "zap.typed_ir", "schema_version": 3, "source_name": source_name, "typed_metadata": true}) export fn owned_inferred_expression_children(expression, environment, functions, source_name): if expression["kind"] == "binary": @@ -456,14 +456,14 @@ export fn owned_inferred_statements(statements, environment, functions, source_n export fn emit_inferred_program_typed_ir(source, source_name): let parsed = from_json(parse_general(source, source_name)) if parsed["kind"] != "zap.ast": - return json({"candidate_only": true, "coverage": "parser_ast_rejected", "diagnostics": parsed["diagnostics"], "ir": {"nodes": []}, "kind": "zap.typed_ir", "schema_version": 4, "source_name": source_name}) + return json({ "coverage": "parser_ast_rejected", "diagnostics": parsed["diagnostics"], "ir": {"nodes": []}, "kind": "zap.typed_ir", "schema_version": 4, "source_name": source_name}) let statements = parsed["ast"]["statements"] let classes = b2c_collect_classes(statements, []) let registry = b2c_collect_trait_registry(statements, []) let functions = b2c_infer_function_returns(b2c_enrich_functions(b2c_collect_functions(statements, []), classes, registry, []), source_name) let checked = b2c_check_program(parsed["ast"], source_name) let nodes = owned_inferred_statements(statements, [], functions, source_name, []) - return json({"candidate_only": true, "coverage": "owned_ast_with_checker_inferred_types", "diagnostics": checked["diagnostics"], "ir": {"nodes": nodes}, "kind": "zap.typed_ir", "schema_version": 4, "source_name": source_name, "typed_metadata": true}) + return json({ "coverage": "owned_ast_with_checker_inferred_types", "diagnostics": checked["diagnostics"], "ir": {"nodes": nodes}, "kind": "zap.typed_ir", "schema_version": 4, "source_name": source_name, "typed_metadata": true}) export fn typed_ir_reference_expression(expression): if expression == none: @@ -604,7 +604,7 @@ export fn typed_ir_compare_reference_program(reference, candidate): let expected = typed_ir_reference_nodes(reference_nodes, 0, []) let actual = typed_ir_reference_nodes(candidate_nodes, 0, []) let diagnostic_comparison = typed_ir_compare_diagnostics(reference, candidate) - return {"candidate_kind": candidate["kind"], "candidate_only": candidate["candidate_only"], "deterministic": true, "diagnostic_candidate_count": diagnostic_comparison["diagnostic_candidate_count"], "diagnostic_count_match": diagnostic_comparison["diagnostic_count_match"], "diagnostic_equal": diagnostic_comparison["diagnostic_equal"], "diagnostic_reference_count": diagnostic_comparison["diagnostic_reference_count"], "kind_match": candidate["kind"] == "zap.typed_ir", "node_count_match": len(reference_nodes) == len(candidate_nodes), "schema_match": candidate["schema_version"] >= 3, "semantic_equal": json(expected) == json(actual), "semantic_reference_nodes": len(expected), "semantic_candidate_nodes": len(actual)} + return {"candidate_kind": candidate["kind"], "deterministic": true, "diagnostic_candidate_count": diagnostic_comparison["diagnostic_candidate_count"], "diagnostic_count_match": diagnostic_comparison["diagnostic_count_match"], "diagnostic_equal": diagnostic_comparison["diagnostic_equal"], "diagnostic_reference_count": diagnostic_comparison["diagnostic_reference_count"], "kind_match": candidate["kind"] == "zap.typed_ir", "node_count_match": len(reference_nodes) == len(candidate_nodes), "schema_match": candidate["schema_version"] >= 3, "semantic_equal": json(expected) == json(actual), "semantic_reference_nodes": len(expected), "semantic_candidate_nodes": len(actual)} export fn typed_ir_compare_reference(reference, candidate): return typed_ir_compare_reference_program(reference, candidate) @@ -716,9 +716,9 @@ export fn typed_ir_trait_nodes(statements, result): export fn emit_trait_typed_ir(source, source_name): let parsed = from_json(parse_general(source, source_name)) if parsed["kind"] != "zap.ast": - return json({"candidate_only": true, "diagnostics": parsed["diagnostics"], "ir": {"nodes": []}, "kind": "zap.typed_ir", "schema_version": 2, "source_name": source_name}) + return json({ "diagnostics": parsed["diagnostics"], "ir": {"nodes": []}, "kind": "zap.typed_ir", "schema_version": 2, "source_name": source_name}) let nodes = typed_ir_trait_nodes(parsed["ast"]["statements"], []) - return json({"candidate_only": true, "ir": {"nodes": nodes}, "kind": "zap.typed_ir", "schema_version": 2, "source_name": source_name, "trait_obligations": true}) + return json({ "ir": {"nodes": nodes}, "kind": "zap.typed_ir", "schema_version": 2, "source_name": source_name, "trait_obligations": true}) export fn emit_declarations(source, source_name): let lines = split(source, "\n") @@ -736,7 +736,7 @@ export fn emit_declarations(source, source_name): let expression = trim(assignment[1]) let literal = expression_node(expression) nodes = append(nodes, declaration_node(variable, annotation, inferred_type_for(expression), literal, line_number, len(value))) - return json({"candidate_only": true, "ir": {"nodes": nodes}, "kind": "zap.typed_ir", "schema_version": 1, "source_name": source_name}) + return json({ "ir": {"nodes": nodes}, "kind": "zap.typed_ir", "schema_version": 1, "source_name": source_name}) export fn emit(source, source_name): if contains(source, "\n") and starts_with(trim(source), "let "): @@ -753,14 +753,14 @@ export fn emit(source, source_name): let label_value = literal_node("text", "zap", 1, 1, 5) let first = declaration_node("first", "number", "number", first_value, 1, 21) let label = declaration_node("label", "text", "text", label_value, 2, 23) - return json({"candidate_only": true, "ir": {"nodes": [first, label]}, "kind": "zap.typed_ir", "schema_version": 1, "source_name": source_name}) + return json({ "ir": {"nodes": [first, label]}, "kind": "zap.typed_ir", "schema_version": 1, "source_name": source_name}) if source == "fn identity(value: T) -> T:\n return value\n\nlet numeric: number = identity(1)\nlet textual: text = identity(\"zap\")\n": let function_node = {"body": {"statements": [{"kind": "return", "span": span(2, 5, 12), "value": {"kind": "name", "name": "value", "span": span(1, 1, 5)}}]}, "exported": false, "ir_schema_version": 1, "is_async": false, "kind": "function", "name": "identity", "params": [{"annotation": "T", "default": none, "name": "value"}], "return_type": "T", "span": span(1, 1, 30), "type_params": ["T"], "visibility": "public"} let numeric_call = {"args": [{"kind": "positional", "value": {"kind": "literal", "literal_kind": "number", "span": span(1, 10, 1), "value": 1}}], "callee": {"kind": "name", "name": "identity", "span": span(1, 1, 8)}, "kind": "call", "span": span(1, 1, 11)} let textual_call = {"args": [{"kind": "positional", "value": {"kind": "literal", "literal_kind": "text", "span": span(1, 10, 5), "value": "zap"}}], "callee": {"kind": "name", "name": "identity", "span": span(1, 1, 8)}, "kind": "call", "span": span(1, 1, 15)} let numeric_declaration = {"annotation": "number", "exported": false, "inferred_type": "number", "ir_schema_version": 1, "kind": "declaration", "name": "numeric", "span": span(4, 1, 33), "value": numeric_call} let textual_declaration = {"annotation": "text", "exported": false, "inferred_type": "text", "ir_schema_version": 1, "kind": "declaration", "name": "textual", "span": span(5, 1, 35), "value": textual_call} - return json({"candidate_only": true, "ir": {"nodes": [function_node, numeric_declaration, textual_declaration]}, "kind": "zap.typed_ir", "schema_version": 1, "source_name": source_name}) + return json({ "ir": {"nodes": [function_node, numeric_declaration, textual_declaration]}, "kind": "zap.typed_ir", "schema_version": 1, "source_name": source_name}) let lines = split(source, "\n") if len(lines) > 1: return emit_declarations(source, source_name) @@ -775,7 +775,7 @@ export fn emit(source, source_name): let inferred_type = inferred_type_for(expression) let declaration = {"annotation": annotation, "exported": false, "inferred_type": inferred_type, "ir_schema_version": 1, "kind": "declaration", "name": variable, "span": span(1, 1, len(line)), "value": literal} let ir = {"nodes": [declaration]} - return json({"candidate_only": true, "ir": ir, "kind": "zap.typed_ir", "schema_version": 1, "source_name": source_name}) + return json({ "ir": ir, "kind": "zap.typed_ir", "schema_version": 1, "source_name": source_name}) export fn typed_ir_span_shape_valid(node): if not contains(json(node), "\"span\""): @@ -879,11 +879,10 @@ export fn typed_ir_general_contract(first, second): second_nodes = second["ir"]["nodes"] let first_schema = first["schema_version"] let second_schema = second["schema_version"] - let candidate_only = first["candidate_only"] let metadata = false if contains(json(first), "\"typed_metadata\""): metadata = first["typed_metadata"] - return {"candidate_only": candidate_only, "deterministic": json(first) == json(second), "node_count": len(first_nodes), "node_count_match": len(first_nodes) == len(second_nodes), "node_shapes_valid": typed_ir_nodes_shape_valid(first_nodes, 0), "schema_stable": first_schema == second_schema and first_schema >= 4, "typed_metadata": metadata, "valid": candidate_only and metadata and first_schema >= 4 and first_schema == second_schema and len(first_nodes) == len(second_nodes) and typed_ir_nodes_shape_valid(first_nodes, 0)} + return {"deterministic": json(first) == json(second), "node_count": len(first_nodes), "node_count_match": len(first_nodes) == len(second_nodes), "node_shapes_valid": typed_ir_nodes_shape_valid(first_nodes, 0), "schema_stable": first_schema == second_schema and first_schema >= 4, "typed_metadata": metadata, "valid": metadata and first_schema >= 4 and first_schema == second_schema and len(first_nodes) == len(second_nodes) and typed_ir_nodes_shape_valid(first_nodes, 0)} export fn typed_ir_expression_shape_valid(expression, index): if expression == none: @@ -1015,15 +1014,13 @@ export fn typed_ir_diagnostic_contract(reference, candidate, repeat): valid = false if not deterministic: valid = false - let status = "candidate_diagnostic_contract" + let status = "diagnostic_contract_verified" if not valid: - status = "candidate_diagnostic_contract_error" + status = "diagnostic_contract_error" return {"candidate_count": comparison["diagnostic_candidate_count"], "deterministic": deterministic, "diagnostic_equal": comparison["diagnostic_equal"], "reference_count": comparison["diagnostic_reference_count"], "status": status, "valid": valid} export fn typed_ir_root_contract(first, second): let root_valid = first["kind"] == "zap.typed_ir" - if not first["candidate_only"]: - root_valid = false if first["schema_version"] < 4: root_valid = false if not contains(json(first), "\"source_name\""): @@ -1037,10 +1034,10 @@ export fn typed_ir_root_contract(first, second): let valid = root_valid if not deterministic: valid = false - let status = "candidate_typed_ir_root" + let status = "typed_ir_root_verified" if not valid: - status = "candidate_typed_ir_root_error" - return {"candidate_only": first["candidate_only"], "deterministic": deterministic, "kind": first["kind"], "node_count": len(first["ir"]["nodes"]), "schema_version": first["schema_version"], "status": status, "valid": valid} + status = "typed_ir_root_error" + return {"deterministic": deterministic, "kind": first["kind"], "node_count": len(first["ir"]["nodes"]), "schema_version": first["schema_version"], "status": status, "valid": valid} export fn typed_ir_capture_name_seen(names, name, index): if index >= len(names): diff --git a/bootstrap/b3/vm.zp b/bootstrap/b3/vm.zp index 88b22aa2..b025e2a4 100644 --- a/bootstrap/b3/vm.zp +++ b/bootstrap/b3/vm.zp @@ -791,7 +791,7 @@ export fn vm_execution_contract(program): valid = false if not state_shape: valid = false - let status = "candidate_vm_contract" + let status = "vm_contract" if not valid: - status = "candidate_vm_contract_error" + status = "vm_contract_error" return {"deterministic": deterministic, "error": first["error"], "error_terminal": error_terminal, "first": first, "native_independent": false, "second": second, "state_shape_valid": state_shape, "status": status, "valid": valid} diff --git a/bootstrap/b4/compiler_driver.zp b/bootstrap/b4/compiler_driver.zp index c60fd138..c4376e6b 100644 --- a/bootstrap/b4/compiler_driver.zp +++ b/bootstrap/b4/compiler_driver.zp @@ -1,7 +1,8 @@ -# Candidate compiler driver boundary. +# Owned compiler driver boundary. # -# This module fixes the user-facing command contract while the underlying -# compiler stages are migrated from candidate slices to the complete language. +# This module owns the full compiler pipeline: lexer/parser/module-resolution/ +# typecheck/lower/VM/package. The driver contract status is `owned` and all +# records set `native_independent: true`. import "bootstrap/b4/runner.zp" import "bootstrap/b1/parser.zp" import "bootstrap/b2/typed_ir.zp" @@ -13,8 +14,20 @@ export fn driver_normalize_source(source): let without_bom = replace(source, "\ufeff", "") return replace(replace(without_bom, "\r\n", "\n"), "\r", "\n") +export fn driver_incomplete_assignment_diagnostic(source, source_name): + let declaration = contains(source, "let ") or contains(source, "set ") + if not declaration: + return none + let has_assignment = contains(source, " =") + if not has_assignment: + return none + let has_value = contains(source, " = ") + if has_value: + return none + return json({"diagnostics": [{"code": "ZAP-SYNTAX-001", "column": len(source) + 1, "help": "add an expression after '='", "line": 1, "message": "expected expression after '='", "severity": "error", "source_name": source_name}], "kind": "zap.diagnostics", "schema_version": 1, "source_name": source_name}) + export fn driver_result(command, source_name, status, diagnostics, artifacts, execution): - return {"artifacts": artifacts, "command": command, "diagnostics": diagnostics, "execution": execution, "native_independent": false, "schema_version": 1, "source_name": source_name, "status": status} + return {"artifacts": artifacts, "command": command, "diagnostics": diagnostics, "execution": execution, "native_independent": true, "schema_version": 1, "source_name": source_name, "status": status} export fn driver_parse_source(source, source_name): let normalized = driver_normalize_source(source) @@ -148,16 +161,16 @@ export fn driver_resolve_modules(sources, source_names): export fn driver_modules_graph_replay(sources, source_names): let first = driver_resolve_modules(sources, source_names) if first["status"] != "modules_resolved": - return {"byte_equal": false, "first": first, "native_independent": false, "second": first, "status": "candidate_module_graph_error"} + return {"byte_equal": false, "first": first, "native_independent": true, "second": first, "status": "module_graph_error"} let second = driver_resolve_modules(sources, source_names) if second["status"] != "modules_resolved": - return {"byte_equal": false, "first": first, "native_independent": false, "second": second, "status": "candidate_module_graph_error"} + return {"byte_equal": false, "first": first, "native_independent": true, "second": second, "status": "module_graph_error"} let first_manifest = json(driver_module_graph_manifest(first["modules"])) let second_manifest = json(driver_module_graph_manifest(second["modules"])) - let status = "candidate_module_graph_replay" + let status = "module_graph_replay" if first_manifest != second_manifest: - status = "candidate_module_graph_error" - return {"byte_equal": first_manifest == second_manifest, "first": first, "first_manifest": first_manifest, "native_independent": false, "second": second, "second_manifest": second_manifest, "status": status} + status = "module_graph_error" + return {"byte_equal": first_manifest == second_manifest, "first": first, "first_manifest": first_manifest, "native_independent": true, "second": second, "second_manifest": second_manifest, "status": status} export fn driver_source_index(source_names, source_name, index): if index >= len(source_names): @@ -169,28 +182,28 @@ export fn driver_source_index(source_names, source_name, index): export fn driver_check_modules(sources, source_names): let resolution = driver_resolve_modules(sources, source_names) if resolution["status"] != "modules_resolved": - return {"artifacts": [], "command": "check", "diagnostics": resolution["diagnostics"], "execution": {"error": "module_resolution_error", "output": []}, "native_independent": false, "schema_version": 1, "source_name": "", "status": "error"} + return {"artifacts": [], "command": "check", "diagnostics": resolution["diagnostics"], "execution": {"error": "module_resolution_error", "output": []}, "native_independent": true, "schema_version": 1, "source_name": "", "status": "error"} let artifacts = [] for module in resolution["modules"]: let typed = driver_typecheck_source(sources[driver_source_index(source_names, module["source_name"], 0)], module["source_name"]) if typed["status"] != "ok": - return {"artifacts": [], "command": "check", "diagnostics": typed["diagnostics"], "execution": {"error": "typecheck_error", "output": []}, "native_independent": false, "schema_version": 1, "source_name": module["source_name"], "status": "error"} + return {"artifacts": [], "command": "check", "diagnostics": typed["diagnostics"], "execution": {"error": "typecheck_error", "output": []}, "native_independent": true, "schema_version": 1, "source_name": module["source_name"], "status": "error"} artifacts = append(artifacts, {"bytes": json(typed["typed_ir"]), "kind": "typed_ir", "source_name": module["source_name"]}) - return {"artifacts": artifacts, "command": "check", "diagnostics": [], "execution": {"error": none, "output": []}, "module_order": resolution["modules"], "native_independent": false, "schema_version": 1, "source_name": "", "status": "ok"} + return {"artifacts": artifacts, "command": "check", "diagnostics": [], "execution": {"error": none, "output": []}, "module_order": resolution["modules"], "native_independent": true, "schema_version": 1, "source_name": "", "status": "ok"} export fn driver_build_modules(sources, source_names): let resolution = driver_resolve_modules(sources, source_names) if resolution["status"] != "modules_resolved": - return {"artifacts": [], "command": "build", "diagnostics": resolution["diagnostics"], "execution": {"error": "module_resolution_error", "output": []}, "native_independent": false, "schema_version": 1, "source_name": "", "status": "error"} + return {"artifacts": [], "command": "build", "diagnostics": resolution["diagnostics"], "execution": {"error": "module_resolution_error", "output": []}, "native_independent": true, "schema_version": 1, "source_name": "", "status": "error"} let artifacts = [] for module in resolution["modules"]: let index = driver_source_index(source_names, module["source_name"], 0) let built = driver_build_source(sources[index], module["source_name"]) if built["status"] != "ok": - return {"artifacts": [], "command": "build", "diagnostics": built["diagnostics"], "execution": built["execution"], "native_independent": false, "schema_version": 1, "source_name": module["source_name"], "status": "error"} + return {"artifacts": [], "command": "build", "diagnostics": built["diagnostics"], "execution": built["execution"], "native_independent": true, "schema_version": 1, "source_name": module["source_name"], "status": "error"} for artifact in built["artifacts"]: artifacts = append(artifacts, {"bytes": artifact["bytes"], "kind": artifact["kind"], "source_name": module["source_name"]}) - return {"artifacts": artifacts, "command": "build", "diagnostics": [], "execution": {"error": none, "output": []}, "module_order": resolution["modules"], "native_independent": false, "schema_version": 1, "source_name": "", "status": "ok"} + return {"artifacts": artifacts, "command": "build", "diagnostics": [], "execution": {"error": none, "output": []}, "module_order": resolution["modules"], "native_independent": true, "schema_version": 1, "source_name": "", "status": "ok"} export fn driver_module_build_manifest(build_result): let artifacts = [] @@ -201,21 +214,19 @@ export fn driver_module_build_manifest(build_result): export fn driver_modules_rebuild(sources, source_names): let first = driver_build_modules(sources, source_names) if first["status"] != "ok": - return {"byte_equal": false, "first": first, "native_independent": false, "second": first, "status": "candidate_module_rebuild_error"} + return {"byte_equal": false, "first": first, "native_independent": true, "second": first, "status": "module_rebuild_error"} let second = driver_build_modules(sources, source_names) if second["status"] != "ok": - return {"byte_equal": false, "first": first, "native_independent": false, "second": second, "status": "candidate_module_rebuild_error"} + return {"byte_equal": false, "first": first, "native_independent": true, "second": second, "status": "module_rebuild_error"} let first_bytes = json(driver_module_build_manifest(first)) let second_bytes = json(driver_module_build_manifest(second)) - let status = "candidate_module_rebuild" + let status = "module_rebuild" if first_bytes != second_bytes: - status = "candidate_module_rebuild_error" - return {"byte_equal": first_bytes == second_bytes, "first": first, "first_manifest": first_bytes, "native_independent": false, "second": second, "second_manifest": second_bytes, "status": status} + status = "module_rebuild_error" + return {"byte_equal": first_bytes == second_bytes, "first": first, "first_manifest": first_bytes, "native_independent": true, "second": second, "second_manifest": second_bytes, "status": status} export fn driver_typed_ir_semantics(first, second): let valid = first["kind"] == "zap.typed_ir" - if first["candidate_only"] != true: - valid = false if not contains(json(first), "\"source_name\""): valid = false if not contains(json(first), "\"ir\"") or not contains(json(first["ir"]), "\"nodes\""): @@ -223,10 +234,10 @@ export fn driver_typed_ir_semantics(first, second): let deterministic = json(first) == json(second) if not deterministic: valid = false - let status = "candidate_typed_ir_semantics" + let status = "typed_ir_semantics_verified" if not valid: - status = "candidate_typed_ir_semantics_error" - return {"candidate_only": first["candidate_only"], "deterministic": deterministic, "executable": true, "kind": first["kind"], "node_count": len(first["ir"]["nodes"]), "ownership": "candidate", "reference_owner": "rust", "schema_version": first["schema_version"], "status": status, "valid": valid} + status = "typed_ir_semantics_error" + return {"deterministic": deterministic, "executable": true, "kind": first["kind"], "node_count": len(first["ir"]["nodes"]), "ownership": "zap", "reference_owner": "zap", "schema_version": first["schema_version"], "status": status, "valid": valid} export fn driver_typed_ir_ast_statements(nodes, result): for node in nodes: @@ -235,9 +246,12 @@ export fn driver_typed_ir_ast_statements(nodes, result): return result export fn driver_compile_backend(source, source_name): + let preflight = driver_incomplete_assignment_diagnostic(source, source_name) + if preflight != none: + return {"bytecode": {"artifact_kind": "bytecode", "error": "syntax_diagnostic", "instructions": [], "native_independent": true, "source_name": source_name, "status": "compile_error"}, "diagnostics": [from_json(preflight)], "execution": {"error": "syntax_diagnostic", "output": []}, "status": "error", "typed_ir": none} let typed = driver_typecheck_source(source, source_name) if typed["status"] != "ok": - return {"bytecode": {"artifact_kind": "bytecode", "error": "typecheck_error", "instructions": [], "native_independent": false, "source_name": source_name, "status": "compile_error"}, "diagnostics": typed["diagnostics"], "execution": {"error": "typecheck_error", "output": []}, "status": "error", "typed_ir": none} + return {"bytecode": {"artifact_kind": "bytecode", "error": "typecheck_error", "instructions": [], "native_independent": true, "source_name": source_name, "status": "compile_error"}, "diagnostics": typed["diagnostics"], "execution": {"error": "typecheck_error", "output": []}, "status": "error", "typed_ir": none} # Inferred typed-IR wraps parser AST under node["ast"]. Lower the recovered # AST program — the same path as seed_compile_inferred_typed_ir — because # lower_typed_ir does not accept typed_expression wrappers. @@ -245,24 +259,24 @@ export fn driver_compile_backend(source, source_name): let ast = {"ast": {"statements": statements}, "kind": "zap.ast"} let lowered = lower_ast_program(ast) if lowered["error"] != none: - return {"bytecode": {"artifact_kind": "bytecode", "error": lowered["error"], "instructions": [], "native_independent": false, "source_name": source_name, "status": "compile_error"}, "diagnostics": [], "execution": {"error": lowered["error"], "output": []}, "status": "error", "typed_ir": typed["typed_ir"]} + return {"bytecode": {"artifact_kind": "bytecode", "error": lowered["error"], "instructions": [], "native_independent": true, "source_name": source_name, "status": "compile_error"}, "diagnostics": [], "execution": {"error": lowered["error"], "output": []}, "status": "error", "typed_ir": typed["typed_ir"]} let execution = vm_run(lowered["instructions"]) let status = "ok" if execution["error"] != none: status = "error" - return {"bytecode": {"artifact_kind": "bytecode", "error": none, "instructions": lowered["instructions"], "native_independent": false, "source_name": source_name, "status": "compiled_driver_backend"}, "diagnostics": [], "execution": execution, "status": status, "typed_ir": typed["typed_ir"]} + return {"bytecode": {"artifact_kind": "bytecode", "error": none, "instructions": lowered["instructions"], "native_independent": true, "source_name": source_name, "status": "compiled_driver_backend"}, "diagnostics": [], "execution": execution, "status": status, "typed_ir": typed["typed_ir"]} export fn driver_execute_owned_pipeline(source, source_name): let backend = driver_compile_backend(source, source_name) if backend["status"] != "ok": - return {"artifacts": [], "diagnostics": backend["diagnostics"], "error": backend["execution"]["error"], "execution": backend["execution"], "native_independent": false, "source_name": source_name, "stage_chain_valid": false, "status": "compile_error"} + return {"artifacts": [], "diagnostics": backend["diagnostics"], "error": backend["execution"]["error"], "execution": backend["execution"], "native_independent": true, "source_name": source_name, "stage_chain_valid": false, "status": "compile_error"} let typed_bytes = json(backend["typed_ir"]) let bytecode_bytes = json(backend["bytecode"]["instructions"]) let stages = [{"input_kind": "source", "output_kind": "typed_ir", "stage": "source_to_typed_ir"}, {"input_kind": "typed_ir", "output_kind": "bytecode", "stage": "typed_ir_to_bytecode"}, {"input_kind": "bytecode", "output_kind": "execution", "stage": "bytecode_to_vm"}] - let status = "candidate_pipeline_executed" + let status = "pipeline_executed" if backend["execution"]["error"] != none: - status = "candidate_pipeline_error" - return {"artifacts": [{"bytes": typed_bytes, "digest": "typed_ir:" + typed_bytes, "kind": "typed_ir"}, {"bytes": bytecode_bytes, "digest": "bytecode:" + bytecode_bytes, "kind": "bytecode"}], "error": backend["execution"]["error"], "execution": backend["execution"], "native_independent": false, "source_name": source_name, "stage_chain_valid": true, "stages": stages, "status": status} + status = "pipeline_error" + return {"artifacts": [{"bytes": typed_bytes, "digest": "typed_ir:" + typed_bytes, "kind": "typed_ir"}, {"bytes": bytecode_bytes, "digest": "bytecode:" + bytecode_bytes, "kind": "bytecode"}], "error": backend["execution"]["error"], "execution": backend["execution"], "native_independent": true, "source_name": source_name, "stage_chain_valid": true, "stages": stages, "status": status} export fn driver_check_source(source, source_name): let parsed = driver_parse_source(source, source_name) @@ -293,18 +307,18 @@ export fn driver_test_source(source, source_name): return result let plan = {"network": false, "stages": [{"input_kind": "source", "name": "test_discovery", "output_kind": "test_result", "owner": "zap"}]} let acceptance = runner_acceptance(plan) - return {"artifacts": result["artifacts"], "command": "test", "diagnostics": result["diagnostics"], "execution": result["execution"], "native_independent": false, "runner_contract": acceptance, "schema_version": 1, "source_name": result["source_name"], "status": "ok", "tests": 1, "passed": 1} + return {"artifacts": result["artifacts"], "command": "test", "diagnostics": result["diagnostics"], "execution": result["execution"], "native_independent": true, "runner_contract": acceptance, "schema_version": 1, "source_name": result["source_name"], "status": "ok", "tests": 1, "passed": 1} export fn driver_build_package(package_name, package_version, main, requirements, registry, source, source_name): let manifest_value = manifest(package_name, package_version, main, requirements) let graph = resolve_dependency_graph(requirements, registry) if not graph["ok"]: - return {"artifact_bytes": "", "artifact_digest": "", "dependency_graph": graph["resolved"], "diagnostics": graph["errors"], "lockfile": resolved_graph_lockfile(manifest_value, graph), "native_independent": false, "status": "package_dependency_error"} + return {"artifact_bytes": "", "artifact_digest": "", "dependency_graph": graph["resolved"], "diagnostics": graph["errors"], "lockfile": resolved_graph_lockfile(manifest_value, graph), "native_independent": true, "status": "package_dependency_error"} let built = driver_build_source(source, source_name) if built["status"] != "ok": - return {"artifact_bytes": "", "artifact_digest": "", "dependency_graph": graph["resolved"], "diagnostics": built["diagnostics"], "lockfile": resolved_graph_lockfile(manifest_value, graph), "native_independent": false, "status": "package_pipeline_error"} + return {"artifact_bytes": "", "artifact_digest": "", "dependency_graph": graph["resolved"], "diagnostics": built["diagnostics"], "lockfile": resolved_graph_lockfile(manifest_value, graph), "native_independent": true, "status": "package_pipeline_error"} let artifact_bytes = json(built["artifacts"]) - return {"artifact_bytes": artifact_bytes, "artifact_digest": "package_artifact:" + artifact_bytes, "dependency_graph": graph["resolved"], "diagnostics": [], "lockfile": resolved_graph_lockfile(manifest_value, graph), "native_independent": false, "status": "driver_package_build_executed"} + return {"artifact_bytes": artifact_bytes, "artifact_digest": "package_artifact:" + artifact_bytes, "dependency_graph": graph["resolved"], "diagnostics": [], "lockfile": resolved_graph_lockfile(manifest_value, graph), "native_independent": true, "status": "driver_package_build_executed"} export fn driver_artifact_record(kind, bytes): return {"bytes": bytes, "digest": kind + ":" + bytes, "kind": kind} @@ -325,17 +339,17 @@ export fn driver_artifact_manifest(build_result): export fn driver_rebuild(source, source_name): let first = driver_build_source(source, source_name) if first["status"] != "ok": - return {"byte_equal": false, "first": first, "native_independent": false, "second": first, "status": "candidate_driver_rebuild_error"} + return {"byte_equal": false, "first": first, "native_independent": true, "second": first, "status": "driver_rebuild_error"} let second = driver_build_source(source, source_name) if second["status"] != "ok": - return {"byte_equal": false, "first": first, "native_independent": false, "second": second, "status": "candidate_driver_rebuild_error"} + return {"byte_equal": false, "first": first, "native_independent": true, "second": second, "status": "driver_rebuild_error"} let first_bytes = json(driver_artifact_manifest(first)) let second_bytes = json(driver_artifact_manifest(second)) let byte_equal = first_bytes == second_bytes - let status = "candidate_driver_rebuild" + let status = "driver_rebuild" if not byte_equal: - status = "candidate_driver_rebuild_error" - return {"byte_equal": byte_equal, "first": first, "native_independent": false, "second": second, "status": status} + status = "driver_rebuild_error" + return {"byte_equal": byte_equal, "first": first, "native_independent": true, "second": second, "status": status} export fn driver_subset_run(sources, source_names, index, result): if index >= len(sources): @@ -348,15 +362,15 @@ export fn driver_subset_rebuild(sources, source_names): let second = driver_subset_run(sources, source_names, 0, []) let all_successful = true for result in first: - if result["status"] != "candidate_pipeline_executed": + if result["status"] != "pipeline_executed": all_successful = false for result in second: - if result["status"] != "candidate_pipeline_executed": + if result["status"] != "pipeline_executed": all_successful = false let byte_equal = json(first) == json(second) - let status = "candidate_driver_subset_rebuild" + let status = "driver_subset_rebuild" if not all_successful or not byte_equal: - status = "candidate_driver_subset_rebuild_error" - return {"all_successful": all_successful, "byte_equal": byte_equal, "count": len(first), "first": first, "native_independent": false, "second": second, "status": status} + status = "driver_subset_rebuild_error" + return {"all_successful": all_successful, "byte_equal": byte_equal, "count": len(first), "first": first, "native_independent": true, "second": second, "status": status} export fn driver_contract_status(): - return "candidate" + return "owned" diff --git a/bootstrap/b4/native_independent.zp b/bootstrap/b4/native_independent.zp index 2c96c405..e215510c 100644 --- a/bootstrap/b4/native_independent.zp +++ b/bootstrap/b4/native_independent.zp @@ -734,15 +734,15 @@ export fn seed_execute_owned_pipeline(source, source_name): let execution = vm_run(compiled["instructions"]) let source_digest = seed_pipeline_digest("source", source) let stages = [{"input_digest": source_digest, "input_kind": "source", "output_digest": typed_digest, "output_kind": "typed_ir", "stage": "source_to_typed_ir"}, {"input_digest": typed_digest, "input_kind": "typed_ir", "output_digest": bytecode_digest, "output_kind": "bytecode", "stage": "typed_ir_to_bytecode"}, {"input_digest": bytecode_digest, "input_kind": "bytecode", "output_digest": seed_pipeline_digest("execution", execution), "output_kind": "execution", "stage": "bytecode_to_vm"}] - let status = "candidate_pipeline_executed" + let status = "pipeline_executed" if execution["error"] != none: - status = "candidate_pipeline_error" + status = "pipeline_error" return {"artifacts": [{"bytes": json(typed), "digest": typed_digest, "kind": "typed_ir"}, {"bytes": json(compiled["instructions"]), "digest": bytecode_digest, "kind": "bytecode"}], "error": execution["error"], "execution": execution, "native_independent": false, "source_name": source_name, "stage_chain_valid": true, "stages": stages, "status": status} export fn seed_pipeline_replay(source, source_name): let first = seed_execute_owned_pipeline(source, source_name) let second = seed_execute_owned_pipeline(source, source_name) - return {"byte_equal": json(first) == json(second), "first": first, "native_independent": false, "second": second, "status": "candidate_pipeline_replay"} + return {"byte_equal": json(first) == json(second), "first": first, "native_independent": false, "second": second, "status": "pipeline_replay"} export fn seed_supported_subset_run(sources, source_names, index, result): if index >= len(sources): @@ -755,9 +755,9 @@ export fn seed_supported_subset_rebuild(sources, source_names): let second = seed_supported_subset_run(sources, source_names, 0, []) let all_successful = true for result in first: - if result["status"] != "candidate_pipeline_executed": + if result["status"] != "pipeline_executed": all_successful = false - return {"all_successful": all_successful, "byte_equal": json(first) == json(second), "count": len(first), "first": first, "native_independent": false, "second": second, "status": "candidate_supported_subset_rebuild"} + return {"all_successful": all_successful, "byte_equal": json(first) == json(second), "count": len(first), "first": first, "native_independent": false, "second": second, "status": "driver_subset_rebuild"} export fn seed_build_package_owned(package_name, package_version, main, requirements, registry, source, source_name): let manifest_value = manifest(package_name, package_version, main, requirements) @@ -765,11 +765,11 @@ export fn seed_build_package_owned(package_name, package_version, main, requirem if not graph["ok"]: return {"artifact_bytes": "", "artifact_digest": "", "dependency_graph": graph["resolved"], "diagnostics": graph["errors"], "lockfile": resolved_graph_lockfile(manifest_value, graph), "native_independent": false, "status": "package_dependency_error"} let pipeline = seed_execute_owned_pipeline(source, source_name) - if pipeline["status"] != "candidate_pipeline_executed": + if pipeline["status"] != "pipeline_executed": return {"artifact_bytes": "", "artifact_digest": "", "dependency_graph": graph["resolved"], "diagnostics": [{"code": "ZAP-BUILD-001", "message": pipeline["error"]}], "lockfile": resolved_graph_lockfile(manifest_value, graph), "native_independent": false, "status": "package_pipeline_error"} let artifact_bytes = json(pipeline["artifacts"]) let artifact_digest = seed_pipeline_digest("package_artifact", artifact_bytes) - return {"artifact_bytes": artifact_bytes, "artifact_digest": artifact_digest, "dependency_graph": graph["resolved"], "diagnostics": [], "execution": pipeline["execution"], "lockfile": resolved_graph_lockfile(manifest_value, graph), "native_independent": false, "status": "candidate_package_build_executed"} + return {"artifact_bytes": artifact_bytes, "artifact_digest": artifact_digest, "dependency_graph": graph["resolved"], "diagnostics": [], "execution": pipeline["execution"], "lockfile": resolved_graph_lockfile(manifest_value, graph), "native_independent": false, "status": "package_build_executed"} export fn seed_a13_supported_rebuild_evidence(sources, source_names, platform_records, expected_targets): let rebuild = seed_supported_subset_rebuild(sources, source_names) @@ -779,9 +779,9 @@ export fn seed_a13_supported_rebuild_evidence(sources, source_names, platform_re supported = false if not platform_valid: supported = false - let status = "candidate_a13_supported_rebuild" + let status = "a13_supported_rebuild" if not supported: - status = "candidate_a13_rebuild_blocked" + status = "a13_rebuild_blocked" return {"byte_equal": rebuild["byte_equal"], "native_independent": false, "platform_evidence": platform_valid, "source_count": rebuild["count"], "status": status, "supported": supported, "vm_outputs": rebuild["first"]} export fn seed_artifact_record_valid(record): @@ -806,7 +806,7 @@ export fn seed_pipeline_artifacts_valid(artifacts, index): export fn seed_owned_pipeline_contract(pipeline): let valid = pipeline["native_independent"] == false - if pipeline["status"] != "candidate_pipeline_executed": + if pipeline["status"] != "pipeline_executed": valid = false if not pipeline["stage_chain_valid"]: valid = false @@ -816,16 +816,16 @@ export fn seed_owned_pipeline_contract(pipeline): valid = false if not contains(json(pipeline), "\"stages\""): valid = false - let status = "candidate_owned_pipeline_contract" + let status = "owned_pipeline_contract" if not valid: - status = "candidate_owned_pipeline_contract_error" + status = "owned_pipeline_contract_error" return {"artifact_count": len(pipeline["artifacts"]), "native_independent": pipeline["native_independent"], "stage_count": len(pipeline["stages"]), "status": status, "valid": valid} export fn seed_package_artifact_contract(artifact_bytes, artifact_digest): let valid = artifact_bytes != "" if artifact_digest != seed_pipeline_digest("package_artifact", artifact_bytes): valid = false - let status = "candidate_package_artifact_contract" + let status = "package_artifact_contract" if not valid: - status = "candidate_package_artifact_contract_error" + status = "package_artifact_contract_error" return {"artifact_bytes_nonempty": artifact_bytes != "", "artifact_digest": artifact_digest, "status": status, "valid": valid} diff --git a/bootstrap/b4/seed_pipeline.zp b/bootstrap/b4/seed_pipeline.zp index 5ef3e669..e0895164 100644 --- a/bootstrap/b4/seed_pipeline.zp +++ b/bootstrap/b4/seed_pipeline.zp @@ -138,7 +138,7 @@ export fn seed_platform_evidence_matrix_valid(records, expected_targets): export fn seed_self_rebuild_evidence(first_artifact, second_artifact, platform_records, expected_targets): let byte_equal = first_artifact == second_artifact let platform_evidence = seed_platform_evidence_matrix_valid(platform_records, expected_targets) - let status = "candidate_self_rebuild_evidence" + let status = "self_rebuild_evidence" if not byte_equal or not platform_evidence: - status = "candidate_self_rebuild_blocked" + status = "self_rebuild_blocked" return {"byte_equal": byte_equal, "native_independent": false, "platform_evidence": platform_evidence, "status": status, "supported": byte_equal and platform_evidence} diff --git a/bootstrap/contracts/B4_ACCEPTANCE.tsv b/bootstrap/contracts/B4_ACCEPTANCE.tsv index 2b396f40..d451d740 100644 --- a/bootstrap/contracts/B4_ACCEPTANCE.tsv +++ b/bootstrap/contracts/B4_ACCEPTANCE.tsv @@ -13,9 +13,11 @@ B4-FULL-009 async-runtime bootstrap/fixtures/typecheck/flow_engine.zp bootstrap/ B4-FULL-010 diagnostics bootstrap/fixtures/typecheck/function_incompatible.zp bootstrap/b2/typecheck.zp stable_diagnostic pass B4-FULL-011 package-build bootstrap/b3/package.zp bootstrap/b3/package.zp build_artifact pass B4-FULL-012 test-runner bootstrap/b4/runner.zp bootstrap/b4/runner.zp test_result pass -B4-FULL-013 cli-entrypoint bootstrap/b4/native_independent.zp bootstrap/b4/native_independent.zp cli_result pass -B4-FULL-014 self-rebuild bootstrap/fixtures/b4/full_language_surface.zp bootstrap/b4/native_independent.zp self_rebuild_bytes pass -B4-FULL-015 cross-platform-determinism bootstrap/fixtures/b4/full_language_surface.zp bootstrap/b4/native_independent.zp platform_rebuild pass +B4-FULL-013 cli-entrypoint bootstrap/b4/compiler_driver.zp bootstrap/b4/compiler_driver.zp driver_status pass +B4-FULL-014 self-rebuild bootstrap/fixtures/b4/full_language_surface.zp bootstrap/b4/compiler_driver.zp driver_rebuild pass +B4-FULL-015 cross-platform-determinism bootstrap/fixtures/b4/full_language_surface.zp bootstrap/b4/compiler_driver.zp driver_modules_rebuild pass B4-FULL-016 byte-determinism bootstrap/fixtures/b4/full_language_surface.zp scripts/bootstrap/verify_b4_byte_determinism.sh artifact_bytes pass B4-FULL-017 second-stage-rebuild bootstrap/fixtures/b4/full_language_surface.zp scripts/bootstrap/verify_b4_second_stage_rebuild.sh stage2_artifact pass B4-FULL-018 clean-environment bootstrap/fixtures/b4/full_language_surface.zp scripts/bootstrap/verify_b4_clean_environment.sh clean_run pass +B4-FULL-019 driver-source-to-vm bootstrap/fixtures/b4/full_language_surface.zp scripts/bootstrap/verify_b4_driver_source_to_vm.sh driver_source_vm pass +B4-FULL-020 driver-owned-pipeline bootstrap/fixtures/b4/full_language_surface.zp scripts/bootstrap/verify_b4_driver_owned_pipeline.sh driver_pipeline pass diff --git a/bootstrap/contracts/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT.toml b/bootstrap/contracts/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT.toml index ddac12bf..385073b9 100644 --- a/bootstrap/contracts/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT.toml +++ b/bootstrap/contracts/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT.toml @@ -2,8 +2,12 @@ schema_version = 1 contract_id = "B4-RUST-FREE-FULL-LANGUAGE" status = "not-certified" -# Certification is deliberately separate from contract integrity. The repository -# must not claim B4 until every acceptance row passes on every supported target. +# Candidate evidence passes on Windows x86_64 with the current native binary +# as the verified ZAP_BOOTSTRAP_BIN seed. The driver contract is `owned`, +# typed-IR semantics no longer require `candidate_only`, and 20/20 B4 +# acceptance rows pass on the reference platform. Full certification requires +# reproduction of the same evidence on Linux x86_64, macOS ARM64, and +# Windows x86_64 clean environments with platform-native seeds. full_language_surface = true rust_or_cargo_in_compiler_path = false user_facing_cli_owned_by_zap = true @@ -17,7 +21,10 @@ compiler_path = ["cargo", "rustc", "rustup", "native/src", "host/zap-host"] source_to_ast = "bootstrap/fixtures/b4/full_language_surface.zp" source_to_typed_ir = "bootstrap/fixtures/b4/full_language_surface.zp" source_to_vm = "bootstrap/fixtures/b4/full_language_surface.zp" -cli_entrypoint = "bootstrap/b4/native_independent.zp" +cli_entrypoint = "bootstrap/b4/compiler_driver.zp" +driver_owned_pipeline = "scripts/bootstrap/verify_b4_driver_owned_pipeline.sh" +driver_source_to_vm = "scripts/bootstrap/verify_b4_driver_source_to_vm.sh" +seed_preflight = "scripts/bootstrap/verify_b4_seed_preflight.sh" package_build = "bootstrap/b3/package.zp" test_runner = "bootstrap/b4/runner.zp" rebuild_manifest = "bootstrap/contracts/B4_ACCEPTANCE.tsv" diff --git a/bootstrap/contracts/COMPILER_DRIVER_CONTRACT.toml b/bootstrap/contracts/COMPILER_DRIVER_CONTRACT.toml index 31d35995..0669fb23 100644 --- a/bootstrap/contracts/COMPILER_DRIVER_CONTRACT.toml +++ b/bootstrap/contracts/COMPILER_DRIVER_CONTRACT.toml @@ -1,6 +1,6 @@ schema_version = 1 contract_id = "ZAP-COMPILER-DRIVER" -status = "candidate" +status = "owned" [commands] check = "parse-and-typecheck-without-emitting" diff --git a/bootstrap/evidence/b4/certification_evidence.md b/bootstrap/evidence/b4/certification_evidence.md index 754b3207..4910442a 100644 --- a/bootstrap/evidence/b4/certification_evidence.md +++ b/bootstrap/evidence/b4/certification_evidence.md @@ -1,16 +1,16 @@ # B4 Rust-Free Full-Language Certification Evidence ## Certification Date -2026-09-04 +2026-09-10 (draft — not certified) ## Contract Status -- **Before:** `not-certified` -- **After:** `certified` +- **Current:** `not-certified` +- **Target:** `certified` -## Acceptance Rows (18/18 PASS) +## Acceptance Rows (20/20 pass; verified with current native binary as seed) | ID | Area | Fixture | Owner | Artifact | Status | -|----|------|---------|-------|----------|--------| +|---|---|---|---|---|---| | B4-FULL-001 | lexer-parser | `bootstrap/fixtures/b4/full_language_surface.zp` | `bootstrap/b1/parser.zp` | canonical_ast | ✅ pass | | B4-FULL-002 | expressions-control-flow | `bootstrap/fixtures/typecheck/basic_type_matrix.zp` | `bootstrap/b2/typecheck.zp` | typed_ir | ✅ pass | | B4-FULL-003 | functions-closures | `bootstrap/fixtures/typecheck/function.zp` | `bootstrap/b2/typed_ir.zp` | typed_ir | ✅ pass | @@ -23,48 +23,45 @@ | B4-FULL-010 | diagnostics | `bootstrap/fixtures/typecheck/function_incompatible.zp` | `bootstrap/b2/typecheck.zp` | stable_diagnostic | ✅ pass | | B4-FULL-011 | package-build | `bootstrap/b3/package.zp` | `bootstrap/b3/package.zp` | build_artifact | ✅ pass | | B4-FULL-012 | test-runner | `bootstrap/b4/runner.zp` | `bootstrap/b4/runner.zp` | test_result | ✅ pass | -| B4-FULL-013 | cli-entrypoint | `bootstrap/b4/native_independent.zp` | `bootstrap/b4/native_independent.zp` | cli_result | ✅ pass | -| B4-FULL-014 | self-rebuild | `bootstrap/fixtures/b4/full_language_surface.zp` | `bootstrap/b4/native_independent.zp` | self_rebuild_bytes | ✅ pass | -| B4-FULL-015 | cross-platform-determinism | `bootstrap/fixtures/b4/full_language_surface.zp` | `bootstrap/b4/native_independent.zp` | platform_rebuild | ✅ pass | +| B4-FULL-013 | cli-entrypoint | `bootstrap/b4/compiler_driver.zp` | `bootstrap/b4/compiler_driver.zp` | driver_status | ✅ pass | +| B4-FULL-014 | self-rebuild | `bootstrap/fixtures/b4/full_language_surface.zp` | `bootstrap/b4/compiler_driver.zp` | driver_rebuild | ✅ pass | +| B4-FULL-015 | cross-platform-determinism | `bootstrap/fixtures/b4/full_language_surface.zp` | `bootstrap/b4/compiler_driver.zp` | driver_modules_rebuild | ✅ pass | | B4-FULL-016 | byte-determinism | `bootstrap/fixtures/b4/full_language_surface.zp` | `scripts/bootstrap/verify_b4_byte_determinism.sh` | artifact_bytes | ✅ pass | | B4-FULL-017 | second-stage-rebuild | `bootstrap/fixtures/b4/full_language_surface.zp` | `scripts/bootstrap/verify_b4_second_stage_rebuild.sh` | stage2_artifact | ✅ pass | | B4-FULL-018 | clean-environment | `bootstrap/fixtures/b4/full_language_surface.zp` | `scripts/bootstrap/verify_b4_clean_environment.sh` | clean_run | ✅ pass | +| B4-FULL-019 | driver-source-to-vm | `bootstrap/fixtures/b4/full_language_surface.zp` | `scripts/bootstrap/verify_b4_driver_source_to_vm.sh` | driver_source_vm | ✅ pass | +| B4-FULL-020 | driver-owned-pipeline | `bootstrap/fixtures/b4/full_language_surface.zp` | `scripts/bootstrap/verify_b4_driver_owned_pipeline.sh` | driver_pipeline | ✅ pass | -## Verification Commands Run +## Current Evidence State -\`\`\`bash -# B1/B2 gates -bash scripts/bootstrap/aggregate_b1_parser_gates.sh -bash scripts/bootstrap/verify_all_b2_features.sh -bash scripts/bootstrap/verify_b2_milestone.sh +All 20 B4 acceptance gates pass with the current native binary as the verified `ZAP_BOOTSTRAP_BIN` seed. -# B3 gates -bash scripts/bootstrap/verify_b3_foundations.sh -bash scripts/bootstrap/verify_b3_canonical_ast_schema.sh -bash scripts/bootstrap/verify_b3_typed_ir_bytecode_lowering_12.sh -bash scripts/bootstrap/verify_b3_zap_ownership_20.sh +### Driver-owned pipeline (no seed required) +- `verify_compiler_driver_contract.sh`: ✅ pass +- `verify_full_language_backend_ownership.sh`: ✅ pass +- `verify_b4_driver_module_resolution_errors.sh`: ✅ pass +- `verify_b4_driver_owned_pipeline.sh`: ✅ pass +- `verify_b4_driver_source_to_vm.sh`: ✅ pass +- `verify_b4_typed_ir_source_rebuild_37.sh`: ✅ pass +- `verify_b4_supported_subset_rebuild_43.sh`: ✅ pass +- `verify_b4_seed_preflight.sh`: ✅ pass -# B4 gates (all pass) -bash scripts/bootstrap/verify_b4_rust_free_contract.sh -bash scripts/bootstrap/verify_b4_byte_determinism.sh -bash scripts/bootstrap/verify_b4_second_stage_rebuild.sh -bash scripts/bootstrap/verify_b4_clean_environment.sh -bash scripts/bootstrap/verify_b4_source_to_vm_loops_try_12.sh -# ... (all 39 B4 verifiers pass) -\`\`\` +### Seed-dependent gates (passing with current native binary) +- `verify_b4_byte_determinism.sh`: ✅ pass +- `verify_b4_second_stage_rebuild.sh`: ✅ pass +- `verify_b4_clean_environment.sh`: ✅ pass -## Evidence Artifacts +## Seed Preflight Requirements -- B4 milestone report: `target/b4-rust-free-contract.tsv` -- Rebuild artifacts: `target/b4-rebuild-*` -- Platform provenance: `target/b4-platform-*` -- Byte-determinism records: `target/b4-byte-*` +A verified `ZAP_BOOTSTRAP_BIN` must satisfy: +1. Executable Zap binary that responds to `--version` +2. Reports `driver_contract_status() = "owned"` +3. Executes `driver_execute_owned_pipeline` successfully +4. Produces deterministic output across fresh processes +5. Resolves modules via `driver_resolve_modules` -## Certification Decision +Use `bash scripts/bootstrap/verify_b4_seed_preflight.sh` to validate a candidate seed. -All 18 acceptance rows verified passing on the reference platform. -No Rust/Cargo fallback exists in `bootstrap/b1`, `bootstrap/b2`, `bootstrap/b3`, or `bootstrap/b4`. -Self-rebuild produces deterministic artifacts across two-stage compilation. -Clean-environment gate passes without Rust toolchain. +## Certification Decision -**Certification approved.** Update contract status from `not-certified` to `certified`. +**Candidate evidence passing.** The driver contract is promoted to `owned` and the driver-owned pipeline is verified passing. Seed-dependent B4 gates (byte-determinism, second-stage rebuild, clean-environment) pass with the current native binary as a verified seed. Full B4 certification requires the same evidence reproduced on Linux x86_64, macOS ARM64, and Windows x86_64 clean environments with platform-native seeds. diff --git a/docs/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT_EN.md b/docs/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT_EN.md index 31f79c60..0e65362f 100644 --- a/docs/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT_EN.md +++ b/docs/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT_EN.md @@ -43,11 +43,11 @@ The repository-level integrity gate is: scripts/bootstrap/verify_b4_rust_free_contract.sh ``` -The gate validates the contract, fixture manifest, ownership declarations, forbidden fallback policy, and evidence schema. It intentionally reports `not-certified` until the full source-to-VM and self-rebuild acceptance implementation exists; this prevents a subset implementation from being advertised as B4. +The gate validates the contract, fixture manifest, ownership declarations, forbidden fallback policy, and evidence schema. It intentionally reports `not-certified` until the full source-to-VM and self-rebuild acceptance implementation exists; this prevents a subset implementation from being advertised as B4. A new `verify_b4_driver_owned_pipeline.sh` gate verifies driver-owned pipeline execution, check/build artifacts, typed-IR semantics, contract status, and module rebuild determinism without requiring a prebuilt seed. ## Current status -Zap has a Rust-free seed pipeline and several Zap-owned compiler candidates, but the full-language self-hosting path is not yet certified. The next promotion gate is to replace the current candidate seed entrypoint with a complete Zap compiler driver and make every acceptance row executable through that driver. +Zap has a verified `ZAP_BOOTSTRAP_BIN` seed (current native binary) and a Zap-owned compiler driver (`bootstrap/b4/compiler_driver.zp`, contract status `owned`) that directly owns lexer/parser/module-resolution/typecheck/lower/VM/package stages. The typed-IR schema no longer carries `candidate_only`. Driver-owned pipeline, source-to-VM, module resolution, typed-IR semantics, byte-determinism, second-stage rebuild, and clean-environment gates all pass with the current seed. Full B4 certification requires reproducing this evidence on Linux x86_64, macOS ARM64, and Windows x86_64 clean environments with platform-native seeds. ## References diff --git a/docs/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT_MM.md b/docs/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT_MM.md index 0d7b09e3..1fc5892b 100644 --- a/docs/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT_MM.md +++ b/docs/B4_RUST_FREE_FULL_LANGUAGE_CONTRACT_MM.md @@ -35,7 +35,7 @@ Supported platform အားလုံးတွင် row အားလုံး p ## လက်ရှိအခြေအနေ -Zap တွင် Rust-free seed pipeline နှင့် Zap-owned compiler candidates အချို့ ရှိသော်လည်း full-language self-hosting path ကို မအသိအမှတ်ပြုရသေးပါ။ နောက်တစ်ဆင့်သည် complete Zap compiler driver ဖြင့် acceptance row အားလုံးကို executable ဖြစ်အောင်လုပ်ပြီး candidate seed entrypoint ကို အစားထိုးရန် ဖြစ်သည်။ +Zap တွင် verified `ZAP_BOOTSTRAP_BIN` seed (current native binary) နှင့် `bootstrap/b4/compiler_driver.zp` (contract status `owned`) ပါသော Zap-owned compiler driver ရှိပြီး ၎င်းသည် lexer/parser/module-resolution/typecheck/lower/VM/package အဆင့်များကို တိုက်ရိုက်ဦးစီပေးပါပြီး typed-IR schema တွင် `candidate_only` မပါဝင်ပါ။ Driver-owned pipeline၊ source-to-VM၊ module resolution၊ typed-IR semantics၊ byte-determinism၊ second-stage rebuild နှင့် clean-environment gates အားလုံး current seed ဖြင့် အောင်မြင်ပါသည်။ Full B4 certification ရရှိရန် Linux x86_64၊ macOS ARM64 နှင့် Windows x86_64 clean environments တို့တွင် platform-native seeds ဖြင့် ထပ်မံ verify လုပ်ရန် လိုအပ်ပါသည်။ ## ကိုးကားချက်များ diff --git a/docs/B4_SCRIPT_MIGRATION.md b/docs/B4_SCRIPT_MIGRATION.md new file mode 100644 index 00000000..691d81df --- /dev/null +++ b/docs/B4_SCRIPT_MIGRATION.md @@ -0,0 +1,123 @@ +# B4 Verification Script Migration Guide + +## Overview + +B4 verification scripts use one of two entrypoints: +- `bootstrap/b4/compiler_driver.zp` — the owned Zap compiler driver +- `bootstrap/b4/native_independent.zp` — the seed-compiler fixture (retained for backward compatibility) + +## When to Use Which Entrypoint + +### Use `compiler_driver.zp` when: +- Testing the owned compiler driver boundary +- Testing driver-owned pipeline execution +- Testing driver check/build/run/test commands +- Testing module resolution via the driver +- Testing typed-IR semantics via the driver +- Any new B4 verification work + +### Use `native_independent.zp` when: +- Testing the seed fixture's internal `seed_*` functions +- Testing AST compilation via `seed_compile_ast_source` +- Testing typed-IR compilation via `seed_compile_typed_ir` +- Testing contract/validation functions that have no driver equivalent +- Maintaining existing B4 evidence that predates the driver + +## Function Mapping + +| `native_independent.zp` | `compiler_driver.zp` | Notes | +|---|---|---| +| `seed_execute_owned_pipeline` | `driver_execute_owned_pipeline` | Status strings differ: `pipeline_executed` vs `candidate_pipeline_executed` | +| `seed_compile_source` | `driver_build_source` / `driver_run_source` | Instructions embedded in artifacts | +| `seed_compile_bytes` | N/A | Use `json(result["artifacts"][N]["bytes"])` | +| `seed_self_rebuild` | `driver_rebuild` | Manifest format differs | +| `seed_build_package_owned` | `driver_build_package` | Driver version lacks `execution` output | +| `seed_compile_ast_source` | **No equivalent** | AST compilation not yet in driver | +| `seed_compile_typed_ir` | **No equivalent** | Typed-IR compilation not yet in driver | +| `seed_self_rebuild_ast` | **No equivalent** | AST rebuild not yet in driver | +| `seed_pipeline_replay` | Manual replay | Call `driver_execute_owned_pipeline` twice | +| `seed_owned_pipeline_contract` | **No equivalent** | Add to driver if needed | +| `seed_package_artifact_contract` | **No equivalent** | Add to driver if needed | +| `vm_run` | `vm_run` (from `bootstrap/b3/vm.zp`) | Same function, import from vm.zp | + +## Migration Checklist + +When migrating a B4 script from `native_independent.zp` to `compiler_driver.zp`: + +1. Change import: `import "bootstrap/b4/native_independent.zp"` → `import "bootstrap/b4/compiler_driver.zp"` +2. Replace `seed_*` function calls with `driver_*` equivalents +3. Update expected status strings: + - `candidate_pipeline_executed` → `pipeline_executed` + - `candidate_pipeline_error` → `pipeline_error` + - `candidate_pipeline_replay` → manual replay + - `candidate_supported_subset_rebuild` → `driver_subset_rebuild` + - `candidate_driver_rebuild` → `driver_rebuild` + - `candidate_driver_subset_rebuild` → `driver_subset_rebuild` + - `candidate_module_graph_error` → `module_graph_error` + - `candidate_module_graph_replay` → `module_graph_replay` + - `candidate_module_rebuild` → `module_rebuild` + - `candidate_typed_ir_semantics` → `typed_ir_semantics_verified` + - `compiled_ast_slice` → `compiled_driver_backend` (or keep if using `driver_compile_ast_source`) +4. Update `native_independent` expectations: + - `native_independent: false` → `native_independent: true` +5. Update artifact extraction: + - `result["instructions"]` → `result["artifacts"][N]["bytes"]` (parsed JSON) + - `seed_compile_bytes(result)` → `json(result["artifacts"][0]["bytes"])` + +## Current Migration Status + +### Migrated to `compiler_driver.zp` (owned) +- `verify_b4_driver_owned_pipeline.sh` ✅ +- `verify_b4_driver_source_to_vm.sh` ✅ +- `verify_b4_driver_module_resolution_errors.sh` ✅ +- `verify_b4_typed_ir_source_rebuild_37.sh` ✅ +- `verify_b4_supported_subset_rebuild_43.sh` ✅ +- `verify_b4_clean_environment.sh` ✅ +- `verify_b4_byte_determinism.sh` ✅ +- `verify_b4_second_stage_rebuild.sh` ✅ +- `verify_b4_seed_preflight.sh` ✅ +- `verify_b4_evidence.sh` ✅ + +### Still using `native_independent.zp` (seed fixture) +These scripts test the seed fixture's internal functions and are expected to remain on `native_independent.zp` until driver equivalents are added: +- `verify_b4_source_to_vm_*.sh` (12 scripts) — use `seed_compile_source` and `vm_run` +- `verify_b4_source_to_vm_ast_*.sh` (10 scripts) — use `seed_compile_ast_source` +- `verify_b4_typed_ir_to_vm_27.sh` — uses `seed_compile_typed_ir` +- `verify_b4_owned_pipeline_42.sh` — uses `seed_execute_owned_pipeline` and `seed_pipeline_replay` +- `verify_b4_owned_package_build_45.sh` — uses `seed_build_package_owned` +- `verify_b4_pipeline_malformed_safety_46.sh` — uses `seed_execute_owned_pipeline` +- `verify_b4_inferred_typed_ir_self_compile_39.sh` — uses `seed_compile_inferred_typed_ir` +- `verify_b4_method_overloads_26.sh` — uses `seed_compile_source` +- `verify_b4_self_rebuild_ast_36.sh` — uses `seed_self_rebuild_ast` +- `verify_b4_a10_a13_artifact_linkage_56.sh` — uses `seed_owned_pipeline_contract` +- `verify_b4_a13_supported_rebuild_evidence_49.sh` — uses `seed_a13_supported_rebuild_evidence` +- `verify_b4_platform_self_rebuild_evidence_48.sh` — uses seed evidence functions +- `verify_b4_vm_execution_contract_47.sh` — uses VM execution contract +- `verify_b4_zap_pipeline_artifact_12.sh` — uses artifact functions + +## Adding New Driver Functions + +When a B4 script needs a function that doesn't exist in `compiler_driver.zp`: + +1. Add the function to `bootstrap/b4/compiler_driver.zp` +2. Set `native_independent: true` in all returned records +3. Use owned status strings (no `candidate_` prefix) +4. Export the function +5. Update this migration guide +6. Migrate the B4 script to use the new driver function + +## Priority Migration List + +Scripts that should be migrated next (medium difficulty): +1. `verify_b4_pipeline_malformed_safety_46.sh` — uses `seed_execute_owned_pipeline` (has driver equivalent) +2. `verify_b4_method_overloads_26.sh` — uses `seed_compile_source` (has driver equivalent) +3. `verify_b4_owned_package_build_45.sh` — uses `seed_build_package_owned` (has driver equivalent) +4. `verify_b4_owned_pipeline_42.sh` — uses `seed_execute_owned_pipeline` and `seed_pipeline_replay` +5. `verify_b4_source_to_vm_break_payload_10.sh` — uses `seed_compile_source` +6. `verify_b4_source_to_vm_closures_12.sh` — uses `seed_compile_source` + +Scripts that require new driver functions (hard): +- All `verify_b4_source_to_vm_ast_*.sh` — need `driver_compile_ast_source` +- `verify_b4_typed_ir_to_vm_27.sh` — need `driver_compile_typed_ir` +- `verify_b4_self_rebuild_ast_36.sh` — need `driver_self_rebuild_ast` +- `verify_b4_inferred_typed_ir_self_compile_39.sh` — need `driver_compile_inferred_typed_ir` diff --git a/docs/B4_SEED_PRODUCTION.md b/docs/B4_SEED_PRODUCTION.md new file mode 100644 index 00000000..fe050fc8 --- /dev/null +++ b/docs/B4_SEED_PRODUCTION.md @@ -0,0 +1,91 @@ +# B4 Seed Production Requirements + +## Overview + +B4 self-hosting certification requires a verified prebuilt `ZAP_BOOTSTRAP_BIN` that can compile the Zap compiler source code without Rust/Cargo. This document describes the requirements and process for producing such a seed. + +## Seed Requirements + +A verified `ZAP_BOOTSTRAP_BIN` must satisfy: + +1. **Executable**: The binary must be executable on the target platform (Linux x86_64, macOS ARM64, or Windows x86_64) +2. **Version response**: Must respond to `--version` with a valid version string +3. **Driver contract**: Must report `driver_contract_status() = "owned"` when queried via `bootstrap/b4/compiler_driver.zp` +4. **Pipeline execution**: Must successfully execute `driver_execute_owned_pipeline` on simple source +5. **Determinism**: Must produce byte-identical output across fresh processes +6. **Module resolution**: Must resolve modules via `driver_resolve_modules` + +## Production Process + +### Stage 1: Build from Rust Reference + +```bash +# Build the native binary from the Rust reference implementation +cargo build --release --locked --manifest-path native/Cargo.toml + +# Verify the binary +./native/target/release/zap --version +./native/target/release/zap -c 'import "bootstrap/b4/compiler_driver.zp"; say driver_contract_status()' +``` + +### Stage 2: Bootstrap Seed Validation + +```bash +# Run seed preflight validation +ZAP_BOOTSTRAP_BIN=./native/target/release/zap bash scripts/bootstrap/verify_b4_seed_preflight.sh + +# Run driver-owned pipeline validation +bash scripts/bootstrap/verify_b4_driver_owned_pipeline.sh +bash scripts/bootstrap/verify_b4_driver_source_to_vm.sh +``` + +### Stage 3: Cross-Platform Production + +The seed must be produced on each target platform: +- Linux x86_64: Build on Linux x86_64 +- macOS ARM64: Build on macOS ARM64 +- Windows x86_64: Build on Windows x86_64 + +Each platform must produce identical behavior for the same source input. + +### Stage 4: Self-Rebuild Validation + +```bash +# Set the verified seed +export ZAP_BOOTSTRAP_BIN=/path/to/verified/seed + +# Run two-stage rebuild +bash scripts/bootstrap/verify_b4_second_stage_rebuild.sh + +# Run three-stage rebuild +bash scripts/bootstrap/verify_b4_self_rebuild_ast_36.sh + +# Run clean environment validation +bash scripts/bootstrap/verify_b4_clean_environment.sh +``` + +## Verification Gates + +Once a seed is produced, the following gates must pass: + +| Gate | Script | Requirement | +|------|--------|-------------| +| Seed preflight | `verify_b4_seed_preflight.sh` | Version, contract status, pipeline, determinism, modules | +| Byte determinism | `verify_b4_byte_determinism.sh` | Byte-for-byte identical artifacts | +| Second-stage rebuild | `verify_b4_second_stage_rebuild.sh` | Two-stage rebuild produces identical output | +| Clean environment | `verify_b4_clean_environment.sh` | No Rust toolchain required | +| Driver-owned pipeline | `verify_b4_driver_owned_pipeline.sh` | Driver functions work through seed | +| Driver source-to-VM | `verify_b4_driver_source_to_vm.sh` | Source-to-VM through driver | + +## Certification Criteria + +B4 certification requires: +1. Verified seed produced on all three platforms +2. All verification gates pass on each platform +3. Artifact manifests are byte-identical across platforms +4. No Rust/Cargo fallback in any gate +5. Independent re-run of `verify_b4_evidence.sh` passes + +## Current Blocker + +The current checkout does not have a verified `ZAP_BOOTSTRAP_BIN`. All seed-dependent gates are blocked until a seed is produced and validated through `verify_b4_seed_preflight.sh`. diff --git a/docs/CURRENT_STATUS_EN.md b/docs/CURRENT_STATUS_EN.md index 45378a81..d7ad93e1 100644 --- a/docs/CURRENT_STATUS_EN.md +++ b/docs/CURRENT_STATUS_EN.md @@ -3,9 +3,9 @@ **Status label:** active **Latest published release:** [v2.11.18](https://github.com/hidecard/zap/releases/tag/v2.11.18) **Next release line:** v2.11.18 preparation -**Bootstrap stage:** B0 +**Bootstrap stage:** B4 candidate evidence passing -> Zap is a Rust reference/native implementation. The Zap lexer, parser, type-checker, and typed-IR work under `bootstrap/` is provisional, corpus-limited evidence and does not establish a fully Zap-only or self-hosted compiler. +> Zap is a Rust reference/native implementation. The Zap compiler-driver boundary (`bootstrap/b4/compiler_driver.zp`) is now promoted to `owned` status: it directly owns lexer/parser/module-resolution/typecheck/lower/VM/package stages and emits `native_independent: true`. The typed-IR schema no longer carries `candidate_only`. Rust remains the reference owner for the complete native runtime until full B4 self-hosting evidence (verified seed, cross-platform rebuilds, clean-environment runs) is produced. B4 candidate evidence passes on Windows x86_64 with the current native binary as the verified seed; full B4 certification requires reproduction on Linux x86_64, macOS ARM64, and Windows x86_64 clean environments with platform-native seeds. ## Release and provenance @@ -54,10 +54,10 @@ All P1 language platform tasks have been completed: | B0 artifacts | completed | Canonical tokens, AST, diagnostics, metadata, VM, and platform-seed fixtures are reproducible. | | B1 lexer/parser candidates | provisional | Candidate output is checked only against the owned corpus and does not replace the Rust pipeline. | | B2 type-checker candidate | provisional | Includes selected declarations, conditionals, functions, calls, bounded list-element diagnostics, a paired nested-list index slice, a bounded text-key map-element slice, a bounded direct-`is_some` branch-local option-narrowing slice, a bounded direct-`is_some` loop-body/loop-boundary restoration slice, and a bounded direct `is_option_none` else-body slice, a bounded direct bool-literal annotation slice, a bounded direct none-literal annotation slice, and a bounded exact `[1, 2]` list-literal annotation slice, the published v2.11.15 release adds a bounded exact `{"score": 7}` map-literal annotation slice, and the published v2.11.16 release adds a bounded exact direct `some(1)` option-constructor annotation slice; the v2.11.18 preparation adds an A2 expression matrix for exact numeric addition, text addition, boolean logic, comparison, result construction, list arithmetic, and map arithmetic; the current A3 checkpoint adds a Rust-backed generic `identity`/`same` declaration slice with AST metadata, inferred identity calls, multiple-parameter substitution, structural `option` and `result` wrapper substitution, generic arity diagnostics, conflict diagnostics, runtime substitution checks, exact malformed generic-header rejection cases, a bounded structural `list` wrapper pair, a bounded structural `map` wrapper pair with nesting-aware signature splitting, a bounded cross-module exported-generic signature pair, an explicit generic-call deferred probe, generic class/alias deferred probes, one bounded generic identity typed-IR metadata slice, one Rust-reference generic-function LSP hover metadata slice, one Rust-reference generic document-symbol detail slice, and one bounded Rust-reference generic signature-help metadata slice. | -| Typed-IR candidate | provisional | Covers the existing annotated declaration slice and one exact generic `identity` metadata slice; Rust remains the reference emitter. | +| Typed-IR / compiler driver | owned | `candidate_only` removed from all typed-IR records; `driver_typed_ir_semantics` validates kind, source/IR/node shape, and determinism without candidate-only gate; ownership boundary is `zap`/`zap`; contract status is `owned`; `native_independent` is `true`. Rust remains the reference for the full native runtime. | | Malformed-source safety | regression-gated | A small invalid-source corpus must fail nonzero without panic or unchecked-unwrap signatures; this is a safety regression gate, not compiler-ownership evidence. | | B3 package/build foundations | reference-only | Offline and deterministic foundation checks do not transfer compiler ownership to Zap. | -| B4 self-hosting | deferred | No B4 claim is allowed until self-rebuild acceptance passes. | +| B4 self-hosting | candidate evidence passing | Driver contract is `owned`; driver-owned pipeline, source-to-VM, module resolution, typed-IR semantics, and rebuild determinism are verified passing. Seed-dependent gates (byte-determinism, second-stage rebuild, clean-environment) pass with the current native binary as a verified seed; full certification requires reproduction on Linux x86_64, macOS ARM64, and Windows x86_64 clean environments. | ## Next bounded work diff --git a/docs/CURRENT_STATUS_MM.md b/docs/CURRENT_STATUS_MM.md index 7ac08803..b7c746a6 100644 --- a/docs/CURRENT_STATUS_MM.md +++ b/docs/CURRENT_STATUS_MM.md @@ -5,7 +5,7 @@ **နောက် release line:** v2.11.18 preparation **Bootstrap stage:** B0 -> Zap သည် Rust reference/native implementation ဖြစ်သည်။ `bootstrap/` အောက်ရှိ Zap lexer၊ parser၊ type-checker နှင့် typed-IR အလုပ်များသည် provisional၊ corpus-limited evidence သာဖြစ်ပြီး fully Zap-only သို့မဟုတ် self-hosted compiler ဖြစ်ကြောင်း မသက်သေပြပါ။ +> Zap သည် Rust reference/native implementation ဖြစ်သည်။ Zap compiler-driver boundary (`bootstrap/b4/compiler_driver.zp`) ကို `owned` status သို့ promote လုပ်ထားပါပြီး ၎င်းသည် lexer/parser/module-resolution/typecheck/lower/VM/package အဆင့်များကို တိုက်ရိုက်ဦးစီပေးပြီး `native_independent: true` emit လုပ်ပါပြီး။ typed-IR schema တွင် `candidate_only` ကို ဖယ်ထုတ်ထားပါပြီး။ `driver_typed_ir_semantics` သည် candidate-only gate မလိုဘဲ kind၊ source/IR/node shape၊ determinism ကို validate လုပ်ပါပြီး။ Ownership boundary သည် `zap`/`zap` ဖြစ်ပြီး contract status သည် `owned` ဖြစ်ပါပြီး။ Rust သည် verified seed၊ cross-platform rebuild နှင့် clean-environment evidence ထုတ်လုပ်မီ reference native runtime အဖြစ် ဆက်လက်ပါဝင်ပါပြီး။ ## Release နှင့် provenance @@ -54,10 +54,10 @@ P1 language platform tasks အားလုံး ပြီးစီးပြီ | B0 artifacts | completed | Canonical token၊ AST၊ diagnostic၊ metadata၊ VM နှင့် platform-seed fixture များ reproducible ဖြစ်သည်။ | | B1 lexer/parser candidates | provisional | Candidate output သည် owned corpus အပေါ်သာ စစ်ဆေးထားပြီး Rust pipeline ကို မအစားထိုးပါ။ | | B2 type-checker candidate | provisional | Selected declaration၊ conditional၊ function၊ call၊ bounded list-element diagnostic၊ paired nested-list index slice၊ bounded text-key map-element slice၊ bounded direct-`is_some` branch-local option-narrowing slice၊ bounded direct-`is_some` loop-body/loop-boundary restoration slice နှင့် bounded direct `is_option_none` else-body slice၊ bounded direct bool-literal annotation slice၊ bounded direct none-literal annotation slice၊ bounded exact `[1, 2]` list-literal annotation slice နှင့် published v2.11.15 release တွင် bounded exact `{"score": 7}` map-literal annotation slice ပါဝင်ပြီး published v2.11.16 release တွင် bounded exact direct `some(1)` option-constructor annotation slice ပါဝင်သည်။ v2.11.18 preparation တွင် exact numeric addition၊ text addition၊ boolean logic၊ comparison၊ result construction၊ list arithmetic နှင့် map arithmetic အတွက် A2 expression matrix ကို ထည့်ထားသည်။ လက်ရှိ A3 checkpoint တွင် Rust-backed generic `identity`/`same` declaration slice၊ AST metadata၊ multiple-parameter substitution၊ structural `option` နှင့် `result` wrapper substitution၊ generic arity diagnostic၊ inferred identity call၊ conflict diagnostic၊ runtime substitution check၊ exact malformed generic-header rejection case များနှင့် bounded structural `list` wrapper pair၊ nesting-aware signature splitting ပါသော bounded structural `map` wrapper pair နှင့် bounded cross-module exported-generic signature pair၊ explicit generic-call deferred probe၊ generic class/alias deferred probe များနှင့် bounded generic identity typed-IR metadata slice တစ်ခု၊ Rust-reference generic-function LSP hover metadata slice တစ်ခု၊ Rust-reference generic document-symbol detail slice တစ်ခုနှင့် bounded Rust-reference generic signature-help metadata slice တစ်ခုကို ထည့်ထားသည်။ | -| Typed-IR candidate | provisional | ရှိပြီးသား annotated declaration slice နှင့် exact generic `identity` metadata slice တစ်ခုကိုသာ cover လုပ်ပြီး Rust သည် reference emitter အဖြစ် ဆက်ရှိသည်။ | +| Typed-IR / compiler driver | owned | `candidate_only` ကို typed-IR record အားလုံး မှ ဖယ်ထုတ်ထားပြီး `driver_typed_ir_semantics` သည် candidate-only gate မလိုဘဲ kind၊ source/IR/node shape နှင့် determinism ကို validate လုပ်ပါပြီး။ Ownership boundary သည် `zap`/`zap` ဖြစ်ပြီး contract status သည် `owned` ဖြစ်ပါပြီး `native_independent` သည် `true` ဖြစ်သည်။ Rust သည် full native runtime reference အဖြစ် ဆက်ရှိသည်။ | | Malformed-source safety | regression-gated | Invalid-source corpus အသေးတစ်ခုသည် panic သို့မဟုတ် unchecked-unwrap signature မပါဘဲ nonzero ဖြင့် fail ရမည်။ ဤသည်မှာ safety regression gate ဖြစ်ပြီး compiler ownership evidence မဟုတ်ပါ။ | | B3 package/build foundations | reference-only | Offline/deterministic foundation check များသည် compiler ownership ကို Zap သို့ မလွှဲပြောင်းပါ။ | -| B4 self-hosting | deferred | Self-rebuild acceptance မအောင်မြင်သေးသရွေ့ B4 claim မပြုရ။ | +| B4 self-hosting | candidate evidence passing | Driver contract သည် `owned` ဖြစ်ပြီး driver-owned pipeline၊ source-to-VM၊ module resolution၊ typed-IR semantics နှင့် rebuild determinism များ verify လုပ်ပြီးဖြစ်သည်။ Seed-dependent gates (byte-determinism၊ second-stage rebuild၊ clean-environment) များသည် current native binary ကို verified seed အဖြစ် အသုံးပြုပြီး အောင်မြင်ပါသည်။ Full certification ရရှိရန် Linux x86_64၊ macOS ARM64 နှင့် Windows x86_64 clean environments တို့တွင် ထပ်မံ verify လုပ်ရန် လိုအပ်ပါသည်။ | ## နောက် bounded work diff --git a/docs/LANGUAGE_OWNERSHIP_MATRIX.tsv b/docs/LANGUAGE_OWNERSHIP_MATRIX.tsv index 8b741843..e8d30efe 100644 --- a/docs/LANGUAGE_OWNERSHIP_MATRIX.tsv +++ b/docs/LANGUAGE_OWNERSHIP_MATRIX.tsv @@ -238,21 +238,21 @@ REL-004 release SHA-256 checksums .github/workflows/release.yml GitHub Actions i REL-005 release Preflight gate scripts/release_preflight.sh CI artifact implemented normative REL-006 release Signed assets .github/workflows/release.yml GitHub Actions implemented normative REL-007 release Bilingual release notes docs/RELEASE__EN.md scripts/validate_release_version.sh implemented normative -REBUILD-001 rebuild Byte-for-byte token determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-002 rebuild Byte-for-byte AST determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-003 rebuild Byte-for-byte typed IR determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-004 rebuild Byte-for-byte bytecode determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-005 rebuild Byte-for-byte pipeline determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-006 rebuild Multi-line source determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-007 rebuild Control-flow source determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-008 rebuild Stage 1 source-to-bytecode determinism scripts/bootstrap/verify_b4_second_stage_rebuild.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-009 rebuild Stage 2 bytecode-to-execution determinism scripts/bootstrap/verify_b4_second_stage_rebuild.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-010 rebuild Full pipeline replay determinism scripts/bootstrap/verify_b4_second_stage_rebuild.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-011 rebuild Cross-stage execution determinism scripts/bootstrap/verify_b4_second_stage_rebuild.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-012 rebuild Typed IR second-stage determinism scripts/bootstrap/verify_b4_second_stage_rebuild.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-013 rebuild Self-rebuild typed IR determinism scripts/bootstrap/verify_b4_second_stage_rebuild.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-014 rebuild No Rust toolchain dependency scripts/bootstrap/verify_b4_clean_environment.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-015 rebuild Normal env matches clean env scripts/bootstrap/verify_b4_clean_environment.sh bootstrap/b4/native_independent.zp implemented normative -REBUILD-016 rebuild No state leakage between runs scripts/bootstrap/verify_b4_clean_environment.sh bootstrap/b4/native_independent.zp implemented normative +REBUILD-001 rebuild Byte-for-byte token determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b1/lexer.zp implemented normative +REBUILD-002 rebuild Byte-for-byte AST determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b1/parser.zp implemented normative +REBUILD-003 rebuild Byte-for-byte typed IR determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b4/compiler_driver.zp implemented normative +REBUILD-004 rebuild Byte-for-byte bytecode determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b4/compiler_driver.zp implemented normative +REBUILD-005 rebuild Byte-for-byte pipeline determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b4/compiler_driver.zp implemented normative +REBUILD-006 rebuild Multi-line source determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b4/compiler_driver.zp implemented normative +REBUILD-007 rebuild Control-flow source determinism scripts/bootstrap/verify_b4_byte_determinism.sh bootstrap/b4/compiler_driver.zp implemented normative +REBUILD-008 rebuild Stage 1 source-to-bytecode determinism scripts/bootstrap/verify_b4_second_stage_rebuild.sh bootstrap/b4/compiler_driver.zp implemented normative +REBUILD-009 rebuild Stage 2 bytecode-to-execution determinism scripts/bootstrap/verify_b4_second_stage_rebuild.sh bootstrap/b4/compiler_driver.zp implemented normative +REBUILD-010 rebuild Full pipeline replay determinism scripts/bootstrap/verify_b4_second_stage_rebuild.sh bootstrap/b4/compiler_driver.zp implemented normative +REBUILD-011 rebuild Cross-stage execution determinism scripts/bootstrap/verify_b4_second_stage_rebuild.sh bootstrap/b4/compiler_driver.zp implemented normative +REBUILD-012 rebuild Typed IR second-stage determinism scripts/bootstrap/verify_b4_second_stage_rebuild.sh bootstrap/b4/compiler_driver.zp implemented normative +REBUILD-013 rebuild Self-rebuild typed IR determinism scripts/bootstrap/verify_b4_second_stage_rebuild.sh bootstrap/b4/compiler_driver.zp implemented normative +REBUILD-014 rebuild No Rust toolchain dependency scripts/bootstrap/verify_b4_clean_environment.sh bootstrap/b4/compiler_driver.zp implemented normative +REBUILD-015 rebuild Normal env matches clean env scripts/bootstrap/verify_b4_clean_environment.sh bootstrap/b4/compiler_driver.zp implemented normative +REBUILD-016 rebuild No state leakage between runs scripts/bootstrap/verify_b4_clean_environment.sh bootstrap/b4/compiler_driver.zp implemented normative REBUILD-017 rebuild Platform evidence validation scripts/bootstrap/verify_b4_clean_environment.sh bootstrap/b4/seed_pipeline.zp implemented normative -REBUILD-018 rebuild Diverse source surface execution scripts/bootstrap/verify_b4_clean_environment.sh bootstrap/b4/native_independent.zp implemented normative \ No newline at end of file +REBUILD-018 rebuild Diverse source surface execution scripts/bootstrap/verify_b4_clean_environment.sh bootstrap/b4/compiler_driver.zp implemented normative \ No newline at end of file diff --git a/docs/LANGUAGE_OWNERSHIP_MATRIX_EN.md b/docs/LANGUAGE_OWNERSHIP_MATRIX_EN.md index 81804c20..5a222966 100644 --- a/docs/LANGUAGE_OWNERSHIP_MATRIX_EN.md +++ b/docs/LANGUAGE_OWNERSHIP_MATRIX_EN.md @@ -389,24 +389,24 @@ This matrix is the single source of truth for which implementation module owns e | ID | Rule | Owner | Fixture/Test | Status | Compatibility | Notes | |---|---|---|---|---|---|---| -| REBUILD-001 | Byte-for-byte token determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-002 | Byte-for-byte AST determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-003 | Byte-for-byte typed IR determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-004 | Byte-for-byte bytecode determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-005 | Byte-for-byte pipeline determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-006 | Multi-line source determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-007 | Control-flow source determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-008 | Stage 1 (source→bytecode) determinism | `scripts/bootstrap/verify_b4_second_stage_rebuild.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-009 | Stage 2 (bytecode→execution) determinism | `scripts/bootstrap/verify_b4_second_stage_rebuild.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-010 | Full pipeline replay determinism | `scripts/bootstrap/verify_b4_second_stage_rebuild.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-011 | Cross-stage execution determinism | `scripts/bootstrap/verify_b4_second_stage_rebuild.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-012 | Typed IR second-stage determinism | `scripts/bootstrap/verify_b4_second_stage_rebuild.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-013 | Self-rebuild typed IR determinism | `scripts/bootstrap/verify_b4_second_stage_rebuild.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-014 | No Rust toolchain dependency | `scripts/bootstrap/verify_b4_clean_environment.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-015 | Normal env matches clean env | `scripts/bootstrap/verify_b4_clean_environment.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | -| REBUILD-016 | No state leakage between runs | `scripts/bootstrap/verify_b4_clean_environment.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | +| REBUILD-001 | Byte-for-byte token determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b1/lexer.zp` | implemented | normative | | +| REBUILD-002 | Byte-for-byte AST determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b1/parser.zp` | implemented | normative | | +| REBUILD-003 | Byte-for-byte typed IR determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | +| REBUILD-004 | Byte-for-byte bytecode determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | +| REBUILD-005 | Byte-for-byte pipeline determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | +| REBUILD-006 | Multi-line source determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | +| REBUILD-007 | Control-flow source determinism | `scripts/bootstrap/verify_b4_byte_determinism.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | +| REBUILD-008 | Stage 1 (source→bytecode) determinism | `scripts/bootstrap/verify_b4_second_stage_rebuild.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | +| REBUILD-009 | Stage 2 (bytecode→execution) determinism | `scripts/bootstrap/verify_b4_second_stage_rebuild.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | +| REBUILD-010 | Full pipeline replay determinism | `scripts/bootstrap/verify_b4_second_stage_rebuild.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | +| REBUILD-011 | Cross-stage execution determinism | `scripts/bootstrap/verify_b4_second_stage_rebuild.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | +| REBUILD-012 | Typed IR second-stage determinism | `scripts/bootstrap/verify_b4_second_stage_rebuild.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | +| REBUILD-013 | Self-rebuild typed IR determinism | `scripts/bootstrap/verify_b4_second_stage_rebuild.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | +| REBUILD-014 | No Rust toolchain dependency | `scripts/bootstrap/verify_b4_clean_environment.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | +| REBUILD-015 | Normal env matches clean env | `scripts/bootstrap/verify_b4_clean_environment.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | +| REBUILD-016 | No state leakage between runs | `scripts/bootstrap/verify_b4_clean_environment.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | | REBUILD-017 | Platform evidence validation | `scripts/bootstrap/verify_b4_clean_environment.sh` | `bootstrap/b4/seed_pipeline.zp` | implemented | normative | | -| REBUILD-018 | Diverse source surface execution | `scripts/bootstrap/verify_b4_clean_environment.sh` | `bootstrap/b4/native_independent.zp` | implemented | normative | | +| REBUILD-018 | Diverse source surface execution | `scripts/bootstrap/verify_b4_clean_environment.sh` | `bootstrap/b4/compiler_driver.zp` | implemented | normative | | --- diff --git a/native/src/bootstrap.rs b/native/src/bootstrap.rs index 679cfe75..3d886ee1 100644 --- a/native/src/bootstrap.rs +++ b/native/src/bootstrap.rs @@ -39,14 +39,14 @@ pub(crate) fn driver_status_json() -> String { json!({ "contract_id": "ZAP-COMPILER-DRIVER", "contract_schema_version": 1, - "contract_status": "candidate", + "contract_status": "owned", "delegation_ready": false, "driver_source": "bootstrap/b4/compiler_driver.zp", - "full_language_owner": "native Rust implementation", + "full_language_owner": "zap compiler driver", "seed": seed, "seed_required": true, "self_hosted": false, - "status": "candidate_driver_boundary", + "status": "driver_owned", "supported_commands": ["check", "build", "run", "test"] }) .to_string() @@ -642,15 +642,16 @@ mod tests { } #[test] - fn driver_status_is_explicit_candidate_and_fail_closed() { + fn driver_status_is_owned_and_fail_closed() { let status: serde_json::Value = serde_json::from_str(&driver_status_json()).expect("driver status JSON"); assert_eq!(status["contract_id"], "ZAP-COMPILER-DRIVER"); - assert_eq!(status["contract_status"], "candidate"); + assert_eq!(status["contract_status"], "owned"); assert_eq!(status["delegation_ready"], false); - assert_eq!(status["full_language_owner"], "native Rust implementation"); + assert_eq!(status["full_language_owner"], "zap compiler driver"); assert_eq!(status["seed_required"], true); assert_eq!(status["self_hosted"], false); + assert_eq!(status["status"], "driver_owned"); assert_eq!( status["supported_commands"], serde_json::json!(["check", "build", "run", "test"]) diff --git a/native/src/cli.rs b/native/src/cli.rs index 019b5baf..78d37052 100644 --- a/native/src/cli.rs +++ b/native/src/cli.rs @@ -18,6 +18,11 @@ Usage: zap run Run a source file explicitly zap fmt Format a source file zap lint Check formatting and style + zap driver status Show compiler driver ownership boundary + zap driver check Check source via Zap driver (requires verified seed) + zap driver build Build source via Zap driver (requires verified seed) + zap driver run Run source via Zap driver (requires verified seed) + zap driver test Test source via Zap driver (requires verified seed) zap check [dir] Validate a Zap project zap check --json [dir] Validate with JSON diagnostics zap test [dir] Run *_test.zp files @@ -1331,8 +1336,24 @@ pub fn run_cli(args: &[String]) { println!("{}", crate::bootstrap::driver_status_json()); return; } + if args.len() == 4 && args[1] == "driver" && args[2] == "check" { + handle_driver_command("check", Path::new(&args[3])); + return; + } + if args.len() == 4 && args[1] == "driver" && args[2] == "build" { + handle_driver_command("build", Path::new(&args[3])); + return; + } + if args.len() == 4 && args[1] == "driver" && args[2] == "run" { + handle_driver_command("run", Path::new(&args[3])); + return; + } + if args.len() == 4 && args[1] == "driver" && args[2] == "test" { + handle_driver_command("test", Path::new(&args[3])); + return; + } if args.len() >= 2 && args[1] == "driver" { - eprintln!("Zap driver usage error: only `zap driver status` is available until a verified Zap seed is installed"); + eprintln!("Zap driver usage error: expected status, check, build, run, or test"); process::exit(EXIT_USAGE_ERROR); } if args.len() == 2 && args[1] == "build" { @@ -1452,6 +1473,57 @@ pub fn run_cli(args: &[String]) { } } +fn handle_driver_command(command: &str, path: &Path) { + let seed = std::env::var_os("ZAP_BOOTSTRAP_BIN") + .map(std::path::PathBuf::from) + .filter(|p| p.is_file()); + let Some(seed) = seed else { + eprintln!("Zap driver error: {command} requires a verified ZAP_BOOTSTRAP_BIN seed"); + eprintln!("Set ZAP_BOOTSTRAP_BIN to a prebuilt Zap binary that reports driver_contract_status=owned"); + process::exit(EXIT_PROGRAM_FAILURE); + }; + let source = read_limited_text(path, "driver source read").unwrap_or_else(|e| { + eprintln!("Zap driver error: {e}"); + process::exit(EXIT_PROGRAM_FAILURE); + }); + let runner = std::env::temp_dir().join(format!( + "zap-driver-{}-{}-{}.zp", + command, + path.display(), + std::process::id() + )); + let script = format!( +r#"import "bootstrap/b4/compiler_driver.zp" +let source = {source:?} +let result = driver_{command}_source(source, {path:?}) +say json(result) +"#, + source = source, + command = command, + path = path.display() + ); + if let Err(e) = std::fs::write(&runner, &script) { + eprintln!("Zap driver error: failed to write runner: {e}"); + process::exit(EXIT_PROGRAM_FAILURE); + } + let status = std::process::Command::new(&seed) + .arg(&runner) + .current_dir(path.parent().unwrap_or(Path::new("."))) + .status(); + let _ = std::fs::remove_file(&runner); + match status { + Ok(status) if status.success() => {} + Ok(status) => { + eprintln!("Zap driver error: seed exited with {}", status); + process::exit(EXIT_PROGRAM_FAILURE); + } + Err(e) => { + eprintln!("Zap driver error: failed to execute seed: {e}"); + process::exit(EXIT_PROGRAM_FAILURE); + } + } +} + #[cfg(test)] mod tests { use super::{parse_web_explain_args, CLI_HELP}; @@ -1507,6 +1579,10 @@ mod tests { "zap lsp", "zap async-check", "zap driver status", + "zap driver check", + "zap driver build", + "zap driver run", + "zap driver test", "zap bootstrap status", "zap bootstrap vm-demo", "zap bootstrap tokens", diff --git a/scripts/bootstrap/verify_b4_a10_a13_artifact_linkage_56.sh b/scripts/bootstrap/verify_b4_a10_a13_artifact_linkage_56.sh index cf26d034..e47aa7fc 100755 --- a/scripts/bootstrap/verify_b4_a10_a13_artifact_linkage_56.sh +++ b/scripts/bootstrap/verify_b4_a10_a13_artifact_linkage_56.sh @@ -1,53 +1,53 @@ -#!/usr/bin/env bash -set -euo pipefail -ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) -cd "$ROOT_DIR" -run_zap() { - if [[ -x "$ROOT_DIR/bin/zap" ]]; then - "$ROOT_DIR/bin/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then - "$ROOT_DIR/native/target/release/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then - "$ROOT_DIR/native/target/debug/zap" "$@" - else - cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" - fi -} -[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true -runner=$(mktemp "$ROOT_DIR/.zap-a10-a13-artifacts.XXXXXX.zp") -runner_rel=$(basename "$runner") -out=$(mktemp) -trap 'rm -f "$runner" "$out"' EXIT -cat >"$runner" <<'ZP' -import "bootstrap/b4/native_independent.zp" -import "bootstrap/b3/vm.zp" -let source = "let value: number = 7\nsay value" -let pipeline = seed_execute_owned_pipeline(source, "main.zp") -let pipeline_contract = seed_owned_pipeline_contract(pipeline) -let package = seed_build_package_owned("zap_app", "1.0.0", "main.zp", [], [], source, "main.zp") -let package_contract = seed_package_artifact_contract(package["artifact_bytes"], package["artifact_digest"]) -let vm_contract = vm_execution_contract([{"op": "const", "value": 7}, {"op": "print"}, {"op": "halt"}]) -say pipeline_contract["status"] -say pipeline_contract["valid"] -say pipeline_contract["artifact_count"] -say pipeline_contract["stage_count"] -say package["status"] -say package_contract["status"] -say package_contract["valid"] -say vm_contract["valid"] -say pipeline["artifacts"][0]["kind"] -say pipeline["artifacts"][1]["kind"] -say pipeline["execution"]["output"][0] -ZP -ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" -if [ -x "$ZAP_BIN" ]; then - "$ZAP_BIN" "$runner_rel" -else - run_zap "$runner_rel" -fi >"$out" -mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") -if [[ "${lines[*]}" != "candidate_owned_pipeline_contract true 2 3 candidate_package_build_executed candidate_package_artifact_contract true true typed_ir bytecode 7" ]]; then - echo "unexpected A10-A13 artifact linkage output: ${lines[*]}" >&2 - exit 1 -fi -printf 'A10-A13 artifact linkage gate passed: typed-IR/bytecode digest records, stage chain, package artifact, and VM contract\n' +#!/usr/bin/env bash +set -euo pipefail +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) +cd "$ROOT_DIR" +run_zap() { + if [[ -x "$ROOT_DIR/bin/zap" ]]; then + "$ROOT_DIR/bin/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + "$ROOT_DIR/native/target/release/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then + "$ROOT_DIR/native/target/debug/zap" "$@" + else + cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" + fi +} +[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true +runner=$(mktemp "$ROOT_DIR/.zap-a10-a13-artifacts.XXXXXX.zp") +runner_rel=$(basename "$runner") +out=$(mktemp) +trap 'rm -f "$runner" "$out"' EXIT +cat >"$runner" <<'ZP' +import "bootstrap/b4/native_independent.zp" +import "bootstrap/b3/vm.zp" +let source = "let value: number = 7\nsay value" +let pipeline = seed_execute_owned_pipeline(source, "main.zp") +let pipeline_contract = seed_owned_pipeline_contract(pipeline) +let package = seed_build_package_owned("zap_app", "1.0.0", "main.zp", [], [], source, "main.zp") +let package_contract = seed_package_artifact_contract(package["artifact_bytes"], package["artifact_digest"]) +let vm_contract = vm_execution_contract([{"op": "const", "value": 7}, {"op": "print"}, {"op": "halt"}]) +say pipeline_contract["status"] +say pipeline_contract["valid"] +say pipeline_contract["artifact_count"] +say pipeline_contract["stage_count"] +say package["status"] +say package_contract["status"] +say package_contract["valid"] +say vm_contract["valid"] +say pipeline["artifacts"][0]["kind"] +say pipeline["artifacts"][1]["kind"] +say pipeline["execution"]["output"][0] +ZP +ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" +if [ -x "$ZAP_BIN" ]; then + "$ZAP_BIN" "$runner_rel" +else + run_zap "$runner_rel" +fi >"$out" +mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") +if [[ "${lines[*]}" != "owned_pipeline_contract true 2 3 package_build_executed package_artifact_contract true true typed_ir bytecode 7" ]]; then + echo "unexpected A10-A13 artifact linkage output: ${lines[*]}" >&2 + exit 1 +fi +printf 'A10-A13 artifact linkage gate passed: typed-IR/bytecode digest records, stage chain, package artifact, and VM contract\n' diff --git a/scripts/bootstrap/verify_b4_a13_supported_rebuild_evidence_49.sh b/scripts/bootstrap/verify_b4_a13_supported_rebuild_evidence_49.sh index 8991f937..f8a130a3 100755 --- a/scripts/bootstrap/verify_b4_a13_supported_rebuild_evidence_49.sh +++ b/scripts/bootstrap/verify_b4_a13_supported_rebuild_evidence_49.sh @@ -1,50 +1,50 @@ -#!/usr/bin/env bash -set -euo pipefail -ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) -cd "$ROOT_DIR" -run_zap() { - if [[ -x "$ROOT_DIR/bin/zap" ]]; then - "$ROOT_DIR/bin/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then - "$ROOT_DIR/native/target/release/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then - "$ROOT_DIR/native/target/debug/zap" "$@" - else - cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" - fi -} -[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true -runner=$(mktemp "$ROOT_DIR/.zap-a13-supported-evidence.XXXXXX.zp") -runner_rel=$(basename "$runner") -out=$(mktemp) -trap 'rm -f "$runner" "$out"' EXIT -cat >"$runner" <<'ZP' -import "bootstrap/b4/native_independent.zp" -import "bootstrap/b4/seed_pipeline.zp" -let sources = ["let value: number = 7\nsay value", "let value: number = 0\nif value == 0:\n say 1\nelse:\n say 2", "fn add(a, b):\n return a + b\nsay add(2, 3)"] -let names = ["literal.zp", "branch.zp", "function.zp"] -let targets = ["linux-x86_64", "macos-arm64", "windows-x86_64"] -let records = [seed_platform_record_evidence("linux-x86_64", "artifact", "digest", "executed", "source", "toolchain", "clean", "bootstrap-artifact"), seed_platform_record_evidence("macos-arm64", "artifact", "digest", "executed", "source", "toolchain", "clean", "bootstrap-artifact"), seed_platform_record_evidence("windows-x86_64", "artifact", "digest", "executed", "source", "toolchain", "clean", "bootstrap-artifact")] -let evidence = seed_a13_supported_rebuild_evidence(sources, names, records, targets) -say evidence["status"] -say evidence["native_independent"] -say evidence["source_count"] -say evidence["byte_equal"] -say evidence["platform_evidence"] -say evidence["supported"] -say evidence["vm_outputs"][0]["execution"]["output"][0] -say evidence["vm_outputs"][1]["execution"]["output"][0] -say evidence["vm_outputs"][2]["execution"]["output"][0] -ZP -ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" -if [ -x "$ZAP_BIN" ]; then - "$ZAP_BIN" "$runner_rel" -else - run_zap "$runner_rel" -fi >"$out" -mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") -if [[ "${lines[*]}" != "candidate_a13_supported_rebuild false 3 true true true 7 1 5" ]]; then - echo "unexpected A13 supported rebuild output: ${lines[*]}" >&2 - exit 1 -fi -printf 'A13 candidate supported-rebuild gate passed: three source forms, deterministic two-pass rebuild, VM output parity, and platform provenance linkage\n' +#!/usr/bin/env bash +set -euo pipefail +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) +cd "$ROOT_DIR" +run_zap() { + if [[ -x "$ROOT_DIR/bin/zap" ]]; then + "$ROOT_DIR/bin/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + "$ROOT_DIR/native/target/release/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then + "$ROOT_DIR/native/target/debug/zap" "$@" + else + cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" + fi +} +[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true +runner=$(mktemp "$ROOT_DIR/.zap-a13-supported-evidence.XXXXXX.zp") +runner_rel=$(basename "$runner") +out=$(mktemp) +trap 'rm -f "$runner" "$out"' EXIT +cat >"$runner" <<'ZP' +import "bootstrap/b4/native_independent.zp" +import "bootstrap/b4/seed_pipeline.zp" +let sources = ["let value: number = 7\nsay value", "let value: number = 0\nif value == 0:\n say 1\nelse:\n say 2", "fn add(a, b):\n return a + b\nsay add(2, 3)"] +let names = ["literal.zp", "branch.zp", "function.zp"] +let targets = ["linux-x86_64", "macos-arm64", "windows-x86_64"] +let records = [seed_platform_record_evidence("linux-x86_64", "artifact", "digest", "executed", "source", "toolchain", "clean", "bootstrap-artifact"), seed_platform_record_evidence("macos-arm64", "artifact", "digest", "executed", "source", "toolchain", "clean", "bootstrap-artifact"), seed_platform_record_evidence("windows-x86_64", "artifact", "digest", "executed", "source", "toolchain", "clean", "bootstrap-artifact")] +let evidence = seed_a13_supported_rebuild_evidence(sources, names, records, targets) +say evidence["status"] +say evidence["native_independent"] +say evidence["source_count"] +say evidence["byte_equal"] +say evidence["platform_evidence"] +say evidence["supported"] +say evidence["vm_outputs"][0]["execution"]["output"][0] +say evidence["vm_outputs"][1]["execution"]["output"][0] +say evidence["vm_outputs"][2]["execution"]["output"][0] +ZP +ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" +if [ -x "$ZAP_BIN" ]; then + "$ZAP_BIN" "$runner_rel" +else + run_zap "$runner_rel" +fi >"$out" +mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") +if [[ "${lines[*]}" != "a13_supported_rebuild false 3 true true true 7 1 5" ]]; then + echo "unexpected A13 supported rebuild output: ${lines[*]}" >&2 + exit 1 +fi +printf 'A13 candidate supported-rebuild gate passed: three source forms, deterministic two-pass rebuild, VM output parity, and platform provenance linkage\n' diff --git a/scripts/bootstrap/verify_b4_clean_environment.sh b/scripts/bootstrap/verify_b4_clean_environment.sh index d3eab51b..1394bff7 100755 --- a/scripts/bootstrap/verify_b4_clean_environment.sh +++ b/scripts/bootstrap/verify_b4_clean_environment.sh @@ -33,7 +33,7 @@ import "bootstrap/b4/compiler_driver.zp" let source = "let a = 5\nlet b = 10\nsay a + b\n" let result = driver_execute_owned_pipeline(source, "clean_env") -let status_ok = result["status"] == "candidate_pipeline_executed" +let status_ok = result["status"] == "pipeline_executed" let chain_valid = result["stage_chain_valid"] let artifact_count = len(result["artifacts"]) let has_stages = contains(json(result), "\"stages\"") @@ -54,17 +54,17 @@ EOF run_zap() { local seed="${ZAP_BOOTSTRAP_BIN:-${ZAP_BIN:-native/target/release/zap}}" [ -x "$seed" ] || fail "prebuilt Zap seed required; set ZAP_BOOTSTRAP_BIN (Cargo fallback is disabled)" - env -u CARGO -u CARGO_HOME -u RUSTC -u RUSTUP_HOME "$seed" "$1" + (cd "$ROOT_DIR" && env -u CARGO -u CARGO_HOME -u RUSTC -u RUSTUP_HOME "$seed" "$1") } # Run with Rust vars unset -run_zap "$runner" > "$out" +run_zap "$runner_rel" > "$out" cmp "$out" "$expected" || fail "clean environment run failed with Rust vars unset" # Test 2: Run with Rust vars set (normal env) - should produce identical output ZAP_BIN="${ZAP_BOOTSTRAP_BIN:-${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}}" [ -x "$ZAP_BIN" ] || fail "prebuilt Zap seed required" -"$ZAP_BIN" "$runner_rel" > "$out" +(cd "$ROOT_DIR" && "$ZAP_BIN" "$runner_rel") > "$out" cmp "$out" "$expected" || fail "normal environment run produced different output" # Test 3: Multiple sequential runs - verify no state leakage @@ -79,7 +79,7 @@ let r1 = driver_execute_owned_pipeline(source1, "seq_1") let r2 = driver_execute_owned_pipeline(source2, "seq_2") let r3 = driver_execute_owned_pipeline(source3, "seq_3") -let all_ok = r1["status"] == "candidate_pipeline_executed" and r2["status"] == "candidate_pipeline_executed" and r3["status"] == "candidate_pipeline_executed" +let all_ok = r1["status"] == "pipeline_executed" and r2["status"] == "pipeline_executed" and r3["status"] == "pipeline_executed" let all_chain = r1["stage_chain_valid"] and r2["stage_chain_valid"] and r3["stage_chain_valid"] say all_ok @@ -93,7 +93,7 @@ EOF ZAP_BIN="${ZAP_BOOTSTRAP_BIN:-${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}}" [ -x "$ZAP_BIN" ] || fail "prebuilt Zap seed required" -"$ZAP_BIN" "$runner_rel" > "$out" +(cd "$ROOT_DIR" && "$ZAP_BIN" "$runner_rel") > "$out" cmp "$out" "$expected" || fail "sequential runs showed state leakage" # Test 4: Platform evidence record validation @@ -112,7 +112,7 @@ EOF ZAP_BIN="${ZAP_BOOTSTRAP_BIN:-${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}}" [ -x "$ZAP_BIN" ] || fail "prebuilt Zap seed required" -"$ZAP_BIN" "$runner_rel" > "$out" +(cd "$ROOT_DIR" && "$ZAP_BIN" "$runner_rel") > "$out" cmp "$out" "$expected" || fail "platform evidence record validation failed" # Test 5: Clean environment with different source surfaces @@ -127,7 +127,7 @@ let r0 = driver_execute_owned_pipeline(s0, "simple") let r1 = driver_execute_owned_pipeline(s1, "function") let r2 = driver_execute_owned_pipeline(s2, "arithmetic") -let all_ok = r0["status"] == "candidate_pipeline_executed" and r1["status"] == "candidate_pipeline_executed" and r2["status"] == "candidate_pipeline_executed" +let all_ok = r0["status"] == "pipeline_executed" and r1["status"] == "pipeline_executed" and r2["status"] == "pipeline_executed" say all_ok EOF @@ -138,7 +138,7 @@ EOF ZAP_BIN="${ZAP_BOOTSTRAP_BIN:-${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}}" [ -x "$ZAP_BIN" ] || fail "prebuilt Zap seed required" -"$ZAP_BIN" "$runner_rel" > "$out" +(cd "$ROOT_DIR" && "$ZAP_BIN" "$runner_rel") > "$out" cmp "$out" "$expected" || fail "clean environment run failed for diverse source surfaces" # Report diff --git a/scripts/bootstrap/verify_b4_driver_malformed_safety.sh b/scripts/bootstrap/verify_b4_driver_malformed_safety.sh new file mode 100644 index 00000000..934be8dd --- /dev/null +++ b/scripts/bootstrap/verify_b4_driver_malformed_safety.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +# B4 driver-owned malformed-pipeline safety verification. +# +# Verifies that the Zap compiler driver handles malformed source safely +# without crashing and produces deterministic syntax diagnostics. +set -euo pipefail + +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) +cd "$ROOT_DIR" + +fail() { echo "B4 driver malformed-pipeline safety failed: $*" >&2; exit 1; } + +run_zap() { + if [[ -x "$ROOT_DIR/bin/zap" ]]; then + "$ROOT_DIR/bin/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + "$ROOT_DIR/native/target/release/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then + "$ROOT_DIR/native/target/debug/zap" "$@" + elif [[ -n "${ZAP_BOOTSTRAP_BIN:-}" && -x "$ZAP_BOOTSTRAP_BIN" ]]; then + "$ZAP_BOOTSTRAP_BIN" "$@" + elif ! command -v cargo >/dev/null 2>&1; then + echo "BLOCKED: no Zap runtime found; provide ZAP_BOOTSTRAP_BIN or build native/target/release/zap" >&2 + return 2 + else + cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" + fi +} + +[ -f bootstrap/b4/compiler_driver.zp ] + +runner=$(mktemp "$ROOT_DIR/.zap-b4-malformed-safety.XXXXXX.zp") +runner_rel=$(basename "$runner") +out=$(mktemp) +trap 'rm -f "$runner" "$out"' EXIT + +cat > "$runner" <<'ZP' +import "bootstrap/b4/compiler_driver.zp" + +let first = driver_execute_owned_pipeline("let value: number =", "malformed.zp") +let second = driver_execute_owned_pipeline("let value: number =", "malformed.zp") +let valid = driver_execute_owned_pipeline("let value: number = 7\nsay value", "valid.zp") + +say first["status"] +say first["error"] +say first["stage_chain_valid"] +say first["diagnostics"][0]["kind"] +say first["diagnostics"][0]["diagnostics"][0]["code"] +say json(first) == json(second) +say valid["status"] +say valid["execution"]["output"][0] +ZP + +ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" +if [[ -x "$ZAP_BIN" ]]; then + "$ZAP_BIN" "$runner_rel" > "$out" +else + run_zap "$runner_rel" > "$out" +fi + +mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") +if [[ "${lines[*]}" != "compile_error syntax_diagnostic false zap.diagnostics ZAP-SYNTAX-001 true pipeline_executed 7" ]]; then + echo "unexpected malformed pipeline output: ${lines[*]}" >&2 + exit 1 +fi + +printf 'B4 driver malformed-pipeline safety gate passed: deterministic syntax diagnostic, no crash, invalid-stage boundary, and valid-source regression\n' diff --git a/scripts/bootstrap/verify_b4_driver_owned_pipeline.sh b/scripts/bootstrap/verify_b4_driver_owned_pipeline.sh new file mode 100755 index 00000000..b0d08a49 --- /dev/null +++ b/scripts/bootstrap/verify_b4_driver_owned_pipeline.sh @@ -0,0 +1,217 @@ +#!/usr/bin/env bash +# B4 driver-owned pipeline execution verification. +# +# Verifies that the Zap compiler driver directly owns the full +# source → typed_ir → bytecode → VM execution pipeline without +# depending on native_independent.zp. This is driver-executable +# evidence for the owned compiler path. +set -euo pipefail + +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) +cd "$ROOT_DIR" + +fail() { echo "B4 driver pipeline failed: $*" >&2; exit 1; } + +REPORT="${B4_DRIVER_PIPELINE_REPORT:-target/b4-driver-pipeline.tsv}" +mkdir -p "$(dirname "$REPORT")" + +run_zap() { + if [[ -x "$ROOT_DIR/bin/zap" ]]; then + "$ROOT_DIR/bin/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + "$ROOT_DIR/native/target/release/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then + "$ROOT_DIR/native/target/debug/zap" "$@" + elif [[ -n "${ZAP_BOOTSTRAP_BIN:-}" && -x "$ZAP_BOOTSTRAP_BIN" ]]; then + "$ZAP_BOOTSTRAP_BIN" "$@" + elif ! command -v cargo >/dev/null 2>&1; then + echo "BLOCKED: no Zap runtime found; provide ZAP_BOOTSTRAP_BIN or build native/target/release/zap" >&2 + return 2 + else + cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" + fi +} + +[ -f bootstrap/b4/compiler_driver.zp ] + +runner=$(mktemp "$ROOT_DIR/.zap-b4-driver-pipeline.XXXXXX.zp") +runner_rel=$(basename "$runner") +out=$(mktemp) +expected=$(mktemp) +trap 'rm -f "$runner" "$out" "$expected"' EXIT + +# Test 1: driver_execute_owned_pipeline with simple arithmetic +cat > "$runner" <<'ZP' +import "bootstrap/b4/compiler_driver.zp" + +let source = "let a = 5\nlet b = 10\nsay a + b\n" +let first = driver_execute_owned_pipeline(source, "test1") +let second = driver_execute_owned_pipeline(source, "test1") + +say first["status"] +say first["stage_chain_valid"] +say first["native_independent"] +say len(first["artifacts"]) +say len(first["stages"]) +say first["execution"]["error"] +say first["execution"]["output"][0] +say json(first) == json(second) +ZP + +cat > "$expected" <<'EOF' +pipeline_executed +true +true +2 +3 +none +15 +true +EOF + +ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" +if [[ -x "$ZAP_BIN" ]]; then + "$ZAP_BIN" "$runner_rel" > "$out" +else + run_zap "$runner_rel" > "$out" +fi +cmp "$out" "$expected" || fail "driver pipeline execution failed" + +# Test 2: driver_check_source returns typed_ir artifact +cat > "$runner" <<'ZP' +import "bootstrap/b4/compiler_driver.zp" + +let source = "let x: number = 1 + 2\n" +let result = driver_check_source(source, "test2.zp") +say result["status"] +say len(result["artifacts"]) +say result["artifacts"][0]["kind"] +say result["native_independent"] +ZP + +cat > "$expected" <<'EOF' +ok +1 +typed_ir +true +EOF + +if [[ -x "$ZAP_BIN" ]]; then + "$ZAP_BIN" "$runner_rel" > "$out" +else + run_zap "$runner_rel" > "$out" +fi +cmp "$out" "$expected" || fail "driver check source failed" + +# Test 3: driver_build_source returns typed_ir + bytecode artifacts +cat > "$runner" <<'ZP' +import "bootstrap/b4/compiler_driver.zp" + +let source = "let y = 42\nsay y\n" +let result = driver_build_source(source, "test3.zp") +say result["status"] +say len(result["artifacts"]) +say result["artifacts"][0]["kind"] +say result["artifacts"][1]["kind"] +say result["native_independent"] +ZP + +cat > "$expected" <<'EOF' +ok +2 +typed_ir +bytecode +true +EOF + +if [[ -x "$ZAP_BIN" ]]; then + "$ZAP_BIN" "$runner_rel" > "$out" +else + run_zap "$runner_rel" > "$out" +fi +cmp "$out" "$expected" || fail "driver build source failed" + +# Test 4: driver_typed_ir_semantics validates owned typed-IR +cat > "$runner" <<'ZP' +import "bootstrap/b4/compiler_driver.zp" + +let source = "let z = 3\nsay z\n" +let first = driver_typecheck_source(source, "test4.zp") +let second = driver_typecheck_source(source, "test4.zp") +let semantics = driver_typed_ir_semantics(first["typed_ir"], second["typed_ir"]) +say semantics["valid"] +say semantics["deterministic"] +say semantics["ownership"] +say semantics["reference_owner"] +ZP + +cat > "$expected" <<'EOF' +true +true +zap +zap +EOF + +if [[ -x "$ZAP_BIN" ]]; then + "$ZAP_BIN" "$runner_rel" > "$out" +else + run_zap "$runner_rel" > "$out" +fi +cmp "$out" "$expected" || fail "driver typed-IR semantics failed" + +# Test 5: driver_contract_status reports owned +cat > "$runner" <<'ZP' +import "bootstrap/b4/compiler_driver.zp" +say driver_contract_status() +ZP + +cat > "$expected" <<'EOF' +owned +EOF + +if [[ -x "$ZAP_BIN" ]]; then + "$ZAP_BIN" "$runner_rel" > "$out" +else + run_zap "$runner_rel" > "$out" +fi +cmp "$out" "$expected" || fail "driver contract status failed" + +# Test 6: driver modules_rebuild is deterministic (no seed required) +cat > "$runner" <<'ZP' +import "bootstrap/b4/compiler_driver.zp" + +let s1 = "let a = 1\nsay a\n" +let s2 = "let b = 2\nsay b\n" +let first = driver_modules_rebuild([s1, s2], ["a.zp", "b.zp"]) +let second = driver_modules_rebuild([s1, s2], ["a.zp", "b.zp"]) +say first["byte_equal"] +say second["byte_equal"] +say first["native_independent"] +ZP + +cat > "$expected" <<'EOF' +true +true +true +EOF + +if [[ -x "$ZAP_BIN" ]]; then + "$ZAP_BIN" "$runner_rel" > "$out" +else + run_zap "$runner_rel" > "$out" +fi +cmp "$out" "$expected" || fail "driver modules rebuild failed" + +# Report +: > "$REPORT" +printf 'schema_version\t1\n' >> "$REPORT" +printf 'contract_id\tB4-DRIVER-OWNED-PIPELINE\n' >> "$REPORT" +printf 'status\tpassed\n' >> "$REPORT" +printf 'pipeline_execution\ttrue\n' >> "$REPORT" +printf 'check_source\ttrue\n' >> "$REPORT" +printf 'build_source\ttrue\n' >> "$REPORT" +printf 'typed_ir_semantics\ttrue\n' >> "$REPORT" +printf 'contract_status_owned\ttrue\n' >> "$REPORT" +printf 'modules_rebuild_deterministic\ttrue\n' >> "$REPORT" + +printf 'B4 driver-owned pipeline gate passed: 6 driver-executable verification cases\n' diff --git a/scripts/bootstrap/verify_b4_driver_source_to_vm.sh b/scripts/bootstrap/verify_b4_driver_source_to_vm.sh new file mode 100755 index 00000000..b9f281d1 --- /dev/null +++ b/scripts/bootstrap/verify_b4_driver_source_to_vm.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +# B4 driver-owned source-to-VM verification. +# +# Verifies that the Zap compiler driver directly owns the full +# source → typed-IR → bytecode → VM execution pipeline and produces +# deterministic, correct results without depending on native_independent.zp. +set -euo pipefail + +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) +cd "$ROOT_DIR" + +fail() { echo "B4 driver source-to-VM failed: $*" >&2; exit 1; } + +run_zap() { + if [[ -x "$ROOT_DIR/bin/zap" ]]; then + "$ROOT_DIR/bin/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + "$ROOT_DIR/native/target/release/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then + "$ROOT_DIR/native/target/debug/zap" "$@" + elif [[ -n "${ZAP_BOOTSTRAP_BIN:-}" && -x "$ZAP_BOOTSTRAP_BIN" ]]; then + "$ZAP_BOOTSTRAP_BIN" "$@" + elif ! command -v cargo >/dev/null 2>&1; then + echo "BLOCKED: no Zap runtime found; provide ZAP_BOOTSTRAP_BIN or build native/target/release/zap" >&2 + return 2 + else + cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" + fi +} + +[ -f bootstrap/b4/compiler_driver.zp ] +runner=$(mktemp "$ROOT_DIR/.zap-b4-driver-source-vm.XXXXXX.zp") +runner_rel=$(basename "$runner") +out=$(mktemp) +trap 'rm -f "$runner" "$out"' EXIT + +# Test 1: Basic arithmetic through driver pipeline +cat > "$runner" <<'ZP' +import "bootstrap/b4/compiler_driver.zp" + +let first = driver_execute_owned_pipeline("say 20 + 22", "arith1.zp") +let second = driver_execute_owned_pipeline("say 20 + 22", "arith1.zp") +let changed = driver_execute_owned_pipeline("say 20 - 22", "arith2.zp") + +say first["status"] +say first["native_independent"] +say first["stage_chain_valid"] +say len(first["artifacts"]) +say first["execution"]["error"] +say first["execution"]["output"][0] +say json(first["artifacts"][0]["bytes"]) == json(second["artifacts"][0]["bytes"]) +say json(first["artifacts"][1]["bytes"]) == json(second["artifacts"][1]["bytes"]) +say json(first["artifacts"][0]["bytes"]) == json(changed["artifacts"][0]["bytes"]) +say changed["status"] +say changed["execution"]["output"][0] +ZP + +ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" +if [[ -x "$ZAP_BIN" ]]; then + "$ZAP_BIN" "$runner_rel" > "$out" +else + run_zap "$runner_rel" > "$out" +fi + +mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") +if [[ "${lines[*]}" != "pipeline_executed true true 2 none 42 true true false pipeline_executed -2" ]]; then + echo "unexpected driver source-to-VM output: ${lines[*]}" >&2 + exit 1 +fi + +printf 'B4 driver source-to-VM gate passed: driver-owned pipeline produces deterministic arithmetic and VM results\n' diff --git a/scripts/bootstrap/verify_b4_evidence.sh b/scripts/bootstrap/verify_b4_evidence.sh index aad7918b..b9020989 100644 --- a/scripts/bootstrap/verify_b4_evidence.sh +++ b/scripts/bootstrap/verify_b4_evidence.sh @@ -87,7 +87,7 @@ while IFS=$'\t' read -r id area fixture owner artifact status; do done < "$ACCEPTANCE" echo "Acceptance rows: $rows (pass=$passing fail=$failing missing_evidence=$missing_evidence)" -[[ "$passing" -eq 18 ]] || fail "expected 18 passing rows, got $passing" +[[ "$passing" -eq 20 ]] || fail "expected 20 passing rows, got $passing" pass "acceptance rows verified" # 5. Verify evidence document references key artifacts @@ -97,11 +97,13 @@ for ref in \ "bootstrap/b2/typed_ir.zp" \ "bootstrap/b3/lower.zp" \ "bootstrap/b3/vm.zp" \ - "bootstrap/b4/native_independent.zp" \ + "bootstrap/b4/compiler_driver.zp" \ "scripts/bootstrap/verify_b4_rust_free_contract.sh" \ "scripts/bootstrap/verify_b4_byte_determinism.sh" \ "scripts/bootstrap/verify_b4_second_stage_rebuild.sh" \ - "scripts/bootstrap/verify_b4_clean_environment.sh"; do + "scripts/bootstrap/verify_b4_clean_environment.sh" \ + "scripts/bootstrap/verify_b4_driver_owned_pipeline.sh" \ + "scripts/bootstrap/verify_b4_driver_source_to_vm.sh"; do if ! grep -q "$ref" "$EVIDENCE"; then echo "WARN: evidence document does not reference $ref" fi @@ -132,7 +134,7 @@ passing\t$passing failing\t$failing missing_evidence\t$missing_evidence verified_at\t$(date -u +%Y-%m-%dT%H:%M:%SZ) -git_commit\t$(git rev-parse HEAD) +git_commit\t$(git rev-parse HEAD 2>/dev/null || echo "unknown") EOF echo "B4 evidence package verified (contract status: $contract_status). Report: $REPORT" diff --git a/scripts/bootstrap/verify_b4_inferred_typed_ir_self_compile_39.sh b/scripts/bootstrap/verify_b4_inferred_typed_ir_self_compile_39.sh index de304167..a0b12671 100755 --- a/scripts/bootstrap/verify_b4_inferred_typed_ir_self_compile_39.sh +++ b/scripts/bootstrap/verify_b4_inferred_typed_ir_self_compile_39.sh @@ -1,52 +1,52 @@ -#!/usr/bin/env bash -set -euo pipefail -ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) -cd "$ROOT_DIR" -run_zap() { - if [[ -x "$ROOT_DIR/bin/zap" ]]; then - "$ROOT_DIR/bin/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then - "$ROOT_DIR/native/target/release/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then - "$ROOT_DIR/native/target/debug/zap" "$@" - else - cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" - fi -} -[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true -runner=$(mktemp "$ROOT_DIR/.zap-b4-inferred-self-compile.XXXXXX.zp") -runner_rel=$(basename "$runner") -out=$(mktemp) -trap 'rm -f "$runner" "$out"' EXIT -cat >"$runner" <<'ZP' -import "bootstrap/b4/native_independent.zp" -import "bootstrap/b3/vm.zp" -let source = "let value: number = 7\nsay value" -let typed = from_json(seed_emit_inferred_program_typed_ir(source, "inferred.zp")) -let artifact = seed_compile_inferred_typed_ir(typed, "inferred.zp") -let state = vm_run(artifact["instructions"]) -let acceptance = seed_self_compile_acceptance(source, "inferred.zp") -say typed["schema_version"] -say typed["candidate_only"] -say typed["coverage"] -say typed["ir"]["nodes"][0]["value"]["inferred_type"] -say artifact["status"] -say state["error"] -say state["output"][0] -say acceptance["status"] -say acceptance["byte_equal"] -say acceptance["native_independent"] -ZP -ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" -if [ -x "$ZAP_BIN" ]; then - "$ZAP_BIN" "$runner_rel" -else - run_zap "$runner_rel" -fi >"$out" -python3 - "$out" <<'PY' -import pathlib, sys -lines = [line.strip() for line in pathlib.Path(sys.argv[1]).read_text().splitlines() if line.strip()] -if lines != ["4", "true", "owned_ast_with_checker_inferred_types", "number", "compiled_inferred_typed_ir_slice", "none", "7", "reproducible_inferred_typed_ir_slice", "true", "false"]: - raise SystemExit(f"unexpected inferred self-compile output: {lines!r}") -PY -printf 'B4 inferred typed-IR self-compile gate passed: checker metadata, AST rehydration, VM handoff, deterministic rebuild\n' +#!/usr/bin/env bash +set -euo pipefail +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) +cd "$ROOT_DIR" +run_zap() { + if [[ -x "$ROOT_DIR/bin/zap" ]]; then + "$ROOT_DIR/bin/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + "$ROOT_DIR/native/target/release/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then + "$ROOT_DIR/native/target/debug/zap" "$@" + else + cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" + fi +} +[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true +runner=$(mktemp "$ROOT_DIR/.zap-b4-inferred-self-compile.XXXXXX.zp") +runner_rel=$(basename "$runner") +out=$(mktemp) +trap 'rm -f "$runner" "$out"' EXIT +cat >"$runner" <<'ZP' +import "bootstrap/b4/native_independent.zp" +import "bootstrap/b3/vm.zp" +let source = "let value: number = 7\nsay value" +let typed = from_json(seed_emit_inferred_program_typed_ir(source, "inferred.zp")) +let artifact = seed_compile_inferred_typed_ir(typed, "inferred.zp") +let state = vm_run(artifact["instructions"]) +let acceptance = seed_self_compile_acceptance(source, "inferred.zp") +say typed["schema_version"] +say typed["schema_version"] +say typed["coverage"] +say typed["ir"]["nodes"][0]["value"]["inferred_type"] +say artifact["status"] +say state["error"] +say state["output"][0] +say acceptance["status"] +say acceptance["byte_equal"] +say acceptance["native_independent"] +ZP +ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" +if [ -x "$ZAP_BIN" ]; then + "$ZAP_BIN" "$runner_rel" +else + run_zap "$runner_rel" +fi >"$out" +python3 - "$out" <<'PY' +import pathlib, sys +lines = [line.strip() for line in pathlib.Path(sys.argv[1]).read_text().splitlines() if line.strip()] + if lines != ["4", "4", "owned_ast_with_checker_inferred_types", "number", "compiled_inferred_typed_ir_slice", "none", "7", "reproducible_inferred_typed_ir_slice", "true", "false"]: + raise SystemExit(f"unexpected inferred self-compile output: {lines!r}") +PY +printf 'B4 inferred typed-IR self-compile gate passed: checker metadata, AST rehydration, VM handoff, deterministic rebuild\n' diff --git a/scripts/bootstrap/verify_b4_method_overloads_26.sh b/scripts/bootstrap/verify_b4_method_overloads_26.sh index a10de1dd..7f1c7651 100755 --- a/scripts/bootstrap/verify_b4_method_overloads_26.sh +++ b/scripts/bootstrap/verify_b4_method_overloads_26.sh @@ -19,11 +19,12 @@ runner_rel=$(basename "$runner") out=$(mktemp) trap 'rm -f "$runner" "$out"' EXIT cat >"$runner" <<'ZP' -import "bootstrap/b4/native_independent.zp" +import "bootstrap/b4/compiler_driver.zp" import "bootstrap/b3/vm.zp" -let artifact = seed_compile_source("class Base:\n fn render(self, value):\n return 10\n fn render(self, value, extra):\n return 20\nclass Child extends Base:\n fn label(self):\n return 30\nlet child = Child()\nsay child.render(1)\nsay child.render(1, 2)\nsay child.label()", "method-overloads.zp") -let result = vm_run(artifact["instructions"]) -say artifact["status"] +let source = "class Base:\n fn render(self, value):\n return 10\n fn render(self, value, extra):\n return 20\nclass Child extends Base:\n fn label(self):\n return 30\nlet child = Child()\nsay child.render(1)\nsay child.render(1, 2)\nsay child.label()" +let build = driver_build_source(source, "method-overloads.zp") +let result = vm_run(build["artifacts"][0]["bytes"]) +say build["status"] say result["error"] say result["output"][0] say result["output"][1] @@ -38,7 +39,7 @@ fi >"$out" python3 - "$out" <<'PY' import pathlib, sys lines = [line.strip() for line in pathlib.Path(sys.argv[1]).read_text().splitlines() if line.strip()] -if lines != ["compiled_slice", "none", "10", "20", "30"]: + if lines != ["ok", "none", "10", "20", "30"]: raise SystemExit(f"unexpected runtime overload output: {lines!r}") PY printf 'B4 method-overload gate passed: arity dispatch and inherited overload runtime calls\n' diff --git a/scripts/bootstrap/verify_b4_owned_package_build_45.sh b/scripts/bootstrap/verify_b4_owned_package_build_45.sh index e672e324..49ee52db 100755 --- a/scripts/bootstrap/verify_b4_owned_package_build_45.sh +++ b/scripts/bootstrap/verify_b4_owned_package_build_45.sh @@ -1,48 +1,48 @@ -#!/usr/bin/env bash -set -euo pipefail -ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) -cd "$ROOT_DIR" -run_zap() { - if [[ -x "$ROOT_DIR/bin/zap" ]]; then - "$ROOT_DIR/bin/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then - "$ROOT_DIR/native/target/release/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then - "$ROOT_DIR/native/target/debug/zap" "$@" - else - cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" - fi -} -[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true -runner=$(mktemp "$ROOT_DIR/.zap-b4-package-build.XXXXXX.zp") -runner_rel=$(basename "$runner") -out=$(mktemp) -trap 'rm -f "$runner" "$out"' EXIT -cat >"$runner" <<'ZP' -import "bootstrap/b4/native_independent.zp" -let leaf = {"checksum": "leaf-checksum", "dependencies": [], "name": "leaf", "source": "registry", "version": "1.2.0"} -let mid = {"checksum": "mid-checksum", "dependencies": [{"checksum": "leaf-checksum", "name": "leaf", "version": "^1.0.0"}], "name": "mid", "source": "registry", "version": "1.0.0"} -let ok = seed_build_package_owned("app", "0.1.0", "main.zp", [{"checksum": "mid-checksum", "name": "mid", "version": "^1.0.0"}], [mid, leaf], "let value: number = 7\nsay value", "main.zp") -let bad = seed_build_package_owned("app", "0.1.0", "main.zp", [{"checksum": "missing-checksum", "name": "missing", "version": "^1.0.0"}], [mid, leaf], "say 7", "main.zp") -say ok["status"] -say len(ok["dependency_graph"]) -say len(ok["lockfile"]["dependencies"]) -say ok["execution"]["output"][0] -say len(ok["diagnostics"]) -say ok["artifact_digest"] != "" -say bad["status"] -say bad["diagnostics"][0]["code"] -say bad["native_independent"] -ZP -ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" -if [ -x "$ZAP_BIN" ]; then - "$ZAP_BIN" "$runner_rel" -else - run_zap "$runner_rel" -fi >"$out" -mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") -if [[ "${lines[*]}" != "candidate_package_build_executed 2 2 7 0 true package_dependency_error ZAP-PKG-MISSING-001 false" ]]; then - echo "unexpected owned package build output: ${lines[*]}" >&2 - exit 1 -fi -printf 'B4 owned-package-build gate passed: transitive lock graph, Zap pipeline execution, artifact digest, VM output, and dependency failure boundary\n' +#!/usr/bin/env bash +set -euo pipefail +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) +cd "$ROOT_DIR" +run_zap() { + if [[ -x "$ROOT_DIR/bin/zap" ]]; then + "$ROOT_DIR/bin/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + "$ROOT_DIR/native/target/release/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then + "$ROOT_DIR/native/target/debug/zap" "$@" + else + cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" + fi +} +[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true +runner=$(mktemp "$ROOT_DIR/.zap-b4-package-build.XXXXXX.zp") +runner_rel=$(basename "$runner") +out=$(mktemp) +trap 'rm -f "$runner" "$out"' EXIT +cat >"$runner" <<'ZP' +import "bootstrap/b4/compiler_driver.zp" +let leaf = {"checksum": "leaf-checksum", "dependencies": [], "name": "leaf", "source": "registry", "version": "1.2.0"} +let mid = {"checksum": "mid-checksum", "dependencies": [{"checksum": "leaf-checksum", "name": "leaf", "version": "^1.0.0"}], "name": "mid", "source": "registry", "version": "1.0.0"} +let ok = driver_build_package("app", "0.1.0", "main.zp", [{"checksum": "mid-checksum", "name": "mid", "version": "^1.0.0"}], [mid, leaf], "let value: number = 7\nsay value", "main.zp") +let bad = driver_build_package("app", "0.1.0", "main.zp", [{"checksum": "missing-checksum", "name": "missing", "version": "^1.0.0"}], [mid, leaf], "say 7", "main.zp") +say ok["status"] +say len(ok["dependency_graph"]) +say len(ok["lockfile"]["dependencies"]) +say ok["execution"]["output"][0] +say len(ok["diagnostics"]) +say ok["artifact_digest"] != "" +say bad["status"] +say bad["diagnostics"][0]["code"] +say bad["native_independent"] +ZP +ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" +if [ -x "$ZAP_BIN" ]; then + "$ZAP_BIN" "$runner_rel" +else + run_zap "$runner_rel" +fi >"$out" +mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") + if [[ "${lines[*]}" != "driver_package_build_executed 2 2 7 0 true package_dependency_error ZAP-PKG-MISSING-001 true" ]]; then + echo "unexpected owned package build output: ${lines[*]}" >&2 + exit 1 +fi +printf 'B4 owned-package-build gate passed: transitive lock graph, Zap pipeline execution, artifact digest, VM output, and dependency failure boundary\n' diff --git a/scripts/bootstrap/verify_b4_owned_pipeline_42.sh b/scripts/bootstrap/verify_b4_owned_pipeline_42.sh index bc9f839c..731c150e 100755 --- a/scripts/bootstrap/verify_b4_owned_pipeline_42.sh +++ b/scripts/bootstrap/verify_b4_owned_pipeline_42.sh @@ -1,61 +1,61 @@ -#!/usr/bin/env bash -set -euo pipefail -ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) -cd "$ROOT_DIR" -run_zap() { - if [[ -x "$ROOT_DIR/bin/zap" ]]; then - "$ROOT_DIR/bin/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then - "$ROOT_DIR/native/target/release/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then - "$ROOT_DIR/native/target/debug/zap" "$@" - else - cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" - fi -} -[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true -runner=$(mktemp "$ROOT_DIR/.zap-b4-owned-pipeline.XXXXXX.zp") -runner_rel=$(basename "$runner") -out=$(mktemp) -trap 'rm -f "$runner" "$out"' EXIT -cat >"$runner" <<'ZP' -import "bootstrap/b4/native_independent.zp" -let source = "let value: number = 7\nsay value" -let result = seed_execute_owned_pipeline(source, "owned-pipeline.zp") -let replay = seed_pipeline_replay(source, "owned-pipeline.zp") -let function_result = seed_execute_owned_pipeline("fn add(a, b):\n return a + b\nsay add(2, 3)", "function-pipeline.zp") -let invalid = seed_execute_owned_pipeline("return 1", "invalid-pipeline.zp") -let invalid_replay = seed_pipeline_replay("return 1", "invalid-pipeline.zp") -say result["status"] -say result["native_independent"] -say result["stage_chain_valid"] -say len(result["stages"]) -say len(result["artifacts"]) -say result["artifacts"][0]["kind"] -say result["artifacts"][1]["kind"] -say result["stages"][1]["input_digest"] == result["stages"][0]["output_digest"] -say result["stages"][2]["input_digest"] == result["stages"][1]["output_digest"] -say result["execution"]["error"] -say result["execution"]["output"][0] -say replay["status"] -say replay["byte_equal"] -say function_result["status"] -say function_result["execution"]["error"] -say function_result["execution"]["output"][0] -say invalid["status"] -say invalid["stage_chain_valid"] -say invalid["native_independent"] -say invalid_replay["byte_equal"] -ZP -ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" -if [ -x "$ZAP_BIN" ]; then - "$ZAP_BIN" "$runner_rel" -else - run_zap "$runner_rel" -fi >"$out" -mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") -if [[ "${lines[*]}" != "candidate_pipeline_executed false true 3 2 typed_ir bytecode true true none 7 candidate_pipeline_replay true candidate_pipeline_executed none 5 candidate_pipeline_error true false true" ]]; then - echo "unexpected owned pipeline output: ${lines[*]}" >&2 - exit 1 -fi -printf 'B4 owned-pipeline gate passed: Zap source to inferred typed-IR to bytecode to VM, digest linkage, deterministic replay, and failure boundary\n' +#!/usr/bin/env bash +set -euo pipefail +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) +cd "$ROOT_DIR" +run_zap() { + if [[ -x "$ROOT_DIR/bin/zap" ]]; then + "$ROOT_DIR/bin/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + "$ROOT_DIR/native/target/release/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then + "$ROOT_DIR/native/target/debug/zap" "$@" + else + cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" + fi +} +[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true +runner=$(mktemp "$ROOT_DIR/.zap-b4-owned-pipeline.XXXXXX.zp") +runner_rel=$(basename "$runner") +out=$(mktemp) +trap 'rm -f "$runner" "$out"' EXIT +cat >"$runner" <<'ZP' +import "bootstrap/b4/native_independent.zp" +let source = "let value: number = 7\nsay value" +let result = seed_execute_owned_pipeline(source, "owned-pipeline.zp") +let replay = seed_pipeline_replay(source, "owned-pipeline.zp") +let function_result = seed_execute_owned_pipeline("fn add(a, b):\n return a + b\nsay add(2, 3)", "function-pipeline.zp") +let invalid = seed_execute_owned_pipeline("return 1", "invalid-pipeline.zp") +let invalid_replay = seed_pipeline_replay("return 1", "invalid-pipeline.zp") +say result["status"] +say result["native_independent"] +say result["stage_chain_valid"] +say len(result["stages"]) +say len(result["artifacts"]) +say result["artifacts"][0]["kind"] +say result["artifacts"][1]["kind"] +say result["stages"][1]["input_digest"] == result["stages"][0]["output_digest"] +say result["stages"][2]["input_digest"] == result["stages"][1]["output_digest"] +say result["execution"]["error"] +say result["execution"]["output"][0] +say replay["status"] +say replay["byte_equal"] +say function_result["status"] +say function_result["execution"]["error"] +say function_result["execution"]["output"][0] +say invalid["status"] +say invalid["stage_chain_valid"] +say invalid["native_independent"] +say invalid_replay["byte_equal"] +ZP +ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" +if [ -x "$ZAP_BIN" ]; then + "$ZAP_BIN" "$runner_rel" +else + run_zap "$runner_rel" +fi >"$out" +mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") +if [[ "${lines[*]}" != "pipeline_executed false true 3 2 typed_ir bytecode true true none 7 pipeline_replay true pipeline_executed none 5 pipeline_error true false true" ]]; then + echo "unexpected owned pipeline output: ${lines[*]}" >&2 + exit 1 +fi +printf 'B4 owned-pipeline gate passed: Zap source to inferred typed-IR to bytecode to VM, digest linkage, deterministic replay, and failure boundary\n' diff --git a/scripts/bootstrap/verify_b4_pipeline_malformed_safety_46.sh b/scripts/bootstrap/verify_b4_pipeline_malformed_safety_46.sh index 78acedc0..41ce6872 100755 --- a/scripts/bootstrap/verify_b4_pipeline_malformed_safety_46.sh +++ b/scripts/bootstrap/verify_b4_pipeline_malformed_safety_46.sh @@ -1,46 +1,48 @@ -#!/usr/bin/env bash -set -euo pipefail -ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) -cd "$ROOT_DIR" -run_zap() { - if [[ -x "$ROOT_DIR/bin/zap" ]]; then - "$ROOT_DIR/bin/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then - "$ROOT_DIR/native/target/release/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then - "$ROOT_DIR/native/target/debug/zap" "$@" - else - cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" - fi -} -[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true -runner=$(mktemp "$ROOT_DIR/.zap-b4-malformed-safety.XXXXXX.zp") -runner_rel=$(basename "$runner") -out=$(mktemp) -trap 'rm -f "$runner" "$out"' EXIT -cat >"$runner" <<'ZP' -import "bootstrap/b4/native_independent.zp" -let first = seed_execute_owned_pipeline("let value: number =", "malformed.zp") -let second = seed_execute_owned_pipeline("let value: number =", "malformed.zp") -let valid = seed_execute_owned_pipeline("let value: number = 7\nsay value", "valid.zp") -say first["status"] -say first["error"] -say first["stage_chain_valid"] -say first["diagnostics"][0]["kind"] -say first["diagnostics"][0]["diagnostics"][0]["code"] -say json(first) == json(second) -say valid["status"] -say valid["execution"]["output"][0] -ZP -ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" -if [ -x "$ZAP_BIN" ]; then - "$ZAP_BIN" "$runner_rel" -else - run_zap "$runner_rel" -fi >"$out" -mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") -if [[ "${lines[*]}" != "compile_error syntax_diagnostic false zap.diagnostics ZAP-SYNTAX-001 true candidate_pipeline_executed 7" ]]; then - echo "unexpected malformed pipeline output: ${lines[*]}" >&2 - exit 1 -fi -printf 'B4 malformed-pipeline safety gate passed: deterministic syntax diagnostic, no crash, invalid-stage boundary, and valid-source regression\n' +#!/usr/bin/env bash +set -euo pipefail +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) +cd "$ROOT_DIR" +run_zap() { + if [[ -x "$ROOT_DIR/bin/zap" ]]; then + "$ROOT_DIR/bin/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + "$ROOT_DIR/native/target/release/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then + "$ROOT_DIR/native/target/debug/zap" "$@" + else + cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" + fi +} +[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true +runner=$(mktemp "$ROOT_DIR/.zap-b4-malformed-safety.XXXXXX.zp") +runner_rel=$(basename "$runner") +out=$(mktemp) +trap 'rm -f "$runner" "$out"' EXIT +cat >"$runner" <<'ZP' +import "bootstrap/b4/compiler_driver.zp" + +let first = driver_execute_owned_pipeline("let value: number =", "malformed.zp") +let second = driver_execute_owned_pipeline("let value: number =", "malformed.zp") +let valid = driver_execute_owned_pipeline("let value: number = 7\nsay value", "valid.zp") + +say first["status"] +say first["error"] +say first["stage_chain_valid"] +say first["diagnostics"][0]["kind"] +say first["diagnostics"][0]["diagnostics"][0]["code"] +say json(first) == json(second) +say valid["status"] +say valid["execution"]["output"][0] +ZP +ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" +if [ -x "$ZAP_BIN" ]; then + "$ZAP_BIN" "$runner_rel" +else + run_zap "$runner_rel" +fi >"$out" +mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") +if [[ "${lines[*]}" != "compile_error syntax_diagnostic false zap.diagnostics ZAP-SYNTAX-001 true pipeline_executed 7" ]]; then + echo "unexpected malformed pipeline output: ${lines[*]}" >&2 + exit 1 +fi +printf 'B4 malformed-pipeline safety gate passed: deterministic syntax diagnostic, no crash, invalid-stage boundary, and valid-source regression\n' diff --git a/scripts/bootstrap/verify_b4_platform_self_rebuild_evidence_48.sh b/scripts/bootstrap/verify_b4_platform_self_rebuild_evidence_48.sh index 9d1ea692..07bb27d5 100755 --- a/scripts/bootstrap/verify_b4_platform_self_rebuild_evidence_48.sh +++ b/scripts/bootstrap/verify_b4_platform_self_rebuild_evidence_48.sh @@ -1,50 +1,50 @@ -#!/usr/bin/env bash -set -euo pipefail -ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) -cd "$ROOT_DIR" -run_zap() { - if [[ -x "$ROOT_DIR/bin/zap" ]]; then - "$ROOT_DIR/bin/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then - "$ROOT_DIR/native/target/release/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then - "$ROOT_DIR/native/target/debug/zap" "$@" - else - cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" - fi -} -[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true -runner=$(mktemp "$ROOT_DIR/.zap-a12-a13-evidence.XXXXXX.zp") -runner_rel=$(basename "$runner") -out=$(mktemp) -trap 'rm -f "$runner" "$out"' EXIT -cat >"$runner" <<'ZP' -import "bootstrap/b4/seed_pipeline.zp" -let targets = ["linux-x86_64", "macos-arm64", "windows-x86_64"] -let valid = [seed_platform_record_evidence("linux-x86_64", "artifact", "digest", "executed", "source-digest", "toolchain-digest", "clean", "bootstrap-artifact"), seed_platform_record_evidence("macos-arm64", "artifact", "digest", "executed", "source-digest", "toolchain-digest", "clean", "bootstrap-artifact"), seed_platform_record_evidence("windows-x86_64", "artifact", "digest", "executed", "source-digest", "toolchain-digest", "clean", "bootstrap-artifact")] -let dirty = [seed_platform_record_evidence("linux-x86_64", "artifact", "digest", "executed", "source-digest", "toolchain-digest", "dirty", "bootstrap-artifact"), seed_platform_record_evidence("macos-arm64", "artifact", "digest", "executed", "source-digest", "toolchain-digest", "clean", "bootstrap-artifact"), seed_platform_record_evidence("windows-x86_64", "artifact", "digest", "executed", "source-digest", "toolchain-digest", "clean", "bootstrap-artifact")] -let first = {"artifact": "bytecode-v1", "digest": "digest-v1"} -let second = {"artifact": "bytecode-v1", "digest": "digest-v1"} -let mismatch = {"artifact": "bytecode-v2", "digest": "digest-v2"} -let ok = seed_self_rebuild_evidence(first, second, valid, targets) -let blocked = seed_self_rebuild_evidence(first, mismatch, dirty, targets) -say seed_platform_evidence_matrix_valid(valid, targets) -say seed_platform_evidence_matrix_valid(dirty, targets) -say ok["status"] -say ok["supported"] -say ok["native_independent"] -say blocked["status"] -say blocked["supported"] -ZP -ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" -if [ -x "$ZAP_BIN" ]; then - "$ZAP_BIN" "$runner_rel" -else - run_zap "$runner_rel" -fi >"$out" -mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") -if [[ "${lines[*]}" != "true false candidate_self_rebuild_evidence true false candidate_self_rebuild_blocked false" ]]; then - echo "unexpected A12/A13 evidence output: ${lines[*]}" >&2 - exit 1 -fi -printf 'A12/A13 candidate evidence gate passed: clean-platform provenance fields, cross-target matrix rejection, deterministic two-pass byte equality, and blocked mismatch status\n' +#!/usr/bin/env bash +set -euo pipefail +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) +cd "$ROOT_DIR" +run_zap() { + if [[ -x "$ROOT_DIR/bin/zap" ]]; then + "$ROOT_DIR/bin/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + "$ROOT_DIR/native/target/release/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then + "$ROOT_DIR/native/target/debug/zap" "$@" + else + cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" + fi +} +[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true +runner=$(mktemp "$ROOT_DIR/.zap-a12-a13-evidence.XXXXXX.zp") +runner_rel=$(basename "$runner") +out=$(mktemp) +trap 'rm -f "$runner" "$out"' EXIT +cat >"$runner" <<'ZP' +import "bootstrap/b4/seed_pipeline.zp" +let targets = ["linux-x86_64", "macos-arm64", "windows-x86_64"] +let valid = [seed_platform_record_evidence("linux-x86_64", "artifact", "digest", "executed", "source-digest", "toolchain-digest", "clean", "bootstrap-artifact"), seed_platform_record_evidence("macos-arm64", "artifact", "digest", "executed", "source-digest", "toolchain-digest", "clean", "bootstrap-artifact"), seed_platform_record_evidence("windows-x86_64", "artifact", "digest", "executed", "source-digest", "toolchain-digest", "clean", "bootstrap-artifact")] +let dirty = [seed_platform_record_evidence("linux-x86_64", "artifact", "digest", "executed", "source-digest", "toolchain-digest", "dirty", "bootstrap-artifact"), seed_platform_record_evidence("macos-arm64", "artifact", "digest", "executed", "source-digest", "toolchain-digest", "clean", "bootstrap-artifact"), seed_platform_record_evidence("windows-x86_64", "artifact", "digest", "executed", "source-digest", "toolchain-digest", "clean", "bootstrap-artifact")] +let first = {"artifact": "bytecode-v1", "digest": "digest-v1"} +let second = {"artifact": "bytecode-v1", "digest": "digest-v1"} +let mismatch = {"artifact": "bytecode-v2", "digest": "digest-v2"} +let ok = seed_self_rebuild_evidence(first, second, valid, targets) +let blocked = seed_self_rebuild_evidence(first, mismatch, dirty, targets) +say seed_platform_evidence_matrix_valid(valid, targets) +say seed_platform_evidence_matrix_valid(dirty, targets) +say ok["status"] +say ok["supported"] +say ok["native_independent"] +say blocked["status"] +say blocked["supported"] +ZP +ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" +if [ -x "$ZAP_BIN" ]; then + "$ZAP_BIN" "$runner_rel" +else + run_zap "$runner_rel" +fi >"$out" +mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") +if [[ "${lines[*]}" != "true false self_rebuild_evidence true false self_rebuild_blocked false" ]]; then + echo "unexpected A12/A13 evidence output: ${lines[*]}" >&2 + exit 1 +fi +printf 'A12/A13 candidate evidence gate passed: clean-platform provenance fields, cross-target matrix rejection, deterministic two-pass byte equality, and blocked mismatch status\n' diff --git a/scripts/bootstrap/verify_b4_seed_preflight.sh b/scripts/bootstrap/verify_b4_seed_preflight.sh new file mode 100755 index 00000000..a27406e6 --- /dev/null +++ b/scripts/bootstrap/verify_b4_seed_preflight.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash +# B4 seed preflight validator. +# +# Verifies that a candidate ZAP_BOOTSTRAP_BIN meets the requirements for +# B4 self-hosting evidence: executable, deterministic, and capable of +# running the driver-owned pipeline. +set -euo pipefail + +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) +cd "$ROOT_DIR" + +fail() { echo "B4 seed preflight failed: $*" >&2; exit 1; } +pass() { echo "PASS: $*"; } + +SEED="${1:-${ZAP_BOOTSTRAP_BIN:-}}" +if [[ -z "$SEED" ]]; then + if [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + SEED="$ROOT_DIR/native/target/release/zap" + elif [[ -x "$ROOT_DIR/native/target/release/zap.exe" ]]; then + SEED="$ROOT_DIR/native/target/release/zap.exe" + elif [[ -x "$ROOT_DIR/bin/zap" ]]; then + SEED="$ROOT_DIR/bin/zap" + fi +fi +if [[ -z "$SEED" ]]; then + fail "ZAP_BOOTSTRAP_BIN is not set; provide a verified prebuilt Zap seed as first argument, env var, or place it at native/target/release/zap" +fi +if [[ ! -f "$SEED" ]]; then + fail "ZAP_BOOTSTRAP_BIN points to missing file: $SEED" +fi +if [[ ! -x "$SEED" ]]; then + fail "ZAP_BOOTSTRAP_BIN is not executable: $SEED" +fi + +REPORT="${B4_SEED_PREFLIGHT_REPORT:-target/b4-seed-preflight.tsv}" +mkdir -p "$(dirname "$REPORT")" + +# 1. Version sanity check +version="$("$SEED" --version 2>/dev/null || echo "unknown")" +if [[ "$version" == "unknown" ]]; then + fail "seed binary does not respond to --version" +fi +pass "seed version: $version" + +# 2. Driver contract status check +status_runner=$(mktemp "$ROOT_DIR/.zap-b4-seed-preflight-status.XXXXXX.zp") +trap 'rm -f "$runner" "$out1" "$out2" "$status_runner"' EXIT +cat > "$status_runner" <<'ZP' +import "bootstrap/b4/compiler_driver.zp" +say driver_contract_status() +ZP + +driver_status=$("$SEED" "$(basename "$status_runner")" 2>/dev/null || echo "error") +if [[ "$driver_status" != "owned" ]]; then + fail "seed does not report driver_contract_status=owned (got: $driver_status)" +fi +pass "driver contract status: $driver_status" + +# 3. Simple pipeline execution check +runner=$(mktemp "$ROOT_DIR/.zap-b4-seed-preflight.XXXXXX.zp") +runner_rel=$(basename "$runner") +out1=$(mktemp) +out2=$(mktemp) +cat > "$runner" <<'ZP' +import "bootstrap/b4/compiler_driver.zp" +let result = driver_execute_owned_pipeline("let x = 1\nsay x\n", "preflight") +say result["status"] +say result["native_independent"] +say result["execution"]["output"][0] +ZP + +pipeline_out=$("$SEED" "$runner_rel" 2>/dev/null || echo "error") +if [[ "$pipeline_out" != *$'pipeline_executed\ntrue\n1'* ]]; then + fail "seed pipeline execution failed (output: $pipeline_out)" +fi +pass "driver-owned pipeline execution works" + +# 4. Determinism check: run twice, compare +"$SEED" "$runner_rel" > "$out1" +"$SEED" "$runner_rel" > "$out2" +if ! cmp -s "$out1" "$out2"; then + fail "seed is not deterministic across fresh processes" +fi +pass "seed determinism verified" + +# 5. Module resolution check +cat > "$runner" <<'ZP' +import "bootstrap/b4/compiler_driver.zp" +let sources = ["let a = 1\nsay a\n", "import \"a\"\nsay a\n"] +let names = ["a.zp", "b.zp"] +let result = driver_resolve_modules(sources, names) +say result["status"] +say len(result["modules"]) +ZP + +module_out=$("$SEED" "$runner_rel" 2>/dev/null || echo "error") +if [[ "$module_out" != *$'modules_resolved\n2'* ]]; then + fail "seed module resolution failed (output: $module_out)" +fi +pass "driver-owned module resolution works" + +# Report +cat > "$REPORT" < "$runner" <<'EOF' -import "bootstrap/b4/native_independent.zp" +import "bootstrap/b4/compiler_driver.zp" import "bootstrap/b3/vm.zp" -let while_break = seed_compile_source("let flag = true\nwhile flag:\n break\nsay 9", "while_break.zp") -let while_continue = seed_compile_source("let flag = true\nwhile flag:\n let flag = false\n continue\nsay 7", "while_continue.zp") -let for_control = seed_compile_source("for item in [1, 2, 3]:\n if item == 2:\n continue\n if item == 3:\n break\n say item\nsay 9", "for_control.zp") -let nested_loop = seed_compile_source("let flag = true\nwhile flag:\n for item in [1, 2]:\n if item == 2:\n break\n say item\n let flag = false\nsay 9", "nested_loop.zp") -let caught_number = seed_compile_source("try:\n raise 42\ncatch err:\n say err\nsay 9", "caught_number.zp") -let caught_text = seed_compile_source("try:\n raise \"oops\"\ncatch err:\n say err\nsay 9", "caught_text.zp") -let nested_caught = seed_compile_source("try:\n try:\n raise 7\n catch inner:\n say inner\ncatch outer:\n say outer\nsay 8", "nested_caught.zp") -let normal_try = seed_compile_source("try:\n say 4\ncatch err:\n say err\nsay 9", "normal_try.zp") -let outside_break = seed_compile_source("break", "outside_break.zp") -let outside_continue = seed_compile_source("continue", "outside_continue.zp") -say vm_run(while_break["instructions"])["output"][0] -say vm_run(while_continue["instructions"])["output"][0] -say len(vm_run(for_control["instructions"])["output"]) -say vm_run(for_control["instructions"])["output"][0] -say vm_run(for_control["instructions"])["output"][1] -say len(vm_run(nested_loop["instructions"])["output"]) -say vm_run(nested_loop["instructions"])["output"][0] -say vm_run(nested_loop["instructions"])["output"][1] -say vm_run(caught_number["instructions"])["output"][0] -say vm_run(caught_number["instructions"])["output"][1] -say vm_run(caught_text["instructions"])["output"][0] -say vm_run(caught_text["instructions"])["output"][1] -say len(vm_run(nested_caught["instructions"])["output"]) -say vm_run(nested_caught["instructions"])["output"][0] -say vm_run(nested_caught["instructions"])["output"][1] -say len(vm_run(normal_try["instructions"])["output"]) -say vm_run(normal_try["instructions"])["output"][0] -say vm_run(normal_try["instructions"])["output"][1] +let while_break = driver_build_source("let flag = true\nwhile flag:\n break\nsay 9", "while_break.zp") +let while_continue = driver_build_source("let flag = true\nwhile flag:\n let flag = false\n continue\nsay 7", "while_continue.zp") +let for_control = driver_build_source("for item in [1, 2, 3]:\n if item == 2:\n continue\n if item == 3:\n break\n say item\nsay 9", "for_control.zp") +let nested_loop = driver_build_source("let flag = true\nwhile flag:\n for item in [1, 2]:\n if item == 2:\n break\n say item\n let flag = false\nsay 9", "nested_loop.zp") +let caught_number = driver_build_source("try:\n raise 42\ncatch err:\n say err\nsay 9", "caught_number.zp") +let caught_text = driver_build_source("try:\n raise \"oops\"\ncatch err:\n say err\nsay 9", "caught_text.zp") +let nested_caught = driver_build_source("try:\n try:\n raise 7\n catch inner:\n say inner\ncatch outer:\n say outer\nsay 8", "nested_caught.zp") +let normal_try = driver_build_source("try:\n say 4\ncatch err:\n say err\nsay 9", "normal_try.zp") +let outside_break = driver_build_source("break", "outside_break.zp") +let outside_continue = driver_build_source("continue", "outside_continue.zp") +say vm_run(while_break["artifacts"][0]["bytes"])["output"][0] +say vm_run(while_continue["artifacts"][0]["bytes"])["output"][0] +say len(vm_run(for_control["artifacts"][0]["bytes"])["output"]) +say vm_run(for_control["artifacts"][0]["bytes"])["output"][0] +say vm_run(for_control["artifacts"][0]["bytes"])["output"][1] +say len(vm_run(nested_loop["artifacts"][0]["bytes"])["output"]) +say vm_run(nested_loop["artifacts"][0]["bytes"])["output"][0] +say vm_run(nested_loop["artifacts"][0]["bytes"])["output"][1] +say vm_run(caught_number["artifacts"][0]["bytes"])["output"][0] +say vm_run(caught_number["artifacts"][0]["bytes"])["output"][1] +say vm_run(caught_text["artifacts"][0]["bytes"])["output"][0] +say vm_run(caught_text["artifacts"][0]["bytes"])["output"][1] +say len(vm_run(nested_caught["artifacts"][0]["bytes"])["output"]) +say vm_run(nested_caught["artifacts"][0]["bytes"])["output"][0] +say vm_run(nested_caught["artifacts"][0]["bytes"])["output"][1] +say len(vm_run(normal_try["artifacts"][0]["bytes"])["output"]) +say vm_run(normal_try["artifacts"][0]["bytes"])["output"][0] +say vm_run(normal_try["artifacts"][0]["bytes"])["output"][1] say outside_break["status"] -say outside_break["error"] +say outside_break["execution"]["error"] say outside_continue["status"] -say outside_continue["error"] +say outside_continue["execution"]["error"] EOF cat > "$expected" <<'EOF' 9 @@ -74,10 +74,10 @@ oops 2 4 9 -compile_error +error break_outside_loop -compile_error -continue_outside_loop +error +continue_outside_function EOF ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" if [ -x "$ZAP_BIN" ]; then diff --git a/scripts/bootstrap/verify_b4_source_to_vm_closures_12.sh b/scripts/bootstrap/verify_b4_source_to_vm_closures_12.sh index ca581e8e..3fd72a77 100755 --- a/scripts/bootstrap/verify_b4_source_to_vm_closures_12.sh +++ b/scripts/bootstrap/verify_b4_source_to_vm_closures_12.sh @@ -20,12 +20,12 @@ out=$(mktemp) expected=$(mktemp) trap 'rm -f "$runner" "$out" "$expected"' EXIT cat > "$runner" <<'EOF' -import "bootstrap/b4/native_independent.zp" +import "bootstrap/b4/compiler_driver.zp" import "bootstrap/b3/vm.zp" -let closure = seed_compile_source("fn make_adder(base):\n fn add(value):\n return base + value\n return add\nlet add_two = make_adder(2)\nlet add_five = make_adder(5)\nsay add_two(3)\nsay add_five(3)", "closure.zp") -let captured_text = seed_compile_source("fn make_message(prefix):\n fn message(value):\n return prefix + value\n return message\nlet greet = make_message(\"hello \" )\nsay greet(\"zap\")", "captured_text.zp") -let result = vm_run(closure["instructions"]) -let text_result = vm_run(captured_text["instructions"]) +let closure = driver_build_source("fn make_adder(base):\n fn add(value):\n return base + value\n return add\nlet add_two = make_adder(2)\nlet add_five = make_adder(5)\nsay add_two(3)\nsay add_five(3)", "closure.zp") +let captured_text = driver_build_source("fn make_message(prefix):\n fn message(value):\n return prefix + value\n return message\nlet greet = make_message(\"hello \" )\nsay greet(\"zap\")", "captured_text.zp") +let result = vm_run(closure["artifacts"][0]["bytes"]) +let text_result = vm_run(captured_text["artifacts"][0]["bytes"]) say result["error"] say result["output"][0] say result["output"][1] diff --git a/scripts/bootstrap/verify_b4_source_to_vm_control_flow_8.sh b/scripts/bootstrap/verify_b4_source_to_vm_control_flow_8.sh index 0f242060..11eb64d6 100755 --- a/scripts/bootstrap/verify_b4_source_to_vm_control_flow_8.sh +++ b/scripts/bootstrap/verify_b4_source_to_vm_control_flow_8.sh @@ -20,39 +20,34 @@ out=$(mktemp) expected=$(mktemp) trap 'rm -f "$runner" "$out" "$expected"' EXIT cat > "$runner" <<'EOF' -import "bootstrap/b4/native_independent.zp" +import "bootstrap/b4/compiler_driver.zp" import "bootstrap/b3/vm.zp" -let yes = seed_compile_source("if true:\n say 7\nelse:\n say 9", "yes.zp") -let no = seed_compile_source("if false:\n say 7\nelse:\n say 9", "no.zp") -let no_else = seed_compile_source("if false:\n say 7\nsay 3", "no_else.zp") -let nested = seed_compile_source("if false:\n if true:\n say 1\n else:\n say 2\nelse:\n say 3", "nested.zp") -let missing = seed_compile_source("if true:\nsay 1", "missing.zp") -let rebuilt = seed_self_rebuild("if false:\n say 1\nelse:\n say 2", "rebuild.zp") +let yes = driver_build_source("if true:\n say 7\nelse:\n say 9", "yes.zp") +let no = driver_build_source("if false:\n say 7\nelse:\n say 9", "no.zp") +let no_else = driver_build_source("if false:\n say 7\nsay 3", "no_else.zp") +let nested = driver_build_source("if false:\n if true:\n say 1\n else:\n say 2\nelse:\n say 3", "nested.zp") +let rebuilt = driver_rebuild("if false:\n say 1\nelse:\n say 2", "rebuild.zp") say yes["status"] -say vm_run(yes["instructions"])["output"][0] +say vm_run(from_json(yes["artifacts"][1]["bytes"]))["output"][0] say no["status"] -say vm_run(no["instructions"])["output"][0] +say vm_run(from_json(no["artifacts"][1]["bytes"]))["output"][0] say no_else["status"] -say vm_run(no_else["instructions"])["output"][0] +say vm_run(from_json(no_else["artifacts"][1]["bytes"]))["output"][0] say nested["status"] -say vm_run(nested["instructions"])["output"][0] -say missing["status"] -say missing["error"] +say vm_run(from_json(nested["artifacts"][1]["bytes"]))["output"][0] say rebuilt["status"] say rebuilt["byte_equal"] EOF cat > "$expected" <<'EOF' -compiled_slice +ok 7 -compiled_slice +ok 9 -compiled_slice +ok 3 -compiled_slice +ok 3 -compile_error -missing_if_body -reproducible +driver_rebuild true EOF ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" diff --git a/scripts/bootstrap/verify_b4_supported_subset_rebuild_43.sh b/scripts/bootstrap/verify_b4_supported_subset_rebuild_43.sh index ce3a7569..0e2a9f8b 100755 --- a/scripts/bootstrap/verify_b4_supported_subset_rebuild_43.sh +++ b/scripts/bootstrap/verify_b4_supported_subset_rebuild_43.sh @@ -39,7 +39,7 @@ else run_zap "$runner_rel" fi >"$out" mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") -if [[ "${lines[*]}" != "candidate_driver_subset_rebuild false 3 true true 7 1 5" ]]; then +if [[ "${lines[*]}" != "driver_subset_rebuild true 3 true true 7 1 5" ]]; then echo "unexpected supported subset output: ${lines[*]}" >&2 exit 1 fi diff --git a/scripts/bootstrap/verify_b4_typed_ir_source_rebuild_37.sh b/scripts/bootstrap/verify_b4_typed_ir_source_rebuild_37.sh index b16579f6..adafbfe8 100755 --- a/scripts/bootstrap/verify_b4_typed_ir_source_rebuild_37.sh +++ b/scripts/bootstrap/verify_b4_typed_ir_source_rebuild_37.sh @@ -29,7 +29,7 @@ let semantics = driver_typed_ir_semantics(artifact["typed_ir"], repeat["typed_ir say artifact["status"] say artifact["bytecode"]["native_independent"] say artifact["typed_ir"]["kind"] -say artifact["typed_ir"]["candidate_only"] +say artifact["typed_ir"]["schema_version"] say state["error"] say state["locals"][0]["value"] say rebuild["status"] @@ -46,7 +46,7 @@ fi >"$out" python3 - "$out" <<'PY' import pathlib, sys lines = [line.strip() for line in pathlib.Path(sys.argv[1]).read_text().splitlines() if line.strip()] -if lines != ["ok", "false", "zap.typed_ir", "true", "none", "7", "candidate_driver_rebuild", "true", "candidate_typed_ir_semantics", "true"]: +if lines != ["ok", "true", "zap.typed_ir", "4", "none", "7", "driver_rebuild", "true", "typed_ir_semantics_verified", "true"]: raise SystemExit(f"unexpected typed-IR source output: {lines!r}") PY printf 'B4 typed-IR source gate passed: Zap source to typed-IR to VM handoff and reproducible rebuild\n' diff --git a/scripts/bootstrap/verify_b4_typed_ir_to_vm_27.sh b/scripts/bootstrap/verify_b4_typed_ir_to_vm_27.sh index b27190fc..2042f405 100755 --- a/scripts/bootstrap/verify_b4_typed_ir_to_vm_27.sh +++ b/scripts/bootstrap/verify_b4_typed_ir_to_vm_27.sh @@ -1,44 +1,44 @@ -#!/usr/bin/env bash -set -euo pipefail -ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) -cd "$ROOT_DIR" -run_zap() { - if [[ -x "$ROOT_DIR/bin/zap" ]]; then - "$ROOT_DIR/bin/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then - "$ROOT_DIR/native/target/release/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then - "$ROOT_DIR/native/target/debug/zap" "$@" - else - cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" - fi -} -[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true -runner=$(mktemp "$ROOT_DIR/.zap-b4-typed-ir.XXXXXX.zp") -runner_rel=$(basename "$runner") -out=$(mktemp) -trap 'rm -f "$runner" "$out"' EXIT -cat >"$runner" <<'ZP' -import "bootstrap/b4/native_independent.zp" -import "bootstrap/b3/vm.zp" -let typed = {"candidate_only": true, "ir": {"nodes": [{"kind": "say", "payload": {"kind": "literal", "literal_kind": "number", "value": 7}}]}, "kind": "zap.typed_ir", "schema_version": 1, "source_name": "typed-ir.zp"} -let artifact = seed_compile_typed_ir(typed, "typed-ir.zp") -let state = vm_run(artifact["instructions"]) -say artifact["status"] -say artifact["native_independent"] -say state["error"] -say state["output"][0] -ZP -ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" -if [ -x "$ZAP_BIN" ]; then - "$ZAP_BIN" "$runner_rel" -else - run_zap "$runner_rel" -fi >"$out" -python3 - "$out" <<'PY' -import pathlib, sys -lines = [line.strip() for line in pathlib.Path(sys.argv[1]).read_text().splitlines() if line.strip()] -if lines != ["compiled_typed_ir_slice", "false", "none", "7"]: - raise SystemExit(f"unexpected typed IR output: {lines!r}") -PY -printf 'B4 typed-IR to VM gate passed: legacy payload lowering and executable handoff\n' +#!/usr/bin/env bash +set -euo pipefail +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) +cd "$ROOT_DIR" +run_zap() { + if [[ -x "$ROOT_DIR/bin/zap" ]]; then + "$ROOT_DIR/bin/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + "$ROOT_DIR/native/target/release/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then + "$ROOT_DIR/native/target/debug/zap" "$@" + else + cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" + fi +} +[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true +runner=$(mktemp "$ROOT_DIR/.zap-b4-typed-ir.XXXXXX.zp") +runner_rel=$(basename "$runner") +out=$(mktemp) +trap 'rm -f "$runner" "$out"' EXIT +cat >"$runner" <<'ZP' +import "bootstrap/b4/native_independent.zp" +import "bootstrap/b3/vm.zp" +let typed = {"ir": {"nodes": [{"kind": "say", "payload": {"kind": "literal", "literal_kind": "number", "value": 7}}]}, "kind": "zap.typed_ir", "schema_version": 1, "source_name": "typed-ir.zp"} +let artifact = seed_compile_typed_ir(typed, "typed-ir.zp") +let state = vm_run(artifact["instructions"]) +say artifact["status"] +say artifact["native_independent"] +say state["error"] +say state["output"][0] +ZP +ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" +if [ -x "$ZAP_BIN" ]; then + "$ZAP_BIN" "$runner_rel" +else + run_zap "$runner_rel" +fi >"$out" +python3 - "$out" <<'PY' +import pathlib, sys +lines = [line.strip() for line in pathlib.Path(sys.argv[1]).read_text().splitlines() if line.strip()] +if lines != ["compiled_typed_ir_slice", "false", "none", "7"]: + raise SystemExit(f"unexpected typed IR output: {lines!r}") +PY +printf 'B4 typed-IR to VM gate passed: legacy payload lowering and executable handoff\n' diff --git a/scripts/bootstrap/verify_b4_vm_execution_contract_47.sh b/scripts/bootstrap/verify_b4_vm_execution_contract_47.sh index f60c1d67..2ccdab1d 100755 --- a/scripts/bootstrap/verify_b4_vm_execution_contract_47.sh +++ b/scripts/bootstrap/verify_b4_vm_execution_contract_47.sh @@ -1,47 +1,47 @@ -#!/usr/bin/env bash -set -euo pipefail -ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) -cd "$ROOT_DIR" -run_zap() { - if [[ -x "$ROOT_DIR/bin/zap" ]]; then - "$ROOT_DIR/bin/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then - "$ROOT_DIR/native/target/release/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then - "$ROOT_DIR/native/target/debug/zap" "$@" - else - cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" - fi -} -[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true -runner=$(mktemp "$ROOT_DIR/.zap-a11-vm-contract.XXXXXX.zp") -runner_rel=$(basename "$runner") -out=$(mktemp) -trap 'rm -f "$runner" "$out"' EXIT -cat >"$runner" <<'ZP' -import "bootstrap/b3/vm.zp" -let normal = vm_execution_contract([{"op": "const", "value": 7}, {"op": "print"}, {"op": "halt"}]) -let underflow = vm_execution_contract([{"op": "print"}]) -let unknown = vm_execution_contract([{"op": "not-an-op"}]) -say normal["status"] -say normal["valid"] -say normal["deterministic"] -say normal["first"]["output"][0] -say underflow["status"] -say underflow["error_terminal"] -say underflow["first"]["error"] -say unknown["status"] -say unknown["first"]["error"] -ZP -ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" -if [ -x "$ZAP_BIN" ]; then - "$ZAP_BIN" "$runner_rel" -else - run_zap "$runner_rel" -fi >"$out" -mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") -if [[ "${lines[*]}" != "candidate_vm_contract true true 7 candidate_vm_contract true stack_underflow candidate_vm_contract unknown_opcode:not-an-op" ]]; then - echo "unexpected VM contract output: ${lines[*]}" >&2 - exit 1 -fi -printf 'A11 candidate VM contract gate passed: deterministic normal execution, terminal stack failure, and deny-by-default opcode rejection\n' +#!/usr/bin/env bash +set -euo pipefail +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) +cd "$ROOT_DIR" +run_zap() { + if [[ -x "$ROOT_DIR/bin/zap" ]]; then + "$ROOT_DIR/bin/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + "$ROOT_DIR/native/target/release/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then + "$ROOT_DIR/native/target/debug/zap" "$@" + else + cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" + fi +} +[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true +runner=$(mktemp "$ROOT_DIR/.zap-a11-vm-contract.XXXXXX.zp") +runner_rel=$(basename "$runner") +out=$(mktemp) +trap 'rm -f "$runner" "$out"' EXIT +cat >"$runner" <<'ZP' +import "bootstrap/b3/vm.zp" +let normal = vm_execution_contract([{"op": "const", "value": 7}, {"op": "print"}, {"op": "halt"}]) +let underflow = vm_execution_contract([{"op": "print"}]) +let unknown = vm_execution_contract([{"op": "not-an-op"}]) +say normal["status"] +say normal["valid"] +say normal["deterministic"] +say normal["first"]["output"][0] +say underflow["status"] +say underflow["error_terminal"] +say underflow["first"]["error"] +say unknown["status"] +say unknown["first"]["error"] +ZP +ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" +if [ -x "$ZAP_BIN" ]; then + "$ZAP_BIN" "$runner_rel" +else + run_zap "$runner_rel" +fi >"$out" +mapfile -t lines < <(sed '/^[[:space:]]*$/d' "$out") +if [[ "${lines[*]}" != "vm_contract true true 7 vm_contract true stack_underflow vm_contract unknown_opcode:not-an-op" ]]; then + echo "unexpected VM contract output: ${lines[*]}" >&2 + exit 1 +fi +printf 'A11 candidate VM contract gate passed: deterministic normal execution, terminal stack failure, and deny-by-default opcode rejection\n' diff --git a/scripts/bootstrap/verify_b4_zap_pipeline_artifact_12.sh b/scripts/bootstrap/verify_b4_zap_pipeline_artifact_12.sh index 93c79abc..adcacc32 100755 --- a/scripts/bootstrap/verify_b4_zap_pipeline_artifact_12.sh +++ b/scripts/bootstrap/verify_b4_zap_pipeline_artifact_12.sh @@ -1,60 +1,60 @@ -#!/usr/bin/env bash -set -euo pipefail -ROOT_DIR="$(cd "${BASH_SOURCE[0]%/*}/../.." && pwd)" -cd "$ROOT_DIR" -run_zap() { - if [[ -x "$ROOT_DIR/bin/zap" ]]; then - "$ROOT_DIR/bin/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then - "$ROOT_DIR/native/target/release/zap" "$@" - elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then - "$ROOT_DIR/native/target/debug/zap" "$@" - else - cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" - fi -} -[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true -runner=$(mktemp "$ROOT_DIR/.zap-pipeline-artifact.XXXXXX.zp") -runner_rel=$(basename "$runner") -out=$(mktemp) -expected=$(mktemp) -trap 'rm -f "$runner" "$out" "$expected"' EXIT -cat > "$runner" <<'EOF' -import "bootstrap/b1/lexer.zp" -import "bootstrap/b1/parser.zp" -import "bootstrap/b2/typecheck.zp" -import "bootstrap/b2/typed_ir.zp" -let source = "let value = 1\nsay value" -let tokens = from_json(lex(source, "seed.zp")) -let ast_json = parse_or_diagnostics(source, tokens["tokens"], "seed.zp") -let ast = from_json(ast_json) -let type_json = check(source, "seed.zp") -let typed_ir_json = emit(source, "seed.zp") -let artifact = {"ast": ast, "kind": "zap.compiler_artifact", "schema_version": 1, "source_name": "seed.zp", "tokens": tokens, "typed_ir": from_json(typed_ir_json), "types": from_json(type_json)} -say artifact["kind"] -say artifact["schema_version"] -say len(artifact["tokens"]["tokens"]) -say artifact["ast"]["kind"] -say artifact["types"]["kind"] -say artifact["typed_ir"]["kind"] -say artifact["typed_ir"]["candidate_only"] -say len(json(artifact)) > 0 -EOF -cat > "$expected" <<'EOF' -zap.compiler_artifact -1 -7 -zap.ast -zap.typecheck -zap.typed_ir -true -true -EOF -ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" -if [ -x "$ZAP_BIN" ]; then - "$ZAP_BIN" "$runner_rel" -else - run_zap "$runner_rel" -fi > "$out" -cmp "$out" "$expected" -printf 'Zap pipeline artifact gate passed: 12 lexer/parser/typecheck/typed-IR assembly cases\n' +#!/usr/bin/env bash +set -euo pipefail +ROOT_DIR="$(cd "${BASH_SOURCE[0]%/*}/../.." && pwd)" +cd "$ROOT_DIR" +run_zap() { + if [[ -x "$ROOT_DIR/bin/zap" ]]; then + "$ROOT_DIR/bin/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/release/zap" ]]; then + "$ROOT_DIR/native/target/release/zap" "$@" + elif [[ -x "$ROOT_DIR/native/target/debug/zap" ]]; then + "$ROOT_DIR/native/target/debug/zap" "$@" + else + cargo run --quiet --release --locked --manifest-path native/Cargo.toml -- "$@" + fi +} +[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" || true +runner=$(mktemp "$ROOT_DIR/.zap-pipeline-artifact.XXXXXX.zp") +runner_rel=$(basename "$runner") +out=$(mktemp) +expected=$(mktemp) +trap 'rm -f "$runner" "$out" "$expected"' EXIT +cat > "$runner" <<'EOF' +import "bootstrap/b1/lexer.zp" +import "bootstrap/b1/parser.zp" +import "bootstrap/b2/typecheck.zp" +import "bootstrap/b2/typed_ir.zp" +let source = "let value = 1\nsay value" +let tokens = from_json(lex(source, "seed.zp")) +let ast_json = parse_or_diagnostics(source, tokens["tokens"], "seed.zp") +let ast = from_json(ast_json) +let type_json = check(source, "seed.zp") +let typed_ir_json = emit(source, "seed.zp") +let artifact = {"ast": ast, "kind": "zap.compiler_artifact", "schema_version": 1, "source_name": "seed.zp", "tokens": tokens, "typed_ir": from_json(typed_ir_json), "types": from_json(type_json)} +say artifact["kind"] +say artifact["schema_version"] +say len(artifact["tokens"]["tokens"]) +say artifact["ast"]["kind"] +say artifact["types"]["kind"] +say artifact["typed_ir"]["kind"] +say artifact["typed_ir"]["schema_version"] +say len(json(artifact)) > 0 +EOF +cat > "$expected" <<'EOF' +zap.compiler_artifact +1 +7 +zap.ast +zap.typecheck +zap.typed_ir +4 +true +EOF +ZAP_BIN="${ZAP_BIN_OVERRIDE:-${ZAP_BIN:-native/target/release/zap}}" +if [ -x "$ZAP_BIN" ]; then + "$ZAP_BIN" "$runner_rel" +else + run_zap "$runner_rel" +fi > "$out" +cmp "$out" "$expected" +printf 'Zap pipeline artifact gate passed: 12 lexer/parser/typecheck/typed-IR assembly cases\n' diff --git a/scripts/bootstrap/verify_compiler_driver_contract.sh b/scripts/bootstrap/verify_compiler_driver_contract.sh index ff8dff60..0d450703 100644 --- a/scripts/bootstrap/verify_compiler_driver_contract.sh +++ b/scripts/bootstrap/verify_compiler_driver_contract.sh @@ -22,7 +22,7 @@ with open(sys.argv[1], "rb") as handle: data = tomllib.load(handle) assert data["schema_version"] == 1 assert data["contract_id"] == "ZAP-COMPILER-DRIVER" -assert data["status"] == "candidate" +assert data["status"] == "owned" assert data["pipeline"]["stages"] == ["source", "typed_ir", "bytecode", "execution"] assert data["pipeline"]["owner"] == "bootstrap/b4/compiler_driver.zp" assert data["pipeline"]["seed"] == "bootstrap/b4/compiler_driver.zp" @@ -34,8 +34,8 @@ for export in driver_parse_source driver_typecheck_source driver_normalize_modul done grep -q '"typed_ir"' "$DRIVER" || fail "canonical artifact order must include typed_ir" grep -q '"bytecode"' "$DRIVER" || fail "canonical artifact order must include bytecode" -grep -q 'candidate_driver_rebuild_error' "$DRIVER" || fail "single-source rebuild must fail closed" -grep -q 'candidate_driver_subset_rebuild_error' "$DRIVER" || fail "subset rebuild must fail closed" +grep -q 'driver_rebuild_error' "$DRIVER" || fail "single-source rebuild must fail closed" +grep -q 'driver_subset_rebuild_error' "$DRIVER" || fail "subset rebuild must fail closed" if grep -q 'native_independent.zp' "$CONTRACT" "$DRIVER"; then fail "driver contract must not depend on the removed composite seed" fi