Skip to content
Draft
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
4 changes: 2 additions & 2 deletions freak-conformance-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ Verdict legend: 🛠 code fix, 📖 amend bible, ✅ already aligned.
|---|---|---|---|
| `pilot x = value` declares variable, mutable by default | ✅ | ✅ | [freakc/parser.py:900-950](freakc/parser.py); confirmed by `tests/suite/test_variables.fk` |
| `fixed pilot x = value` immutable | ✅ | ✅ | parsed and enforced |
| Type annotation optional / inferred | ✅ | ✅ | The shipping checker infers unannotated literals. In V4, task-local `pilot` and `fixed pilot` annotations—including tuple and fixed-array annotations used by tuple/list destructuring—are normalized with exact spans into HIR snapshot v5 facts, exposed/canonicalized by TY, and consumed by MIR build without re-reading their type tokens. MIR build still uses body tokens for patterns, initializer boundaries, places, and CFG; six unrelated type-text callers remain guarded, backend representation is unchanged, and symbol-valued annotated locals retain the existing phantom-local-IR limitation. |
| Type annotation optional / inferred | ✅ | ✅ | The shipping checker infers unannotated literals. In V4, task-local `pilot` and `fixed pilot` annotations—including tuple and fixed-array annotations used by tuple/list destructuring—are normalized with exact spans into HIR snapshot v6 facts, exposed/canonicalized by TY, and consumed by MIR build without re-reading their type tokens. MIR build still uses body tokens for patterns, initializer boundaries, places, and CFG; six unrelated type-text callers remain guarded, backend representation is unchanged, and symbol-valued annotated locals retain the existing phantom-local-IR limitation. |
| `pilot mut x = ...` (Phase-1 BC) for explicit mutability under `--strict-borrow` | ✅ | 📖 | [src/compiler/v3/checker.fk](src/compiler/v3/checker.fk) — bible should mention this dual mode (default leak-everything vs `--strict-borrow`) |

#### §1.2 Functions ([freak-full-bible.md:42-71](freak-full-bible.md))

