Skip to content

spec(pkg): default personal-knowledge-graph structure (the seed to build over)#13

Merged
mdheller merged 13 commits into
mainfrom
personal-knowledge-graph-spec
Jul 4, 2026
Merged

spec(pkg): default personal-knowledge-graph structure (the seed to build over)#13
mdheller merged 13 commits into
mainfrom
personal-knowledge-graph-spec

Conversation

@mdheller

@mdheller mdheller commented Jul 1, 2026

Copy link
Copy Markdown
Member

The default ego-centric graph a person starts with — the seed the Memory Steward grows over. Not a new store: a schema over HellGraph (NodeAtom + AssertionClass + required provenance + SHACL), scoped by memory-scope.yaml, populated by prophet-workspace, and the per-person graph the mesh grounds on.

Maps the diagram directly:

  • NodesSelf (single anchor) · Person (Mom, Jamie, "Mom's dentist") · Place (Hometown) · Organization (High school) · Thing (Electric/Acoustic guitar) · Interest · Event · Document · Communication · Account.
  • Solid edges — typed relations: relatedTo/knows/homeTown/attended/owns/interestedIn/providerFor/participatedIn/authored/communicatedWith/hasAccount.
  • Dashed edges — the external-link contract: sameAs → {general_purpose (Wikidata/KKO), social_network, domain_specific, ecommerce_catalog} with direction: reference_onlyprivacy invariant: the PKG reads external KGs for grounding, never leaks private data outward (the digital-soul boundary). confidence + trust_class + provenance required.

Every node/edge carries provenance + epistemic mode + P-RET/P-GEN + I-DED/IND/ABD + memory_scope + confidence — the same axes as the grounding-fidelity moat, so the PKG is provenance-native.

Seed = the Self node + registered external KGs + empty typed slots; prophet-workspace ingestion (contacts→Person, calendar→Event, mail→communicatedWith, drive→Document) fills them. Rule #0: exam/holdout content is never ingested (no contamination via retrieval).

mdheller added 7 commits June 28, 2026 19:13
Canonical contract and runtime engine for the 2026 reframing of Gartner's
"Applying AI to the Development Process": the build-AI ladder becomes the
platform stack, the AI-autonomy ladder becomes the governed Agent Choir, and
a third axis (governed autonomy) gates every rung through the trust kernel.

- specs/ai-driven-development.yaml — the canonical L0..L5 ladder, build-ladder
  -> layer map, per-level gate + enforced_at repo, and IBM-PE layering analogy.
- autonomy.py — validator + fail-closed gate engine. evaluate_autonomy()
  authorizes by role ceiling then admits by evidence, demoting toward L0.
- cli: validate-ai-driven-development, evaluate-autonomy.
- 6 tests; full suite passes.
Add export-autonomy-ladder CLI + canonical_ladder() that derives a
machine-readable ladder (specs/ai-driven-development.ladder.json) from the
spec. This is the single source downstream repos (tritfabric, prophet-platform,
Noetica) derive from / verify against instead of hand-mirroring the YAML. A
drift test asserts the committed export matches the spec.
…ild over)

The ego-centric graph a person starts with, that the Memory Steward grows.
Schema over HellGraph (NodeAtom + AssertionClass{Structural/Assertion/Executable}
+ required provenance + SHACL), scoped by memory-scope.yaml, populated by
prophet-workspace (contacts/calendar/mail/drive), and the per-person graph the
mesh grounds on.

- node_types: Self(anchor) · Person · Place · Organization · Thing · Interest ·
  Event · Document · Communication · Account
- edge_types: relatedTo/knows/homeTown/attended/worksAt/owns/interestedIn/
  providerFor/participatedIn/authored/communicatedWith/hasAccount
- external_link contract (the dashed edges): sameAs → {general_purpose, social,
  domain_specific, ecommerce}, direction=reference_only (privacy: read external,
  never leak), confidence + trust_class + provenance required
- every node/edge carries provenance + epistemic_mode + P-RET/P-GEN +
  I-DED/IND/ABD + memory_scope + confidence (ties to the grounding-fidelity moat)
- seed = Self + registered external KGs + empty typed slots
- Rule #0: exam/holdout NEVER ingested (no contamination via retrieval)
Makes the default person-graph buildable-over, reading the spec vocabulary:
- seed_graph(self_id) → the Self anchor (Structural) + registered external KGs.
- ingestion: ingest_contact (family→relatedTo / social→knows), ingest_event
  (→participatedIn), ingest_message (→communicatedWith), ingest_document
  (→authored) — every element carries workspace provenance.
