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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .machine_readable/descriptiles/STATE.deed
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ last-updated = "2026-06-21"
status = "active"
authoritative-status-doc = "docs/CAPABILITY-MATRIX.adoc"
drift-flag = "STALE as of 2026-05-23 PM: this file's [components]/[features]/[project-context] still predate landed PRs since 2026-05-19. It MIRRORS, it does not LEAD. Authoritative sources by topic — readiness: docs/CAPABILITY-MATRIX.adoc; spine + AS↔typed-wasm contract: docs/ECOSYSTEM.adoc; coordination ledger / critical path: docs/TECH-DEBT.adoc; test taxonomy + PR-level gates: docs/standards/TESTING.adoc (added 2026-05-23); panic-attack SOP: docs/standards/PANIC-ATTACK.adoc (added 2026-05-23). Gate baseline: CAPABILITY-MATRIX records 260/260 at 2026-05-19 reconstruction; subsequent borrow-checker work has lifted it (#240 → 263, return-escape → 271/274, &mut surface → 278/281). The exact live number for any given commit comes from `dune runtest --force` — do not hard-code it here. (DOC-05, issue #176.)"
session-note-2026-12-01 = "INTERPRETER PARITY #833. lib/interp.ml now runs what the checker accepts: every top-level fn shares one environment cell (self-, forward and mutual recursion, including private fns of imported modules); let mut / const mut bindings are cells (Value.Cell) and assignment resolves its left-hand side to a place (compound operators, array element, record field, tuple component); return unwinds to the enclosing call (Value.EarlyReturn; it used to fall through, a silently wrong value); Some / None / Ok / Err are bound as the preamble constructors the flattener assumes (string::char_at); println writes a String unquoted. affinescript eval type-checks through Typecheck.check_program, as check and compile do. NOT done: eval still skips the borrow checker (COMPLETION-PLAN H6). Anchor: test/test_interp_eval.ml (18 cases, interpreter vs expected vs Bun-ESM). This file MIRRORS; authoritative: docs/SOUNDNESS.adoc."
session-note-2026-06-21 = "SESSION: release-binaries pipeline repair + downstream gap triage + onboarding polish. (1) RELEASE — PR #641 (merged b8ba479) fixed .github/workflows/release.yml, which had been shipping v0.2.0 SOURCE-ONLY (regression from v0.1.1). Two bugs, both confirmed from the failed v0.2.0 run 26694097435: (a) immutable releases now forbid adding assets to a PUBLISHED release (linux leg died HTTP 422), and (b) the v0.2.0-added version-bake step used GNU `sed -i` which BSD/macOS sed rejects (extra characters at the end of l command), so both mac legs failed before building. Fix: create the release as a DRAFT, upload all binaries + SHA256SUMS into it, then publish (--draft=false --latest) last so it seals atomically; portable `sed -i.bak`. Compiler verified to build in release mode locally; --version/check/eval/compile work. v0.2.0 is immutable+assetless and cannot be amended, so binaries ship via a fresh v0.2.1 tag — OWNER action: a Claude-Code-web session cannot push v* tags (HTTP 403). Tracked in #646 (incl. downstream quandledb re-pin). (2) WASM cross-module constructor-link task was ALREADY LANDED before this session: #602 / ac98c81 (Closes #138) — register_imported_types in Codegen.gen_imports registers imported public enum constructors into variant_tags via the local gen_decl path; core-Wasm regression test in test_stdlib_aot.ml; verified locally 534/534. Downstream stapeln re-pins to ac98c81 and drops its carried git apply. (3) svalinn-gateway compiler gaps confirmed + filed: #642 (compile has no module search-path / project mode for nested src/**), #643 (float_to_string raises UnboundVariable at core-Wasm compile; wired only in resolve/typecheck/interp/Deno), #644 (empty match-arm body Pat => {} is a parse error). `pub extern fn` was checked and is SUPPORTED — not a gap. (4) ONBOARDING POLISH (this change): added tutorial lesson-01 (the docs/tutorial track previously started at lesson-02), an audience router (developers / maintainers / end-users) in README + NAVIGATION, and this note. Docs consolidation (two overlapping lesson tracks, wiki sync) tracked in #647. Note: guides/lessons/01-hello bare-println example is stale (parse error on current compiler) — folded into #647. This file MIRRORS; authoritative sources unchanged (see drift-flag)."
session-note-2026-05-26-publish-104 = "ISSUE #104 CLOSED — FIRST NPM PUBLISH LANDED. @hyperpolymath/affine-vscode@0.1.0 is now on registry.npmjs.org. Owner-action sequence completed today: (1) npm org `hyperpolymath` created on free public-package tier; (2) Granular Access Token generated for scope @hyperpolymath/* with Read+Write, uploaded to repo secret NPM_TOKEN; (3) signed annotated tag affine-vscode-v0.1.0 pushed at origin/main (RSA key 9639451754496E51D6B537CAD119017EBF695AB1); (4) .github/workflows/affine-vscode-publish.yml ran green — `npm publish --access public` succeeded; (5) `npm view @hyperpolymath/affine-vscode` resolves. Downstream consumers (my-lang#66, standards#160) which un-vendored their adapters on 2026-05-21 now have a working `npm install` path; vscode-smoke workflow (skipped per #381 while package was unpublished) will start exercising the live package on its next PR run. Lineage for future @hyperpolymath/* publishes: org+token are reusable; mirror `affine-vscode-publish.yml`'s shape (tag trigger, version-match guard, .npmrc write from secret, npm publish --access public). NPM_TOKEN rotation advised post-publish (token value transited a session transcript during wire-up); see .machine_readable/descriptiles/PLAYBOOK.a2ml [npm-publish] for the runbook."
session-note-2026-05-30 = "DOC-16 + DOC-17 — DOC-TRUTHING MONITOR FULLY MECHANICAL (issue #176). Two complementary in-repo guards now enforce the doc-truthing rules that were previously external-bot-only. DOC-16 (PR #476, tools/check-doc-truthing.sh): banner-PRESENCE invariant — fails if any over-claiming doc loses its CAPABILITY-MATRIX banner, if the matrix stops self-declaring primacy / loses its 'What AffineScript is NOT' section, or if STATE.a2ml drops its mirror keys; deliberately does NOT phrase-scan (a naive grep false-positives on the negating banners + future-roadmap text). DOC-17 (PR #475, tools/check-doc-overclaims.sh + tools/doc-overclaims.allow): the phrase-detection complement — a frozen-baseline RATCHET over README + docs/** (excluding CAPABILITY-MATRIX + TECH-DEBT, which quote the rule) that fails any NEW backend-breadth / 'production-ready' / stdlib-% occurrence beyond the 13-line baseline (all current entries legit: future-tense roadmap milestones + dated history snapshots + corrective banners); re-baseline via `--update` / `just doc-overclaims-bless`, diff = audit trail. Both wired into `just check` (guard recipe) + ci.yml build job, both toolchain-free bash (run without OCaml). #475 was originally a superset of #476 (built in parallel, same session); on discovering #476 had merged first, #475 was reworked to drop the duplicated banner check and keep only the unique ratchet, renamed check-doc-truth.sh→check-doc-overclaims.sh to avoid the name clash (DOC-DEDUP-clean). FOLLOW-UP (same day, post-#475-merge): the two near-identically-named guards were consolidated so neither lingers — the ratchet (incl. `--update` mode + tools/doc-overclaims.allow baseline) was folded INTO tools/check-doc-truthing.sh using #476's fail-accumulator/note() structure, and tools/check-doc-overclaims.sh was deleted. A SINGLE toolchain-free guard now enforces both presence invariants (DOC-04/05) and the over-claim ratchet (DOC-08/09) in one run; one CI step; the `guard` recipe runs it; re-baseline via `just doc-truth-bless`. DOC-17 folded into DOC-16 in the ledger. Gate-number policy unchanged (DOC-05): live `dune runtest --force` count never hard-coded. No compiler code touched. Refs #176 / #175."
Expand Down
34 changes: 16 additions & 18 deletions bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,16 @@ let eval_file face json path =
| Error (e, span) ->
add (Affinescript.Json_output.of_resolve_error e span)
| Ok (resolve_ctx, type_ctx) ->
let type_ctx = { type_ctx with symbols = resolve_ctx.symbols } in
(* Register builtins (print, int_to_string, tea_run, etc.) before type-checking *)
Affinescript.Typecheck.register_builtins type_ctx;
(match List.fold_left (fun acc decl ->
match acc with
| Error _ as e -> e
| Ok () -> Affinescript.Typecheck.check_decl type_ctx decl
) (Ok ()) prog.prog_decls with
(* The same type-checking entry as `check` and `compile` (#833). `eval`
used to fold [Typecheck.check_decl] itself, without the pass that
pre-registers every top-level signature, so it rejected forward
and mutual references that `compile` accepts. *)
(match Affinescript.Typecheck.check_program
~import_types:type_ctx.Affinescript.Typecheck.name_types
resolve_ctx.symbols prog with
| Error e ->
add (Affinescript.Json_output.of_type_error e)
| Ok () ->
| Ok _type_ctx ->
(* Stage 1: QTT quantity enforcement *)
(match Affinescript.Quantity.check_program_quantities prog with
| Error (err, span) ->
Expand Down Expand Up @@ -354,19 +353,18 @@ let eval_file face json path =
(Affinescript.Face.format_resolve_error face e);
`Error (false, "Resolution error")
| Ok (resolve_ctx, type_ctx) ->
let type_ctx = { type_ctx with symbols = resolve_ctx.symbols } in
(* Register builtins (print, int_to_string, tea_run, etc.) before type-checking *)
Affinescript.Typecheck.register_builtins type_ctx;
(match List.fold_left (fun acc decl ->
match acc with
| Error _ as e -> e
| Ok () -> Affinescript.Typecheck.check_decl type_ctx decl
) (Ok ()) prog.prog_decls with
(* The same type-checking entry as `check` and `compile` (#833). `eval`
used to fold [Typecheck.check_decl] itself, without the pass that
pre-registers every top-level signature, so it rejected forward
and mutual references that `compile` accepts. *)
(match Affinescript.Typecheck.check_program
~import_types:type_ctx.Affinescript.Typecheck.name_types
resolve_ctx.symbols prog with
| Error e ->
Format.eprintf "@[<v>%s@]@."
(Affinescript.Face.format_type_error face e);
`Error (false, "Type error")
| Ok () ->
| Ok _type_ctx ->
(* Stage 1: QTT quantity enforcement *)
(match Affinescript.Quantity.check_program_quantities prog with
| Error (err, _span) ->
Expand Down
10 changes: 5 additions & 5 deletions docs/COMPLETION-PLAN.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Results were consistent, but they do not prove CI is green.
| No totality gate.

| Interpreter (`lib/interp.ml`)
| Early `return` gives a wrong value (`g(5)=2`, expected 1) because of `interp.ml:262`. Local `let mut` reassignment fails at runtime (`value.ml:157`). `2147483647+1` evaluates to `2147483648` in the interpreter but `-2147483648` in compiled WASM.
| Early `return` gives a wrong value (`g(5)=2`, expected 1) because of `interp.ml:262`. Local `let mut` reassignment fails at runtime (`value.ml:157`). (Both fixed 2026-12-01, #833; see H1 and H7 below.) `2147483647+1` evaluates to `2147483648` in the interpreter but `-2147483648` in compiled WASM.
| The interpreter is the declared reference semantics, and the Coq models claim to mirror it.
| Delimited continuations. The interpreter is the only handler executor, yet it cannot run `return` or `let mut` correctly, so handler programs have no correct execution path today.

Expand Down Expand Up @@ -201,13 +201,13 @@ Results were consistent, but they do not prove CI is green.

All were observed by RUN unless marked otherwise. The maps confirm that H1–H4 and H9 are absent from `docs/SOUNDNESS.adoc`. H5–H8, H10, H12 and H13 were not checked against the ledger. H11 already has a drafted issue (`issues-drafts/06`, referenced from the AFFIRMATION). H14, H15 and H19 belong to typed-wasm, not the AffineScript ledger.

. H1. Interpreter early `return` has no non-local exit (`lib/interp.ml:262`).
. H1. Interpreter early `return` has no non-local exit (`lib/interp.ml:262`). *Fixed 2026-12-01 (#833):* `return` unwinds to the enclosing call (`Value.EarlyReturn`). Anchor: `test/test_interp_eval.ml`.
. H2. Bun-ESM `return` in expression position is lowered as an IIFE (`lib/codegen_deno.ml:1575`). *Narrowed 2026-11-09:* `let` initializers and function and lambda tails are now lowered to statements, so the `return` leaves the function; a match used as an argument or operand with a `return` in an arm is refused loudly. *Round 2 (2026-11-16):* match arms and guards are lowered as a labelled block, so a guard sees the arm's bindings and a `return` in an arm leaves the function; `let _ = e` still evaluates `e`; a `return` in an `if` condition, a scrutinee or a guard is refused loudly. Anchor: `test/test_module_root_flatten.ml`.
. H3. The JS-text backend drops block returns (`lib/js_codegen.ml`). The Lua backend emits invalid code.
. H4. Non-exhaustive match compiles to "return 0" on core WASM.
. H5. Effect rows are not checked against performed operations or callee rows.
. H6. `eval` and the REPL skip borrow checking and trait coherence. Only the `eval` borrow-checking gap is RUN. The REPL gap is READ only, because the REPL is not built.
. H7. Interpreter `let mut` reassignment fails at runtime.
. H6. `eval` and the REPL skip borrow checking and trait coherence. Only the `eval` borrow-checking gap is RUN. The REPL gap is READ only, because the REPL is not built. *Narrowed 2026-12-01 (#833):* `eval` now type-checks through `Typecheck.check_program`, as `check` and `compile` do, so it runs trait coherence (RUN: a duplicate impl is rejected). `eval` still does not run the borrow checker.
. H7. Interpreter `let mut` reassignment fails at runtime. *Fixed 2026-12-01 (#833):* a `let mut` / `const mut` binding is a cell (`Value.Cell`), and assignment resolves its left-hand side to a place. The same change fixes self-, forward and mutual recursion in the interpreter and the missing `Some` / `None` / `Ok` / `Err`. Anchor: `test/test_interp_eval.ml`.
. H8. `total fn` is accepted without any check.
. H9. Integer width diverges: the interpreter uses 63-bit ints, WASM wraps at i32.
. H10. `compile` emits a `.wasm` despite typed-wasm L7/L10 violations.
Expand All @@ -222,7 +222,7 @@ All were observed by RUN unless marked otherwise. The maps confirm that H1–H4
. H19 (typed-wasm). No L5 index guard: `get_player_hp(0,150)` reads an adjacent region. `where` constraints are discarded. Malformed `session` blocks are silently ignored.
. H23 (found and fixed 2026-11-09, checking and running metadatastician/kyq; numbered H20 in #788, renumbered because #787 assigned H20–H22). A module file found for `A.B` that declares `module A;` was accepted as `A.B`, so `use A.Nonexistent::*` type-checked and imported `A`'s exports; it is now a `ModuleDeclMismatch` load error. *Round 2 (2026-11-16):* a nested candidate (`dir/A/B.affine`) is now searched in every directory before any parent-module fallback, and a module whose load fails is no longer left marked as loading (which reported a later import of it as a cycle). Anchor: `test/test_module_root_flatten.ml`.
. H24 (found and fixed 2026-11-09; numbered H21 in #788). `eval` ran the unflattened program, so no imported function was bound at run time; flattening also emitted a selected function before the private helpers it calls and carried no helpers for glob or plain imports. `eval` now flattens, every import kind carries its helpers, and they are emitted in the imported module's declaration order. *Round 2 (2026-11-16):* two modules with a same-named private helper no longer collide: every private helper carried into a flattened program is renamed `__priv_<Module>__<name>` with a capture-avoiding substitution (the module path is length-prefixed, so `A_B.C` and `A.B_C` cannot share a name), and an aliased import emits the original before the alias. *Round 3 (2026-11-16):* a public declaration carried only for the module's own callers (the original of an alias, or a helper only a selected function calls) gets an internal name too, so two modules' `helper`s cannot replace one another; aliasing a mutable binding, which would make a second copy, and an unresolvable name collision are structured flattening errors (diagnostic E0206), not exceptions. *Round 4 (2026-11-19, #801):* the per-case renaming above still let two modules' public declarations of one name meet when they arrived through other modules' imports (`X` uses `A.f`, `Y` uses `B.f`; the flattened program kept one `f` and Bun ran it for both). Every function and constant of an imported module, public or private, now carries a module-qualified name `__mod_<Module>__<name>` (length-prefixed as before; `__priv_` is gone), the root keeps its own and its imported names, externs keep their host names, and the flattener and the JS emitters refuse two different top-level bindings of one name. Only the root program's `main` is run. Anchor: `test/test_module_root_flatten.ml`.
. H25 (found and fixed 2026-11-09; numbered H22 in #788). The interpreter had no `++` on arrays and no `==`/`!=` beyond Int, Float, String and Bool, though the checker accepts them; it now uses the structural `Value.value_eq`. H7 (`let mut`) is unchanged. Anchor: `test/test_module_root_flatten.ml`.
. H25 (found and fixed 2026-11-09; numbered H22 in #788). The interpreter had no `++` on arrays and no `==`/`!=` beyond Int, Float, String and Bool, though the checker accepts them; it now uses the structural `Value.value_eq`. H7 (`let mut`) is unchanged by that change (fixed later, #833). Anchor: `test/test_module_root_flatten.ml`.

== 2. Target architecture

Expand Down
2 changes: 1 addition & 1 deletion js/js_api.ml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ let eval_program_string (code : string) : eval_result Js.t =
let env_str =
List.map (fun (name, value) ->
Printf.sprintf "%s = %s" name (Affinescript.Value.show_value value)
) env
) (Affinescript.Value.env_values env)
|> String.concat "\n"
in
success_result env_str "Environment"
Expand Down
Loading
Loading