Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ The trust-gradient coordination policy IS Agora V6's Integrate-as-choice-locus d

The Agora V6 operational primitives compose at distributed-coordination scope.

### For the existing CRDT substrate (`src/Core/Crdt/*`)
### For the existing CRDT substrate (`src/Core/Crdt.fs`)

The CRDT substrate IS the algebra tier (no consensus). The trust-gradient coordination policy gives the architectural framing for when CRDTs are sufficient vs when escalation is needed:

Expand Down Expand Up @@ -220,7 +220,7 @@ The CRDT substrate IS the algebra tier (no consensus). The trust-gradient coordi
- B-0683 (tier-deferred causality) — facts can be in superposition of coordination tiers
- B-0687 (ZetaParse) — parser substrate stays at algebra tier (local DBSP retraction)
- B-0688 (incremental compiler host) — full trust-gradient operates at compiler-fact-emission scope
- `src/Core/Crdt/*` (existing CRDT substrate) — algebra tier; trust-gradient gives the framing for when escalation is needed
- `src/Core/Crdt.fs` (existing CRDT substrate) — algebra tier; trust-gradient gives the framing for when escalation is needed
- `src/Core/Consensus.fs` (existing consensus substrate; if exists) — CASPaxos/CASRaft tier substrate
- Earlier Amara persona substrate cluster + Kestrel persona substrate cluster

Expand Down
33 changes: 33 additions & 0 deletions src/Core.FSharp.ZetaId/Codec.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,39 @@ module ZetaIdCodec =
validateEnumField (byte obs.Category) 4 "Category"
validateEnumField (byte obs.Firefly) 1 "Firefly"

// Re-validate Authority.Raw / Momentum.Raw at Pack time. F# DU cases
// are inherently public — callers can construct `Authority.Raw 31` directly,
// bypassing `Authority.raw` smart-constructor validation. Pack re-checks
// for named-case collision + Authority bounds. C# achieves the equivalent
// via sealed-record private setter; F# achieves it via re-validation here.
// Per Copilot + Codex post-merge thread on PR #4548.
match obs.Authority with
| Authority.Raw v ->
if v > 31uy then
raise (System.ArgumentOutOfRangeException(
"obs", v :> obj,
Comment on lines +56 to +60
sprintf "ZetaObservation.Authority = Authority.Raw(%d) exceeds 5-bit Authority field (0..31). Use Authority.raw smart constructor (rejects this at construction) or named case." v))
if v = byte AuthorityValue.HumanVerified
|| v = byte AuthorityValue.TrustedAgent
|| v = byte AuthorityValue.Standard
|| v = byte AuthorityValue.BestEffort
|| v = byte AuthorityValue.Simulated then
raise (System.ArgumentOutOfRangeException(
"obs", v :> obj,
sprintf "ZetaObservation.Authority = Authority.Raw(%d) aliases a named case (round-trip unstable). Use the named Authority case directly, or Authority.raw smart constructor (rejects this at construction)." v))
| _ -> ()
match obs.Momentum with
| Momentum.Raw v ->
if v = byte MomentumValue.Background
|| v = byte MomentumValue.Normal
|| v = byte MomentumValue.Elevated
|| v = byte MomentumValue.High
|| v = byte MomentumValue.Critical then
raise (System.ArgumentOutOfRangeException(
"obs", v :> obj,
sprintf "ZetaObservation.Momentum = Momentum.Raw(%d) aliases a named case (round-trip unstable). Use the named Momentum case directly, or Momentum.raw smart constructor (rejects this at construction)." v))
| _ -> ()

let mutable id = System.UInt128.Zero
id <- setBits id layout.Version (uint64 (byte obs.Version))
id <- setBits id layout.Timestamp (uint64 obs.Timestamp)
Expand Down
2 changes: 1 addition & 1 deletion src/Core.FSharp.ZetaId/Types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Persona =

/// Location field — 8 bits. Mirrors `src/Core.CSharp.ZetaId/Location.cs`.
/// Codes 1-11 cover major regions across AWS / GCP / Azure / DigitalOcean.
/// Backlog (Aaron 2026-05-21): registry/locations.yaml + provider-specific
/// Backlog (human maintainer 2026-05-21): registry/locations.yaml + provider-specific
/// mapping layer ships in a separate follow-up PR.
type Location =
| EastUsVa = 1uy // AWS us-east-1, Azure East US, GCP us-east4
Expand Down
3 changes: 2 additions & 1 deletion tests/Tests.FSharp/ZetaId/CrossVerifyTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ let ``cross-verify twelve vectors match TS+C# bootstrap hex`` () =
if not roundtripOk then roundtripMismatches <- roundtripMismatches + 1
if not matchesExpected then hexMismatches <- hexMismatches + 1

let outputPath = Path.Join(root, "tests", "cross-verification", "zeta-id", "fs-output.json")
// compare.ts reads `fsharp-output.json` (not `fs-output.json`) — match per Copilot #4548 thread
let outputPath = Path.Join(root, "tests", "cross-verification", "zeta-id", "fsharp-output.json")
let options = JsonSerializerOptions(WriteIndented = true)
let json = JsonSerializer.Serialize(results, options)
File.WriteAllText(outputPath, json)
Expand Down
Loading