- link_external → reference-only external-KG link (privacy: read, never leak).
- validate() = SHACL-lite: node types + relations in the spec vocabulary, single
  Self invariant, external KG known, provenance.source required on every element.
Brain-agnostic (data model; the mesh grounds on it, memory-steward owns it). 5/5 tests.
Persist and populate the Personal Knowledge Graph on real substrate:

pkg_hellgraph.py — projects a PKG into HellGraph's canonical wire shape
(GraphNode {id,labels,properties,createdAt} + GraphEdge with the mandatory
epistemic fields epistemicClass/confidence/promotionState/createdAt). Maps PKG
inference/method → EpistemicClass (workspace imports = confirmed_relation/
confirmed, labelled inferences = inferred_relation/candidate); external links
stay reference_only in properties. Emits to the TS HellGraphStore façade; the
Rust kernel is untouched (external writers go through the TS projection).

pkg_workspace.py — adapters over the real workspace contracts: contact.schema
(→ Person + worksAt Organization + social sameAs), calendar-event.schema
(→ Event + participatedIn for Self and attendees-with-contactRef),
mail-message.schema (→ communicatedWith from the correspondent), office-artifact
.schema (→ Document + authored). sourceAdapter/accountRef/timestamps flow into
provenance; ingest_workspace() batches a whole export in dependency order so
mail/calendar edges resolve onto Person nodes from contacts (no dup).

15 PKG tests pass (5 spec/builder + 5 writer + 5 adapters).
Non-invasive EmittingPKG wrapper dual-writes every add_node/add_edge as a
sourceos-spec v2 EventEnvelope onto an append-only hash-linked log (Fig-18
railroad track). Causal + locus/attestation metadata rides in the open payload;
no schema change, pkg.py untouched. Includes deterministic fold() round-trip and
verify_chain() tamper check. Emit-only — merge is Slice 3, gate is Slice 4.
5 new tests; full suite 65 green.
@mdheller

mdheller commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

Added: CRDT Slice 1 — EventEnvelope op-emitter (8da919b)

Non-invasive EmittingPKG wrapper that dual-writes every add_node/add_edge as a sourceos-spec v2 EventEnvelope onto an append-only, hash-linked op-log (the Figure-18 "railroad track"). Emit-only — no merge yet (merge is Slice 3, the locus/attestation gate is Slice 4).

  • src/prophet_mesh/pkg_ops.pyOpLog (hash chain) + EmittingPKG (wraps PKG, untouched) + fold() (deterministic rebuild from log) + verify_chain() (tamper check)
  • Causal + locus/attestationRef metadata rides in the open payloadno schema change
  • tests/test_pkg_ops.py — 5 tests (envelope conformance, causal order, hash chain, tamper detection, fold round-trip). Full suite 65 green.

Design doc: SourceOS-Linux/sourceos-spec#130.

materialize(): deterministic add-wins OR-Set fold with observed-remove retracts +
LWW(lamport,eventId) value resolution — order-independent reconstruction from a log.
merge(): dedup-by-eventId union of replicas' logs; commutative/associative/idempotent
→ strong eventual consistency, zero coordination. Closes local-first ideals 2 (multi-
device) + 4 (collaboration) without touching 5/6/7. Adds retract_node/edge (observed-
remove) + apply_remote (ingest without re-emit) to EmittingPKG.

9 new tests: commutativity, associativity, idempotence, offline convergence, random-
shuffle order-independence, add-wins-over-concurrent-retract, retract-wins. Suite 74 green.
@mdheller

mdheller commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

Added: CRDT Slice 2/3 — reconstruct + converge (687f5f4)

The load-bearing slice — offline replicas now converge, closing local-first ideals 2 (multi-device) and 4 (collaboration) without touching 5/6/7.

  • materialize() — deterministic add-wins OR-Set fold with observed-remove retracts + LWW(lamport, eventId) value resolution. Order-independent reconstruction from a log (Slice 2 supersedes the Slice-1 fold, kept as an alias).
  • merge() — dedup-by-eventId union of replicas' logs; commutative / associative / idempotent → strong eventual consistency, zero coordination (Slice 3).
  • EmittingPKG.retract_node/edge (observed-remove) + apply_remote (ingest a remote op without re-emitting).

9 new tests (14 CRDT total): commutativity, associativity, idempotence, offline convergence, random-shuffle order-independence, add-wins-over-concurrent-retract, retract-wins. Full suite 74 green.

Remaining per design (SourceOS-Linux/sourceos-spec#130 §8): Slice 4 = locus/attestation merge gate (canonical vs. quarantine), Slice 5 = live second-replica ingester.

…ss moat)

