Programming Language

Nocter

A self-contained systems language built around simplicity, encapsulation, and foolproof design.

/development/docs/v0.2.0.md

Nocter v0.2.0 Development Contract

Purpose

v0.2.0 makes variable-length data safe to own in Nocter and exposes the same semantic information to editors. At completion, String and Vec<T> are practical APIs built on a shared Allocator and ownership foundation rather than demonstration-only implementations.

This document is the sole definition of the v0.2.0 milestone. Because v0 is ambiguous, it is not used as shorthand for a release name. Past releases remain in Git and release metadata rather than being mixed into the current design documents.

The release is 0.2.0 for arm64-darwin. Public language rules follow the specification.

Completion Definition

v0.2.0 is complete only when all four areas below are satisfied.

1. Allocator

  • Layout centralizes size, alignment, overflow, and zero-sized allocation rules.
  • Allocation, growth, and deallocation use one Allocator contract; String and Vec<T> do not call OS page primitives directly.
  • Growth allocates and transfers content before freeing the old region. Failure preserves the old value.
  • RawBuffer retains allocator provenance and actual allocation layout, and invalid values cannot be constructed through public APIs.
  • Runtime tests fix capacity arithmetic overflow, excessive alignment, allocation failure, and freeing empty values.
  • Allocators are passed explicitly; v0.2.0 does not introduce an implicit global allocator.

See Allocator and Ownership.

2. Ownership and Destruction

  • Recursive partial-initialization state is representable for structs, fixed arrays, and payload enums.
  • A fixed array tracks its completed prefix separately from the current element under construction. If nested initialization of that element fails, acquired resources are destroyed exactly once in reverse order.
  • Vec<T> owns [0, len) and drops non-copy elements in reverse order.
  • push publishes len only after element construction; clear and drop destroy every element exactly once.
  • pop transfers ownership of the final element to its return value and shrinks the vector-owned range by one.
  • Normal return, early ?, branches, loop exits, replacement, and partial-initialization failure all apply the same drop rules.
  • Unsupported ownership shapes receive a source-backed diagnostic before reaching IR or backend.

3. Standard Library Runtime

  • String empty, from/copy, reserve, push, clear, view, and drop work on the shared Allocator.
  • Vec<T> empty, with_capacity, from_slice, reserve, push, pop, clear, view, and drop work for copy and non-copy elements where defined.
  • Build/run tests cover at least Vec<String>, Vec<File>, and Vec<Vec<String>> across growth, early return, clear, and scope exit without double-free, leaks, or use-after-move.
  • The packaged .nocter/std and repository-local development/std expose the same behavior.
  • Runtime primitives remain inside the narrow pub(nocter) trust boundary; ordinary APIs are not compiler-name special cases.

See Standard Library.

4. LSP

  • Diagnostics, semantic tokens, definition, references, and document symbols use the same compile-unit facts for open documents and imports.
  • Hover returns declaration kind, complete type or signature, generic specialization, documentation, and ownership capability with a source-backed range.
  • Completion distinguishes global, local, import, member, enum-pattern, struct-field, and keyword contexts and filters candidates by type, visibility, and position. Candidates include kind, detail, and required insertion text.
  • Signature help at call positions returns parameters, active parameter, return type, and documentation.
  • Incomplete source does not crash the server; hover and completion recover where semantic facts can still be established.
  • The LSP does not reimplement name resolution, type inference, visibility, or ownership.

See LSP.

Acceptance Programs

Release qualification includes distributed-home scenarios, not only focused unit tests:

  1. 1. Grow Vec<String> from empty, reserve multiple times, pop a string, and use it after vector drop.
  2. Clear a Vec<File> partway through and close any remainder at scope exit; every handle closes exactly once on failure paths as well.
  3. Construct Vec<Vec<String>> and verify both normal completion and recovery of inner values after failed growth.
  4. Grow String from empty repeatedly, verify its view, clear it, and reuse it.
  5. Fix JSON-RPC diagnostics, hover, completion, and signature-help responses for a multi-file standard-library program.

Explicit Non-goals

The following are not v0.2.0 completion criteria, and temporary implementations that damage the foundation are not accepted:

  • collection literals, map literals, and ... spread or variadic syntax
  • implicit allocator selection for string interpolation
  • interface runtime dispatch and embedding
  • remove ownership extraction from an arbitrary vector index and sparse live-element tracking
  • an implicit default allocator or multiple public allocator families
  • a workspace-wide package index, rename, code actions, or formatting requests
  • native backends other than arm64-darwin

pop is included because it only shrinks the tail prefix. Arbitrary remove requires a separately designed sparse ownership state.

Work Order

The dependency order and completion state are:

  1. 1. Add fixed-array current-element staging to recursive drop obligations. (complete)
  2. Complete Layout, RawBuffer, and Allocator allocate/grow/free contracts. (complete)
  3. Implement initialized-prefix ownership and non-copy push/clear/drop for Vec<T>. (complete)
  4. Implement Vec<T>.pop as ownership transfer. (complete)
  5. Move String to the shared Allocator and fix growth-failure invariants. (complete)
  6. Integrate hover with the stable typecheck-fact presentation model. (complete)
  7. Add context-aware completion and signature help to compiler analysis. (complete)
  8. Pass distributed-home acceptance and all verification with no unresolved required documentation. (complete)

Release Gate

Stable version and release metadata require all of:

  • ./development/compiler/scripts/verify.sh
  • cargo fmt --manifest-path development/compiler/Cargo.toml --check
  • git diff --check
  • build/run/LSP integration tests for the acceptance programs above
  • no unresolved required v0.2.0 item in development/docs/ or development/TODO.md
  • a distribution generated by package-local-release.sh and reverified using only its .nocter home

All gates passed for the v0.2.0 release commit.