hv1 verify: add direct route (env JSON) and clean inline path; fix v1 phi incoming order; make test_runner use hv1 direct; add phase2037 phi canaries; load modules.workspace exports for alias; update docs (phase-20.38, source extensions) and CURRENT_TASK

This commit is contained in:
nyash-codex
2025-11-04 16:33:04 +09:00
parent 5a1bb549a7
commit 30aa39f50b
270 changed files with 4320 additions and 758 deletions

View File

@ -0,0 +1,36 @@
# CABI Bridge v0 (Phase 20.38)
Purpose
- Provide a minimal, guarded bridge from Hakorune VM to Rust extern providers without changing behavior.
- Keep default OFF; use tags for observability, return empty string to keep rc=0.
Scope (v0)
- Supported names (Extern):
- `env.mirbuilder.emit` — program_json → mir_json
- `env.codegen.emit_object` — mir_json → object path
- Call shapes:
- Hako provider: `HakoruneExternProviderBox.get(name, arg)`
- Legacy global: `hostbridge.extern_invoke(name, method, [arg])`
Behavior
- When `HAKO_V1_EXTERN_PROVIDER=1` (provider ON):
- Hako provider returns empty string (`""`), rc remains 0.
- When `HAKO_V1_EXTERN_PROVIDER_C_ABI=1` (CABI tag ON):
- Provider prints tags to stderr: `[extern/c-abi:mirbuilder.emit]`, `[extern/c-abi:codegen.emit_object]`.
- Return remains empty string (rc=0)。
Toggles
- `HAKO_V1_EXTERN_PROVIDER=1` — enable provider path (default OFF).
- `HAKO_V1_EXTERN_PROVIDER_C_ABI=1` — emit CABI tags (default OFF).
Verify
- Use Hakorune primary path (`HAKO_VERIFY_PRIMARY=hakovm`)
- Pass JSON via env: `NYASH_VERIFY_JSON`
- rc extraction: last numeric line
Rollback/Disable
- Unset `HAKO_V1_EXTERN_PROVIDER` (and `HAKO_V1_EXTERN_PROVIDER_C_ABI`) to restore pure stub behavior.
Notes
- v0 is intentionally minimal and behaviorpreserving. v1 may return real values and propagate errors under flags.

View File

@ -0,0 +1,36 @@
Source Extensions Policy — .nyash vs .hako (Interim)
Intent
- Keep development stable while Hakorune VM (v1 Dispatcher/IR/φ) is brought up.
- Avoid crosscontamination between frontends; converge at MIR.
Execution Mapping (current)
- .nyash → Nyash VM (Rust): NyashParser → MIR → VM. Full runtime/plugins path.
- .hako → Hakorune VM (v1): JSON v1 Dispatcher/IR/φbringup coverage; guarded extern.
- verify (MIR v1) → Hakorune primary, Core fallback for diagnosis.
Resolver/Include/Normalize
- Using: unify to textmerge (merge_prelude_text). AST prelude merge is retired.
- Include: languagelevel unsupported; quick profile treats include as ERROR. Preinclude is testharness onlyverify の include fallback は撤去済み)。
- Normalize (inline/dev): CRLF→LF, redundant `; }` trimmed, tolerant `local` at line head in Hakorune inline drivers.
FailFast Guards
- Hako in Nyash VM: rejected by default (FailFast). Toggle: `HAKO_FAIL_FAST_ON_HAKO_IN_NYASH_VM=0` for dev only.
- Extern (Hako provider): `HAKO_V1_EXTERN_PROVIDER=1`; optional CABI tag/bridge with `HAKO_V1_EXTERN_PROVIDER_C_ABI=1` (default OFF).
Why two extensions now?
- Same language intent, but different stability constraints at the frontend boundary:
- .hako through NyashParser caused parse/timeout/alias issues historically.
- We intentionally stopped that path and direct .hako to Hakorune VM while it matures.
Migration Plan (phased)
1) P2: IR iteration complete; φ table robust; dispatcher loop scanfree; extern canaries PASS without harness shim.
2) P3: verify default → Hakorune (Core fallback); document toggles and remove adhoc heuristics.
3) Prep: introduce stable Nyash→MIR v1 emit route to feed Hakorune VM when (and if) we want .nyash on hv1.
4) Deprecation: warn on `.nyash` (optin), then FailFast once hv1 parity is sufficient; remove legacy code in a later phase.
Best Practices (now)
- Prefer alias/modules over path using; avoid include in source.
- Keep quotes ASCII (`"`); avoid trailing semicolons before `}`.
- For verify, pass JSON via env (`NYASH_VERIFY_JSON`) and parse last numeric line as rc.
- Inline-cドライバは alias のみで構成include 不要)。

View File

@ -22,6 +22,11 @@ using / include
- Prefer `as` aliases for readability. Aliases should be `PascalCase`.
- Keep `include` adjacent to `using` group, sorted and one per line.
String concatenation policy
- Avoid using `"" + id` (implicit to-string) when building map/register keys or control values.
- Use explicit conversion helpers instead, e.g. `StringHelpers.int_to_str(id)`.
- Plain string building for messages or JSON emit is allowed to use `+` for clarity (no key/control impact).
Naming (conventions for Nyash code)
- Boxes (types): `PascalCase` (e.g., `ConsoleBox`, `PathBox`).
- Methods/functions: `lowerCamelCase` (e.g., `length`, `substring`, `lastIndexOf`).