gate() splits a converged op-log into a canonical view (ops from local/trusted_private,
or attested_fog/burst_cloud WITH a passing correctness receipt) vs. a quarantine view
(everything else, retained not authoritative). Fail-closed: unattested gated-locus ops
are quarantined, so an untrusted retract cannot silently delete canonical data. Emits a
SyncCycleReceipt-shaped receipt per cycle. This is where TEE-confidentiality ends and
correctness-attestation begins — the moat, made executable.

7 tests incl. fail-closed admission, attested-admit, the untrusted-retract security
property, longevity (nothing lost), and SyncCycleReceipt v2 conformance. Suite 81 green.
@mdheller

mdheller commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Added: CRDT Slice 4 — locus/attestation merge gate (d2608a2)

Where the correctness moat becomes executable. Slices 1–3 converge everything; Slice 4 decides which converged sub-graph is authoritative — the layer TEE/confidentiality cannot provide.

  • gate() splits a converged op-log into a canonical view (ops from local/trusted_private, or attested_fog/burst_cloud with a passing correctness receipt) vs. a quarantine view (everything else — retained, not authoritative).
  • Fail-closed: an unattested gated-locus op is quarantined by default (deny_all resolver). Consequently an untrusted retract cannot silently delete canonical data — verified by test_untrusted_retract_cannot_delete_canonical_data.
  • Emits a SyncCycleReceipt-shaped receipt per cycle (conformance-tested against sourceos-spec v2: allowed-keys ⊆, required ⊇, URN/enum patterns).

7 tests (21 CRDT total): fail-closed admission, attested-admit, the retract security property, longevity (nothing lost), receipt conformance, outcome/policyGate logic. Full suite 81 green.

Slices 1–4 of the design (SourceOS-Linux/sourceos-spec#130 §8) now landed. Only Slice 5 (live second-replica ingester) remains — everything below it is real and tested.

…complete)

Replica: a live device/agent that syncs with peers by anti-entropy (exchange only
missing ops), converging two live participants with no coordinator. sync() is
bidirectional + idempotent; Lamport advances on receive so later local edits win.

replay_to_hellgraph(): the ingester the writer promised but never had (gap #4) —
replays a materialized PKG through a HellGraphStore-shaped sink (addNode/addEdge),
idempotent via content-addressing. persist_canonical() composes it with the Slice-4
gate so ONLY the proven-correct sub-graph reaches the store; unattested cloud ops
converge into every log (longevity) but are never persisted.

6 tests: live convergence, sync idempotence, post-sync propagation, replay +
idempotent replay, and the end-to-end 'only canonical graph reaches HellGraph'.
Suite 87 green. All 5 CRDT slices landed.
@mdheller

mdheller commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Added: CRDT Slice 5 — live replicas + HellGraph ingester (54be26c) — design complete

The last slice. Slices 1–4 were pure functions over logs; Slice 5 makes them live and persistent.

  • Replica — a device/agent that syncs with peers by anti-entropy (exchange only missing ops), converging two live participants with no coordinator. sync() is bidirectional + idempotent; Lamport advances on receive so later local edits win.
  • replay_to_hellgraph() — the ingester pkg_hellgraph.to_hellgraph() always promised but never had (gap Seed AI Forensics Corpora manifest rows #4): replays a materialized PKG through a HellGraphStore-shaped sink (addNode/addEdge), idempotent via content-addressing. The op-log is no longer emit-only.
  • persist_canonical() composes Slice 4 + 5: gate the converged log, then replay only the canonical (proven-correct) graph to HellGraph. Unattested cloud ops converge into every replica's log (longevity) but never reach the store — verified by test_only_gated_canonical_graph_reaches_the_store.

6 tests (27 CRDT total). Full suite 87 green.

All 5 slices landed (SourceOS-Linux/sourceos-spec#130 §8)

emit → reconstruct → converge → correctness-gate → live-sync + persist-proven-only

Local-first ideals 2 (multi-device) and 4 (collaboration) are now tested capabilities, the eighth ideal (correctness) is executable (gate), and the whole thing lands on the real HellGraph substrate. Ready for review.

mdheller added 2 commits July 4, 2026 12:37
The test job (ruff check src tests) was red: 4 unused imports (F401) in
pkg_gate.py and the pkg tests, and 7 semicolon-joined statements (E702) in
pkg_ops.py and test_pkg_replica.py. Removed the unused imports and split the
compound statements onto their own lines. ruff clean + pytest green, no behaviour
change.
@mdheller mdheller merged commit 69bc21e into main Jul 4, 2026
5 checks passed
@mdheller mdheller deleted the personal-knowledge-graph-spec branch July 4, 2026 16:42
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.

1 participant