Skip to content

feat(core): Maji F# algebraic types — identity-preservation + projection-preservation + MessiahScore#1709

Merged
AceHack merged 4 commits intomainfrom
claim/task-maji-fsharp-types
May 6, 2026
Merged

feat(core): Maji F# algebraic types — identity-preservation + projection-preservation + MessiahScore#1709
AceHack merged 4 commits intomainfrom
claim/task-maji-fsharp-types

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented May 6, 2026

Summary

F# algebraic types per Amara's Maji formal operational model. Types + basic operators + 8 passing tests.

  • IdentitySubstrate / IdentityTuple / MajiIndex / MajiFinder / MessiahFunction / MessiahScore / MajiMode
  • identityDistance: weighted Jaccard metric across identity-tuple components
  • projectionPreserved: P_{n+1→n}(I_{n+1}) ≈ I_n check
  • computeScore: MessiahScore with capture-risk + collapse-risk subtracted (anti-cult-by-construction)

Test plan

  • dotnet test --filter Maji — 8/8 pass
  • dotnet build -c Release — 0 warnings, 0 errors

🤖 Generated with Claude Code

AceHack and others added 3 commits May 6, 2026 10:38
…del — identity-preservation + projection-preservation + MessiahScore

Types per docs/research/maji-formal-operational-model-amara-courier-ferry-2026-04-26.md §10:
- IdentitySubstrate (§10.A): load-bearing substrate item with commit hash, provenance, confidence
- IdentityTuple (§2): canonical identity-pattern (Values/Goals/Roles/Policies/MemoryGraph/CorrectionHistory/CrossRefTopology/Provenance)
- MajiIndex (§10.B): exhaustive lower-dimensional index with coverage score + broken-ref detection
- MajiFinder (§10.B'): search/recognizer operator per §9b separation (Maji finds; Messiah is the found lift)
- MessiahFunction (§10.B'): the identity-preserving lift σ : I_n → I_{n+1} — SEPARATE TYPE from MajiIndex per §9b correction
- MessiahScore (§10.B'): weighted evaluator with capture-risk + collapse-risk SUBTRACTED (anti-cult-by-construction per Otto-294)
- MajiMode (dynamic 4th refinement): Search / Steward / SearchAgain state machine
- IdentityDistanceWeights + identityDistance: weighted Jaccard metric per §10.D
- projectionPreserved: d(P_{n+1→n}(I_{n+1}), I_n) ≤ ε check per §9b projection-preservation invariant

8 tests (all pass):
- Identity distance: identical=0, disjoint=1
- Projection-preservation: within-epsilon=true, drifted=false
- MessiahScore: capture-risk subtracts, collapse-risk subtracts (negative score when risk high)
- MajiMode: three constructors
- Empty index: zero coverage

Implementation owed: reload operator, MajiRecovery, MajiExpansion with expansion-gate + lemma-ladder, MajiNorthStar, dimensional-expansion math, aperiodic-order detector. This commit is types + basic operators only.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 6, 2026 14:41
@AceHack AceHack enabled auto-merge (squash) May 6, 2026 14:43
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 67ce8218bc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Core/Maji.fs
Comment thread src/Core/Maji.fs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Zeta.Core.Maji module defining “Maji” identity-preservation algebraic types plus initial scoring/distance operators, and wires it into the Core + F# test projects.

Changes:

  • Add src/Core/Maji.fs with Maji domain types (IdentityTuple, MajiIndex, MessiahScore, etc.) and helper operators (computeScore, identityDistance, projectionPreserved).
  • Add new xUnit tests covering identity distance, projection preservation, score subtraction behavior, and basic constructors.
  • Register the new source + test files in Core.fsproj and Tests.FSharp.fsproj.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
tests/Tests.FSharp/Tests.FSharp.fsproj Adds the new Maji test file to the test project compile list (but currently violates the “Properties last” compile-order contract).
tests/Tests.FSharp/MajiTests.fs New xUnit tests for the Maji module (but currently doesn’t follow the suite’s naming/layout conventions).
src/Core/Maji.fs New core module with Maji algebraic types and initial scoring/distance/projection checks (includes some doc/convention drift to address).
src/Core/Core.fsproj Registers Maji.fs for compilation in the core library.

Comment thread tests/Tests.FSharp/Tests.FSharp.fsproj
Comment thread tests/Tests.FSharp/MajiTests.fs
Comment thread src/Core/Maji.fs Outdated
Comment thread src/Core/Maji.fs
Comment thread src/Core/Maji.fs Outdated
Comment thread src/Core/Maji.fs
Comment thread src/Core/Maji.fs
…rovenance weight

- Replace "Amara" persona name with "the deep-research peer" in source comments (role-ref discipline on code surface)
- Replace failwith with invalidArg for weight-count check (Result-over-exception per Core convention)
- Add Provenance component to IdentityDistanceWeights (was in IdentityTuple but missing from distance metric)
- Update tests for Provenance weight field

8/8 tests pass. Build clean.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@AceHack AceHack merged commit b943e78 into main May 6, 2026
25 of 26 checks passed
@AceHack AceHack deleted the claim/task-maji-fsharp-types branch May 6, 2026 14:52
@chatgpt-codex-connector
Copy link
Copy Markdown

💡 Codex Review

Zeta/src/Core/Maji.fs

Lines 134 to 136 in e094b7e

let identityDistance (w: IdentityDistanceWeights) (a: IdentityTuple) (b: IdentityTuple) : float =
w.Values * jaccard a.Values b.Values
+ w.Goals * jaccard a.Goals b.Goals

P2 Badge Validate identity-distance weights are non-negative

identityDistance multiplies each component distance by caller-provided weights without any bounds check, so a misconfigured negative weight can make the total distance negative. That breaks the metric assumption and can cause projectionPreserved to return true for clearly drifted identities (for example, disjoint tuples with Values = -1.0 and epsilon = 0.0), which can silently admit invalid expansions in experiments.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants