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
164 changes: 6 additions & 158 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,162 +123,10 @@ wrappers preserve fitting and overflow checks; unsupported generic callable
origins remain limited. A constrained generic argument satisfies a destination
constraint when its admitted set is nonempty and every member belongs to the
destination set. Struct and union type annotations enforce these constraints
as well as construction. String comparison uses byte contents. Read the
[language tour](examples/037_language_tour.a7) and [specification](docs/SPEC.md)
together with [Status](docs/STATUS.md).
as well as construction. String comparison uses byte contents. User variadic
parameters, multi-declaration / destructuring, and multi-return spellings are
cut: they fail at semantic exit 6 or parse exit 5. Pass a slice or return a
named struct instead. Intrinsics other than `@type_set` stay reserved. Read the
[language tour](examples/037_language_tour.a7) and
[specification](docs/SPEC.md) together with [Status](docs/STATUS.md).

Inferred slice bindings retain their slice type when initialized from an array
view. A mutable binding can later select a view of a different length; its
initializer runs once. Slice lifetime enforcement remains incomplete.

Local bindings cannot reuse an import alias from their own file. This includes
function parameters, loop bindings and match captures. Each file has its own
namespace. Imported declarations use `alias.name`; top-level `_name` is private,
and struct fields remain visible. Qualified types and struct literals retain
their defining file's identity. Import aliases remain local to the file that
declares them. See [qualification](docs/audits/2026-10-07/qualification.md) and
[Status](docs/STATUS.md) for the source-specific verification boundary.

Represented readonly calls reject known nil field reads with semantic exit 6.
Previously accepted guarded calls and literal-selected non-reading controls
remain accepted. Existing call checks still apply. General callee, container
and lifetime proofs remain incomplete; see the
[safety contract](docs/SAFETY_CONTRACT.md).

The compiler also checks the original executable entry declaration against
its complete readonly summary. It rejects a represented nil read reached through
a known local selector. `--lib` has no implicit executable root. General
caller-local Boolean and effect proofs remain incomplete.

Use `usize` for sizes, lengths and indices. Use `isize` for signed pointer-sized
offsets and position differences. A7 source recursion is rejected; use loops or
explicit stacks. Current traversal candidates use worklists for parsing, type
checking, safety traversal, Zig emission and AST comparison and display. The
recursive-group and generated-method exception lists are empty. The frozen
integration passed 3,602 tests with one expected failure. Its secrets check
needed Git metadata restored; that check and all remaining release checks then
passed on unchanged sources.
See [architecture](docs/ARCHITECTURE.md) for the checked source versions and
qualification limits.

Array literals selected by `if` or `match` use the declared element type.
Concrete generic calls check each literal element for size and range.

Reference-to-fixed-array indexing supports primitive element reads and simple
or compound writes when bounds and non-nil requirements are proven. Guarded nil
calls and borrowed-array calls remain valid. Unresolved nil-call conditions,
effectful indices, selected reference-array fields, mutable or captured callable
origins, ref slicing and general reference-element ownership remain incomplete.

A resolved function with one Boolean-literal return can supply an indexed guard
fact through direct or forwarded calls and stable unwritten, uncaptured local
aliases. The checker preserves call and argument evaluation; indexed uses retain
optional-reference unwraps. Conditional, effectful and deferred helpers remain
unknown.

Local Boolean guards, early returns and value copies can prove indexed calls
safe for every input. Bare, negated and Boolean-literal comparison guards are
supported. Captured or reference-exposed cells, fields and globals are excluded.
An unguarded symbolic nil wrapper remains unresolved even with a false caller.

Numeric writes through references apply the scalar destination's exact-fit
rules. A guarded `ref usize` accepts `n = 3`; overflow and incompatible typed
values remain semantic errors. Ordinary scalar reads through references remain
unsupported.

