Section 7: Concurrency and Asynchronous Execution¶
TECHSPEC-07 — Section 7 · Version 0.1 · Status: Initial Draft
Status: draft. This section is an Initial Draft (Section 57 is a Working Register). It describes intended or proposed behavior, not a finalized, implemented language rule. Do not treat examples here as normative.
1. Concurrency Philosophy¶
Concurrency must be explicit and controlled.
The language must prevent data races, unsafe shared mutation, and unmanaged asynchronous operations wherever possible.
2. Asynchronous Functions¶
The language supports asynchronous functions using ASYNC.
Example:
ASYNC FUNCTION fetchAccount(
id: Integer
) -> Result<Account, NetworkError>
EFFECTS:
NETWORK
IMPLEMENTATION:
LET response = AWAIT HTTP.GET("/accounts/" + id)
RETURN PARSE(response)
END FUNCTION
Rules: - Asynchronous functions must be explicitly declared. - Asynchronous calls must be explicitly awaited or transferred to a managed task. - Possible failures must be handled. - Task cancellation must have defined behavior. - Unfinished tasks must not be silently abandoned.
3. Parallel Execution¶
The language supports explicit parallel execution.
Example:
PARALLEL:
LET accountA = AWAIT fetchAccount(100)
LET accountB = AWAIT fetchAccount(200)
END PARALLEL
Rules: - Parallel operations must have independent or safely coordinated state access. - Conflicting mutable access must be rejected. - Each operation must declare its effects. - Execution order must not be assumed unless explicitly guaranteed.
4. Shared State¶
Shared mutable state requires controlled access.
The language will support: - Immutable shared data. - Explicit locks. - Atomic operations. - Message passing. - Channels.
Rules: - Shared mutable state cannot be accessed without an approved synchronization mechanism. - Locks must have defined ownership and lifetimes. - Atomic operations must specify their supported guarantees. - Message passing must respect declared message types.
5. Task Management¶
- Every task must have a defined owner.
- Task lifetimes must be managed.
- Cancellation must be explicit.
- Task failures must be observable.
- Parent tasks must account for child task completion or cancellation.
- Detached tasks require explicit authorization and lifecycle management.
6. Determinism¶
- Sequential execution must have defined ordering.
- Parallel execution may be nondeterministic unless ordering is explicitly enforced.
- Operations requiring a specific order must declare that requirement.
- Reproducible execution should be supported where practical.
7. Compiler Responsibilities¶
The compiler must: - Detect conflicting mutable access. - Enforce ownership rules across tasks. - Validate asynchronous calls. - Detect unhandled task failures. - Enforce task lifecycle rules. - Identify potentially unsafe synchronization patterns.
The compiler should detect obvious deadlock risks, but must not claim that all possible deadlocks can be detected.
8. Design Goal¶
AI agents must be able to create concurrent software without accidentally introducing data races, uncontrolled shared state, forgotten tasks, or unhandled asynchronous failures.
Source and related sections¶
Source file: TECHSPEC-7.md (preserved in source-original/LANG/). See the specification index, the glossary, and the cross-reference index.