Implement M6.5c persisted environmental community and bounded writers

This commit is contained in:
dingo
2026-09-27 13:07:35 -04:00
parent e9ea388cef
commit 364c090bc8
16 changed files with 970 additions and 42 deletions
+24 -9
View File
@@ -1,13 +1,13 @@
# M6.5 environmental process contract v1
Authority: ADR-0055, ADR-0054, environmental units (ADR-0050), and the scoped
producer/feeding rules (ADRs 0025/0026). **Specified, not implemented.** M6.5b is a
contract segment. M6.5c must implement this contract and the complete buffer codec
before advance is enabled. Coefficients below are fixture inputs, not game rules.
producer/feeding rules (ADRs 0025/0026). **Implemented in M6.5c; broader qualification remains M6.5d.** M6.5b is a
contract segment. M6.5c implements the runtime and complete buffer codec together.
Coefficients below are fixture inputs, not game rules.
## Ownership and interface boundary
One `EnvironmentalCommunity` (working name) owns one coupled resource owner,
One `EnvironmentalCommunity` owns one coupled resource owner,
immutable configuration, progress and process retry receipts. Admission supports
one habitat site and exactly two sorted nonzero actor IDs. Producer and consumer
are configured capabilities, not inheritance classes or permanent species.
@@ -19,13 +19,13 @@ Require all ten fields present, valid material binding and capacities, and a fre
resource owner (command/adoption watermark zero and no history). Reject adopting a
previously advanced independent resource owner: migration is not implied.
Conceptual API, to be finalized with callers/tests in M6.5c:
Public API in `include/evo/processes/environmental_community.hpp`:
- create(config, exclusively owned resources, total peak byte budget) -> expected owner;
- advance(exact next tick, immutable tick input) -> expected report;
- snapshot() -> complete canonical process envelope;
- restore(bytes, expected world, budgets) -> detached validated owner;
- inspect() -> read-only values/views, invalidated at publication.
- resources()/progress() -> read-only resource access and copied progress; views require freshness validation.
No mutable resource getter, user-supplied resource delta, commit callback, external
credit/debit or independent process-state setter. Host access is single-writer.
@@ -39,7 +39,7 @@ sequenceDiagram
participant C as Detached candidate
H->>P: exact tick + bounded input
P->>P: resolve retained exact retry or reject conflict
P->>C: clone complete owned state within peak budget
P->>C: stage scalar balances and progress within peak budget
C->>C: capture then growth then feeding
C->>C: validate conservation, capacity, progress and report
P->>P: publish resources + progress + retry history (noexcept)
@@ -173,8 +173,7 @@ history order/count, latest tick, endpoint/rules references, residual bounds and
resource checkpoint watermark. Reject a bare resource snapshot as a process snapshot.
Do not synthesize absent source or lifecycle state from defaults.
M6.5c must define exact byte fields, bounds and malformed-input validation before
exposing advance. Nothing here grants restart fencing, durable ACKs, disk publication
M6.5c defines exact byte fields and validation in [the envelope schema](../../schemas/environmental-community.md). Nothing here grants restart fencing, durable ACKs, disk publication
or host-loss recovery; those remain M7/M8.
## Hand-checkable acceptance vectors
@@ -199,3 +198,19 @@ zero efficiency, all capacity/overflow bounds, exact retry after restore, more t
64 ticks, malformed snapshots, deterministic seeded input streams and independent
per-channel accounting. No stochastic fairness or RNG is required in the engine;
seeded test drivers record their full input sequence.
## M6.5c implementation detail
For one site, field channels are uniform scalars. Stage all 30 balances, progress,
report and the historical audit anchor in bounded arrays. A private world checkpoint
validates conserved totals and capacities then replaces baselines without allocation;
process progress/history publish immediately afterward without throwing. Terrain is
unchanged. There is no full terrain clone or codec round trip in advance. This refines
the initial cloning baseline above while retaining detached candidate semantics.
Restore replays the 64-tick receipt window from a persisted historical anchor and
compares all reports and final state. The anchor is not spendable. The consumer is
always active in rules v1 (no consumer-death operation exists); producer terminal
state is serialized explicitly. Frame/site, account IDs, source identity and primitive
rate config come from the complete envelope, never missing-state defaults.