Heap values currently require `del` or `defer del`. Pass lvalues directly to
`ref` parameters and access reference fields after nil checks. There are no
public address-of or dereference operators. Heap fixed arrays, `new [N]T`, are
rejected. Direct reference aliases share deletion state, and guarded reference
fields are checked. Literal-index reads of tracked fixed arrays retain reference
allocation identity on represented straight-line and conditional paths.
Deleting that allocation invalidates saved aliases and later reads of the
tracked slot. Fresh slot replacements and
independent array copies preserve valid uses. Broader array, slice and joined
reference lifetime checks remain incomplete. Known direct global
reference stores now propagate allocation identity through calls, so deleting a
stored allocation invalidates its caller aliases. Simple direct calls with literal
boolean selectors preserve the selected reference or nil return. Broader return,
global nil-state and parameter proofs remain incomplete. Automatic memory
management is not implemented.

Eligible loop-counter proofs survive represented readonly calls, returned
reference forwarding and writes to distinct owned storage. Known writes through
reference parameters still invalidate affected facts. Unknown calls and escaped
storage remain conservative; these checks do not establish general lifetime
safety.

Inferred concrete function bindings support reassignment and matching
reference parameters. Saved function values keep their previous target. Generic
function aliases remain compile-time aliases; closure support is unchanged.

The current stdlib provides `io` and `math`. Reserved `std/` imports resolve to
registered hooks or bundled implementation sources. This loader support adds no
public stdlib modules. Package-owned `Option(T)` and
`Result(T, E)` are available in every file. Remove old declarations of those
names or rename custom types. `io.read_line` takes a mutable byte slice, and
both it and `io.println_ok` return `Result(usize, io.IoErr)`. Import `io` explicitly
in each file that uses its operations or error type. The compiler
rejects value uses of registered `print`, `println` and `eprintln` at semantic
exit 6, including inferred bindings and array elements. Statement effects stay
valid, and `println_ok` remains value-bearing. Nine native controls passed across
debug, release and fast. The combined gate passed on frozen source `e0c6235a`.
The [verification record](docs/audits/2026-10-07/stdio-integration-verification.json)
records the complete source hash. Ordinary user void bindings are unchanged.

File imports share one emitted Zig file after per-file semantic checking. Selected
imports (`import "m" { A, B }`) bind public names from file modules and virtual
stdlib modules. `using import` rejects at semantic exit 6 with alias-form
guidance. Forwarding another file's import alias is rejected under
L76. Unsupported multi-dot type annotations and struct literals still fail
parsing. Some accepted forms
still fail later in compilation. The [gap list](docs/STATUS.md) records those
cases and the remaining generic and numeric limits.

V1 publication requires automatic memory, useful libraries and tools,
concurrency, CPU AI, actual GPU execution and self-hosting parity under
[decision L73](docs/plan/decisions.md#full-v1-completion-boundary-2026-10-07).
These are unfinished requirements. The [delivery roadmap](docs/plan/delivery-roadmap.md)
separates approved work, unresolved designs and required evidence.
GPU execution is deferred under L75. The
[Zig GPU research](docs/research/2026-10-07-zig-gpu-support.md) records support
and compile-only evidence; it does not qualify device execution.

The compiler is not a sandbox. Compile and execute only source you trust.

## Exit codes

| Code | Meaning |
| --- | --- |
| 0 | Success |
| 2 | Usage or toolchain error |
| 3 | I/O error |
| 4 | Tokenization error |
| 5 | Parse error |
| 6 | Semantic error |
| 7 | Code generation or native build error |
| 8 | Internal error |

`run` returns the native process's exit status, which can overlap these codes.

## Development and documentation

```bash
uv run python scripts/project_status.py
PYTHONPATH=. uv run pytest test/test_tokenizer.py
./run_release_checks.sh
```

`project_status.py` reports source-derived counts; it does not run tests.
The [release guide](docs/RELEASE.md) covers full checks, worker limits, native
artifacts, package builds and release preparation. The [site guide](site/README.md)
covers documentation development and generated exports.

- [Documentation index](docs/README.md), [architecture](docs/ARCHITECTURE.md)
and [changelog](docs/CHANGELOG.md).
- [Safety contract](docs/SAFETY_CONTRACT.md) and [security policy](docs/SECURITY.md).
- [Published documentation](https://code5717.github.io/a7-py/).
- [Agent index](https://code5717.github.io/a7-py/llms.txt),
[Markdown docs](https://code5717.github.io/a7-py/docs/index.md),
[manifest](https://code5717.github.io/a7-py/docs/manifest.json) and
[full agent context](https://code5717.github.io/a7-py/llms-full.txt).
5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ belong in git history, not in long Markdown logs.

## Unreleased

- Docs, site coverage, README, and feature pins sync cut-surface and
`--timings` wording after the surface-cut, perf-baseline, and P-MEM packet
tracks. Safety alias / formal-discharge gaps stay open on their own tracks;
this sync does not rewrite `a7/safety.py`.

- The docs-site lockfile uses markdown-it 15.0.3, fixing advisory
GHSA-gfr2-rv44-r23c.

Expand Down
7 changes: 7 additions & 0 deletions docs/SAFETY_CONTRACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,10 @@ Codegen must call `BackendPlan.require(node, operation)` before lowering any
approved risky operation. Approval is operation-specific: a node approved for
`index` is not approved for `cast`, `deref`, or any other lowering. Missing or
wrong approvals are compiler bugs and must fail codegen.

## Open alias and discharge work

Alias analysis through array elements and joined allocation field paths,
global nil-state summaries, and broader formal discharge remain incomplete.
See [Status](STATUS.md). Separate safety-alias tracks own changes to
`a7/safety.py`; docs and example sync must not claim those gaps closed.
6 changes: 4 additions & 2 deletions docs/SPEC.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# A7 Programming Language Specification

This reference describes the current compiler where source and regression tests
establish behavior. Sections marked parsed-only, reserved, or proposed do not
promise executable programs. Approved rules that are not yet enforced are
establish behavior. Sections marked cut, reserved, parsed-only, or proposed do
not promise executable programs. Cut forms (user variadics, multi-declaration /
destructuring, multi-return) fail closed at parse or semantic exit; do not treat
them as future runnable syntax. Approved rules that are not yet enforced are
identified separately.

The [project README](../README.md) and [release checklist](RELEASE.md) are the
Expand Down
5 changes: 5 additions & 0 deletions docs/STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,11 @@ three compilers. It is not approved. Python-specific CLI compatibility needs
a separate disposition before replacement; four report probes do not establish
self-hosting.

Safety alias and formal discharge work remains open on separate tracks. This
docs/tests/examples sync does not rewrite `a7/safety.py`; alias/lifetime gaps
in Current Surface and the [safety contract](SAFETY_CONTRACT.md) stay as
recorded until those tracks land.

Compile performance for the rewrite is measured, not optimized here: on the
2026-11-12 example corpus the Python frontend is ~3–43 ms while
`zig build-exe` release/fast is ~11–14 s per program. Use `a7 check --timings`
Expand Down
3 changes: 2 additions & 1 deletion site/public/docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schemaVersion": 1,
"sourceRevision": {
"kind": "documentation-sha256",
"value": "9157165ae6f4d7dc559befe60007b75834f23720f568dcd6cdbf51a505f991e4"
"value": "25773ba15e3ef7b92b58e37330aac6c15291fab8412bda63a6e98570e81f2cf0"
},
"qualification": "Documentation content digest, not a compiler verification result. Evidence links identify the source authority.",
"pages": [
Expand Down Expand Up @@ -1408,6 +1408,7 @@
"https://github.com/code5717/a7-py/blob/master/docs/plan/delivery-roadmap.md",
"https://github.com/code5717/a7-py/blob/master/docs/audits/2026-10-07/readonly-entry-verification.json",
"https://github.com/code5717/a7-py/blob/master/site/docs/content-verification.md",
"https://github.com/code5717/a7-py/blob/master/docs/plan/packets/P-MEM-mechanism-selection.md",
"https://github.com/code5717/a7-py/blob/master/docs/plan/decisions.md",
"https://github.com/code5717/a7-py/blob/master/docs/audits/README.md"
],
Expand Down
8 changes: 8 additions & 0 deletions site/public/docs/status.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ and an A7 compiler that establishes self-hosting parity (decision L73).
The Python compiler remains the bootstrap until parity justifies replacement;
Zig handles generated code and runtime/native integration.

Automatic memory has an approval packet only:
[P-MEM-mechanism-selection](https://github.com/code5717/a7-py/blob/master/docs/plan/packets/P-MEM-mechanism-selection.md).
No mechanism is selected until ledger approval after L38 measurements.
Compile-stage timers (`a7 check --timings` / `stages.*.ms`) document rewrite
baselines; they do not optimize the Python frontend. Safety alias and formal
discharge remain open on separate tracks; public docs here do not claim those
gaps closed.

GPU implementation and the proposed local Vulkan experiment remain deferred
for Zig GPU research under L75. That deferral does not waive V1's GPU
qualification requirement. No GPU backend or automatic-memory mechanism is
Expand Down
8 changes: 8 additions & 0 deletions site/public/llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2364,6 +2364,14 @@ and an A7 compiler that establishes self-hosting parity (decision L73).
The Python compiler remains the bootstrap until parity justifies replacement;
Zig handles generated code and runtime/native integration.

Automatic memory has an approval packet only:
[P-MEM-mechanism-selection](https://github.com/code5717/a7-py/blob/master/docs/plan/packets/P-MEM-mechanism-selection.md).
No mechanism is selected until ledger approval after L38 measurements.
Compile-stage timers (`a7 check --timings` / `stages.*.ms`) document rewrite
baselines; they do not optimize the Python frontend. Safety alias and formal
discharge remain open on separate tracks; public docs here do not claim those
gaps closed.

GPU implementation and the proposed local Vulkan experiment remain deferred
for Zig GPU research under L75. That deferral does not waive V1's GPU
qualification requirement. No GPU backend or automatic-memory mechanism is
Expand Down
80 changes: 80 additions & 0 deletions test/test_docs_claim_pins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
"""Pin user-facing docs so cut forms are not described as runnable.

Observable claim: README, SPEC, STATUS, and site coverage agree that user
variadics, multi-declaration/destructuring, and multi-return are cut. This
does not re-test compiler exits (see test_surface_cut_parsed_only.py).
"""

from __future__ import annotations

from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]


def _read(rel: str) -> str:
return (ROOT / rel).read_text(encoding="utf-8")


def test_readme_names_cut_surface():
text = _read("README.md")
assert "cut" in text.lower()
assert "variadic" in text.lower()
assert "destructuring" in text.lower()
assert "multi-return" in text.lower()
# Must not advertise cut forms as planned runnable syntax.
assert "variadic runtime lowering" not in text.lower()


def test_spec_preamble_and_variadic_section_say_cut():
text = _read("docs/SPEC.md")
assert "Sections marked cut" in text or "marked cut," in text
assert "### 6.6 Variadic Functions" in text
section = text.split("### 6.6 Variadic Functions", 1)[1].split("\n---", 1)[0]
assert "Cut from the current language surface" in section
assert "parsed and partially" not in section.lower()


def test_status_records_cut_exits():
text = _read("docs/STATUS.md")
assert "are cut from the runnable surface" in text
assert "semantic exit 6" in text
assert "parse exit 5" in text
assert "P-STD-collections-scope" in text
assert "P-MEM-mechanism-selection" in text
assert "does not rewrite `a7/safety.py`" in text


def test_coverage_matrix_matches_cut_qualifications():
text = _read("site/docs/coverage.md")
assert "Cut: declarations parse then fail at semantic exit 6" in text
assert "Cut: multi-return and destructuring fail at parse exit 5" in text
assert "Cut: user variadic parameters fail at semantic exit 6" in text
assert "user variadic runtime lowering is unavailable" not in text


def _top_level_commas(expr: str) -> bool:
depth = 0
for ch in expr:
if ch in "([{":
depth += 1
elif ch in ")]}":
depth = max(0, depth - 1)
elif ch == "," and depth == 0:
return True
return False


def test_examples_avoid_cut_spellings():
forbidden_snippets = (
": ..",
", :=",
)
for path in sorted((ROOT / "examples").glob("*.a7")):
source = path.read_text(encoding="utf-8")
for snippet in forbidden_snippets:
assert snippet not in source, f"{path.name} contains cut spelling {snippet!r}"
for line in source.splitlines():
stripped = line.split("//", 1)[0].strip()
if stripped.startswith("ret ") and _top_level_commas(stripped[4:]):
raise AssertionError(f"{path.name} has multi-value ret: {stripped}")
Loading