| Contract | Status | Verdict | Notes |
|---|---|---|---|
| `task name(...) -> type { ... }` | ✅ | ✅ | Core feature. V4 stores ordinary top-level tasks as closed `explicit` / `implicit-block` / `arrow` HIR return-form facts; an explicit `-> T` carries normalized surface text and its exact span through HIR snapshot v5, and TY consumes that declared type/span without token reconstruction. Arrow inference, implicit block returns, impl/doctrine/extern signatures, MIR body lowering, and backend behavior retain their existing semantics and remain separately bounded. |
| `task name(...) -> type { ... }` | ✅ | ✅ | Core feature. V4 stores ordinary top-level tasks as closed `explicit` / `implicit-block` / `arrow` HIR return-form facts; an explicit `-> T` carries normalized surface text and its exact span through HIR snapshot v6, and TY consumes that declared type/span without token reconstruction. Ordinary-task parameters are likewise stored as ordered HIR name/mode/lifetime/type contracts with exact spans; TY, MIR build, Meiya, and editor consumers use those semantic facts. Impl/doctrine/extern parameter signatures, arrow inference, implicit block returns, other MIR body families, and backend behavior retain their existing semantics and remain separately bounded. |
| `give back` return keyword | ✅ | ✅ | |
| `say` print keyword always available | ✅ | ✅ | |
| String path interpolation `"{path}"` | ✅ | ✅ | Self-hosted V3 lowers resolved `IDENT(.IDENT)*` paths in every word-expression context on C and LLVM; non-path brace bodies remain literal. Executable evidence: [tests/v3_interpolation.py](tests/v3_interpolation.py) and [tests/v3_legacy_golden.py](tests/v3_legacy_golden.py). |
Expand Down
95 changes: 92 additions & 3 deletions freakc/auditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2878,7 +2878,7 @@ def add(label: str, ok: bool, detail: str = "") -> None:
if v4_hir_task_return.exists():
hir_src = v4_hir_task_return.read_text(encoding="utf-8")
for needle in (
'pilot v4_hir_snapshot_format = "freak-hir-snapshot-v5"',
'pilot v4_hir_snapshot_format = "freak-hir-snapshot-v6"',
'pilot v4_hir_task_return_explicit = "explicit"',
'pilot v4_hir_task_return_implicit_block = "implicit-block"',
'pilot v4_hir_task_return_arrow = "arrow"',
Expand Down Expand Up @@ -2935,7 +2935,7 @@ def add(label: str, ok: bool, detail: str = "") -> None:
v4_task_return_readme,
(
"The third bounded boundary covers declared returns on ordinary top-level tasks.",
"HIR snapshot v5 validates that vocabulary",
"HIR snapshot v6 validates that vocabulary",
),
),
(
Expand All @@ -2956,14 +2956,103 @@ def add(label: str, ok: bool, detail: str = "") -> None:
add(
"V4 task return HIR boundary",
not task_return_boundary_missing,
"HIR v5 + TY adapters + smoke + docs wired" if not task_return_boundary_missing else f"{len(task_return_boundary_missing)} gap(s)",
"HIR v6 + TY adapters + smoke + docs wired" if not task_return_boundary_missing else f"{len(task_return_boundary_missing)} gap(s)",
)
if task_return_boundary_missing:
failures.append(
"V4 ordinary-task return HIR boundary regressed: "
+ "; ".join(task_return_boundary_missing)
)

# Check 9c: ordinary-task parameter contracts belong to HIR. Nonordinary
# impl/doctrine/extern signatures remain explicit, guarded token fallbacks.
v4_hir_task_param = repo / "src" / "compiler" / "v4" / "crates" / "freak_hir" / "src" / "lib.fk"
v4_ty_task_param = repo / "src" / "compiler" / "v4" / "crates" / "freak_ty" / "src" / "lib.fk"
v4_mir_build_task_param = repo / "src" / "compiler" / "v4" / "crates" / "freak_mir_build" / "src" / "lib.fk"
v4_editor_task_param = repo / "src" / "compiler" / "v4" / "crates" / "freak_editor" / "src" / "lib.fk"
v4_task_param_smoke = repo / "src" / "compiler" / "v4" / "tests" / "task_param_semantic_boundary_smoke.fk"
task_param_boundary_missing: List[str] = []
for path, label, needles in (
(
v4_hir_task_param,
"freak_hir",
(
'pilot v4_hir_snapshot_format = "freak-hir-snapshot-v6"',
'pilot v4_hir_task_param_mode_value = "value"',
'pilot v4_hir_task_param_mode_lend = "lend"',
'pilot v4_hir_task_param_mode_lend_mut = "lend mut"',
"task v4_hir_task_param_count(",
"task v4_hir_task_param_name_span(",
"task v4_hir_task_param_segment_span(",
'pilot out = "hir-task-param-owner"',
'pilot out = "hir-task-param"',
"task v4_hir_snapshot_task_param_owner_is_valid(",
"task v4_hir_snapshot_task_param_is_valid(",
"task v4_hir_snapshot_task_param_slots_are_valid(",
),
),
(
v4_ty_task_param,
"freak_ty",
(
"task v4_ty_signature_is_ordinary_hir_task(",
"task v4_ty_signature_param_count(",
"task v4_ty_signature_param_name(",
"task v4_ty_signature_param_mode(",
"task v4_ty_signature_param_lifetime(",
"task v4_ty_signature_param_surface_type(",
"task v4_ty_signature_param_type_span(",
"task v4_ty_signature_param_segment_span(",
"task v4_ty_signature_param_name_span(",
"task v4_ty_nonordinary_signature_param_count_fallback(",
"task v4_ty_nonordinary_signature_param_name_fallback(",
"task v4_ty_nonordinary_signature_param_surface_type_fallback(",
),
),
(v4_mir_build_task_param, "freak_mir_build", ("v4_ty_signature_param_segment_span",)),
(v4_editor_task_param, "freak_editor", ("v4_ty_signature_param_name_span",)),
):
if not path.exists():
task_param_boundary_missing.append(f"{label}/src/lib.fk missing")
continue
source = path.read_text(encoding="utf-8")
for needle in needles:
if needle not in source:
task_param_boundary_missing.append(f"{label}: {needle}")
if not v4_task_param_smoke.exists():
task_param_boundary_missing.append("smoke fixture: task_param_semantic_boundary_smoke.fk")
if v4_task_return_harness.exists():
harness_src = v4_task_return_harness.read_text(encoding="utf-8")
for needle in (
'"name": "task parameter semantic boundary"',
'"fixture": "task_param_semantic_boundary_smoke.fk"',
"def check_task_param_hir_boundary() -> None:",
"check_task_param_hir_boundary()",
):
if needle not in harness_src:
task_param_boundary_missing.append(f"check_v4.py: {needle}")
for doc_path, needles in (
(v4_task_return_readme, ("The fourth", "ordinary-task parameter APIs", "HIR snapshot v6 validates exact record")),
(audit_doc, ("Ordinary-task parameters are likewise stored", "Impl/doctrine/extern parameter signatures")),
):
if not doc_path.exists():
task_param_boundary_missing.append(f"documentation missing: {doc_path.name}")
continue
doc_src = doc_path.read_text(encoding="utf-8")
for needle in needles:
if needle not in doc_src:
task_param_boundary_missing.append(f"{doc_path.name}: {needle}")
add(
"V4 task parameter HIR boundary",
not task_param_boundary_missing,
"HIR v6 + TY/MIR/editor adapters + smoke + docs wired" if not task_param_boundary_missing else f"{len(task_param_boundary_missing)} gap(s)",
)
if task_param_boundary_missing:
failures.append(
"V4 ordinary-task parameter HIR boundary regressed: "
+ "; ".join(task_param_boundary_missing)
)

# ── Check 10: V4 contract-region source sets ──
# Borrowed return signatures may select every parameter whose lifetime
# outlives the return region. Require the set-valued TY/MIR/Meiya contract,
Expand Down
17 changes: 13 additions & 4 deletions src/compiler/v4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,21 @@ that exact set and prevents local declaration lowering from returning to it.
The third bounded boundary covers declared returns on ordinary top-level tasks.
`freak_hir` stores one closed `explicit` / `implicit-block` / `arrow` record per
task, including normalized surface type and exact contained span only for an
explicit `-> T`; HIR snapshot v5 validates that vocabulary, task-only ownership,
explicit `-> T`; HIR snapshot v6 validates that vocabulary, task-only ownership,
canonical spans, contiguous slots, and declared counts before restore. TY reads
explicit return types and spans only through those HIR facts. Arrow inference,
implicit block returns, and non-ordinary impl/doctrine/extern signatures remain
separately named fallbacks and keep their existing semantics. Task parameter
types, shape/route fields, const annotations, non-ordinary signatures, the
separately named fallbacks and keep their existing semantics. The fourth
bounded boundary covers parameters on those same ordinary tasks. HIR owns one
ordered parameter-count record per task, including zero, plus normalized name,
`value` / `lend` / `lend mut` mode, optional named lifetime, surface type, and
their exact contained spans. TY's public ordinary-task parameter APIs consume
only those records; MIR build uses the semantic segment span and editor
definitions use the semantic name span. HIR snapshot v6 validates exact record
widths, Task-only ownership, contiguous ordinals and counts, identifier and
mode vocabulary, source ordering, and atomic restore. Impl, doctrine, and
extern signatures remain explicitly named token-facing fallbacks. Shape/route
fields, const annotations, other non-ordinary signatures, the
remaining MIR body families, and all other type families remain explicit
follow-up slices. These boundaries change fact ownership, not language
semantics or backend representation. Symbol-valued annotated locals still
Expand Down Expand Up @@ -518,7 +527,7 @@ unit-section|<section-name>|<escaped-checkpoint-identity>|<escaped-section-paylo
end|freak-00-unit-snapshot-v3
```

The source records describe the current `freak_session` source database. The checkpoint identity folds the source identity and content digests for all 15 sections in canonical order, including identity expansion between parse and HIR, so a section cannot be transplanted from a different checkpoint even when source text is unchanged. This is an integrity checksum, not an authentication primitive. Section records are owned by `freak_snapshot`; each section is allowed to change internally only when its format helper and validator change together. Standalone expansion- and HIR-component restore dirty their cached query families and transitive dependents before arena-slot reuse; full prevalidated 00-Unit restore instead keeps both component restores raw before installing the checkpoint's saved query section. HIR v5 validation requires canonical alias-target, local-annotation, and ordinary-task declared-return spans, exact child ownership/slot identity, a closed return-form vocabulary, and exact declared counts. Adding the expansion section changes the complete checkpoint format from v2 to v3; v2 payloads are rejected rather than reinterpreted.
The source records describe the current `freak_session` source database. The checkpoint identity folds the source identity and content digests for all 15 sections in canonical order, including identity expansion between parse and HIR, so a section cannot be transplanted from a different checkpoint even when source text is unchanged. This is an integrity checksum, not an authentication primitive. Section records are owned by `freak_snapshot`; each section is allowed to change internally only when its format helper and validator change together. Standalone expansion- and HIR-component restore dirty their cached query families and transitive dependents before arena-slot reuse; full prevalidated 00-Unit restore instead keeps both component restores raw before installing the checkpoint's saved query section. HIR v6 validation requires canonical alias-target, local-annotation, ordinary-task declared-return, and ordinary-task parameter spans; exact child ownership/slot identity; closed return-form and parameter-mode vocabularies; exact declared counts; and validation-before-mutation restore. Adding the expansion section changes the complete checkpoint format from v2 to v3; v2 payloads are rejected rather than reinterpreted.

### `workspace/unitSnapshotManifest`

Expand Down
Loading