Files
aji/docs/rfcs/0035-caller-buffer-lexical-paths.md
T
dev ad75ffe021
ci / build (ubuntu-latest) (push) Successful in 4m52s
ci / extended (push) Failing after 3h0m2s
ci / build (macos-latest) (push) Canceled after 0s
docs: adopt intermediate standard library foundation
Record the owner-requested STD-0..7 merge boundary and adoption of implemented
RFCs 0016-0035, whose normative rules and vertical implementations land together.
Update repository and std status; keep remaining Std 0.1 and service milestones
in the backlog. Track Q-034/P6-11 as the next source-language task and retain
the existing P7/P8 gate.

Implementation checks are recorded in RFC 0035 and the std plan; this change
updates adoption metadata and planning only.
2026-10-07 13:42:50 +03:00

47 lines
7.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# RFC 0035: Caller-buffer lexical paths
Status: Implemented
Scope: STD-7c, std.path after owning buffered files
Adoption: owner-requested intermediate std merge, 2026-10-07; normative rules and reference implementation are integrated together.
## Motivation and spec integration
Spec 16 §2.19 adds six pure path operations on bytes with one portable slash syntax. Paths are frequent CLI/storage data; normalization/join/component loops should be reusable without hidden allocations, host state or a larger authority surface. Spec 16 and reference/std.md contain the normative contracts; this record explains them.
## Preserved invariant and verifier rule
Output writes remain within the supplied exclusive slice, successful output preserves its suffix, and every returned input/size/capacity error preserves the entire destination. Input borrows only read; no borrow escapes, file/resource is consumed or capability is gained. Component queries return bounded Copy index ranges, keeping lifetime/bounds decisions visible in the caller. Ordinary borrow, bounds, Copy/Send/Share, task loans and effect checks apply without new verifier state.
## Runtime / deterministic behavior
Only safe source algorithms: validation and final-size measurement precede emission. Reverse scanning cancels components with pending parents; a second reverse pass writes retained components into the exact final prefix. Capacity is measured after cancellation, so a short destination can hold a result whose raw input was long. No heap/scratch allocation, platform branch, filesystem access, symlink interpretation or current directory. `/` is the separator in every profile. NUL rejects in writers; non-UTF-8/backslash bytes remain ordinary data. Primitive filesystem capability/path checks are unchanged and still mandatory.
## Valid and rejected examples
Join /data/a with ../b into a caller array, handle WriteResult, then use the resulting slice with an explicit fs capability. Normalization alone cannot authorize the path. Disjoint slices within one allocation are valid; overlapping source/output, task-loaned output and wrong scalar/slice types reject through existing diagnostics. The [pure example](../../examples/std/path.aji) joins into caller storage and borrows its component ranges. [A one-byte canceled result](../../tests/conformance/source/path/canceled_capacity.aji) and [disjoint slices](../../tests/conformance/source/path/disjoint.aji) are valid. [Overlapping slices](../../tests/conformance/source/path/overlap.aji) reject E2101; [a live task loan](../../tests/conformance/source/path/loan.aji) rejects E4101. [Authority](../../tests/conformance/source/path/authority.aji) remains independently enforced, and [reusing a range on a shorter input](../../tests/conformance/source/path/range_bounds.aji) traps T0008 through ordinary bounds checking.
## Diagnostics / AIR / compatibility
No new diagnostic, source syntax, AIR instruction/feature/meaning, verifier/runtime state or trusted boundary. Existing E7002/E7005/E2101/E4101 apply. WriteResult variants are ordinary Copy data; insufficient output and malformed input do not trap or mutate output. All existing paths/fs grants/source/AIR contracts retain their meaning. Q-034 is neither expanded nor silently inferred: callers explicitly borrow a returned Range from their own path.
## Agent complexity impact
Six supported operations: is_absolute/basename/parent/extension/normalize/join. One separator syntax and one destination-first writing result. Queries report raw bounded offsets without borrowed returns; writing reports final prefix size and has an unchanged-output error contract. No agent needs platform-specific normalization, hidden allocation or lifetime inference. Existing primitives suffice; no language concepts, verifier state, syntax forms or diagnostics are added. Full edge rules stay on demand. Measured Quick Reference/source bundle budgets follow; no empirical MCC benefit is claimed.
## Alternatives considered
Host-dependent paths would make deterministic fixtures/platform reasoning harder and disagree with the existing runtime slash syntax. Borrowed query returns would require a separate vertical lifetime feature before safe source can use them. Requiring raw-input-sized output would fail ordinary cancellation cases unnecessarily. In-place mutation would need explicit overlap semantics and would violate the current exclusive-output/shared-input contract. Adding an opaque path opcode is unnecessary.
## Validation gate
Independent forward-stack byte oracle; empty/root/relative/absolute, repeated separators, dot/parent cancellation, root saturation, hidden/multiple/trailing extensions, non-UTF-8/backslash/NUL, exact/short capacities, late malformed input, suffix preservation, disjoint same-allocation slices and small canceled-result output. Rejected aliases/types/imports/task loans; valid task transfer/restored loans; source/AIR/package/profile/provenance/audit and authority checks; GC/scheduler stress, full conformance, unit/Quick Reference, formatting, source coverage and documentation budget. STD-7 completes only after this gate; STD-8 and the broader roadmap remain required.
Measured cl100k growth from RFC 0034: Quick Reference 8,445 → 8,518 (+0.9%); other source documentation 61,223 → 63,296 (+3.4%); full source excluding AIR 69,668 → 71,814 (+3.1%). library/std.md is 26,437 tokens. Corresponding o200k groups are 8,552 / 63,497 / 72,049; qwen2.5 groups are 8,768 / 64,821 / 73,589. AIR remains 179,282 bytes / 19 files / 51 sections; its source-bundle copy remains 46,300 / 46,451 / 47,800 tokens. Cumulative cl100k growth over pre-std 33,981 is +111.3%, justified for owner review by visible byte syntax, cancellation/root, range/capacity and authority contracts. Quick Reference is beyond its 4–6k target; front-door consolidation/selective reading remains separate work. No new syntax, diagnostic or verifier/runtime state is added, and no empirical MCC improvement is claimed.
## Validation result
All 1079 repository conformance cases pass, including 18 path fixtures. The independent Python forward-stack oracle covers 132 paths with queries/idempotence and every short/exact/extra output capacity, 49 joins and four malformed pairs. All 255 non-NUL bytes are additionally tested. Fixtures cover one-byte canceled outputs, late malformed input winning over short capacity (including ignored base), suffix/guard preservation, raw ranges, no borrowed-return inference, disjoint same-allocation slices, aliases, task loans, wrong types/imports and independent filesystem authority. Reused ranges retain normal runtime bounds checks, with T0008 on a shorter unrelated path.
68 CLI/source/AIR/package/profile/provenance/audit checks pass. Pure APIs use no entry grants, heap allocation or unsafe sites. Lowered AIR and source agree; reordered imports/package loading/name collisions are deterministic. Hosted cases cover arbitrary byte components and actual denied-file authority independently of normalization. Unit/Quick Reference, formatting, 117/117 source coverage constructs and reference generation pass. All 18 path fixtures pass the collection-before-every-step gate; scheduled fixtures pass 12 seeds under quanta 1, 2, 7 and their own quantum. The oracle batches preserve every vector/capacity while ending literal frames between batches, bounding collector roots. STD-7c and the intermediate STD-0..7 foundation are complete. STD-8 and Std 0.1 remain unfinished.