Case file

KNOWX · 00

Introduction

Building KnowX as a Memorix Agent Pack

Audience: Developers implementing the first-party KnowX agent — vocabulary, services, and pipeline.
Twin: Builders version
Scenario: Fresh sandbox* · install ops then knowx · agentIds: ["knowx"] (inherits ops).
Packages: @x12i/memorix-knowx-pack, @x12i/memorix-ops-pack, @x12i/memorix-service, @x12i/memorix-pipeline, @x12i/memorix-format, @x12i/memorix-relationships.
Prerequisites: Agent packs · Services · Pipelines · Format.
Site: https://ebooks.memorix.x12i.com · Hard rules
Status: Present-tense tutorial for the shipped @x12i/memorix-knowx-pack. Deterministic fixture stubs — no live AI required. Replace stubs with real service bodies using the Memorix contracts in §B.


Case file

KNOWX · 00

How to read this tutorial

Work in authoring order: A vocabulary → B services → C pipeline → D install & run.

  1. KnowX is a content type (knowx) plus a first-party agent pack — not a siloed graph engine.
  2. Agent knowx is a child of ops. Scope with agentIds: ["knowx"] so inheritance collapses ops + knowx.
  3. Three ordinary Memorix services extract and associate; they do not persist.
  4. Pipeline knowx-ingest-associate persists via write-record and relationship-write.
  5. When your service implementations return contract-shaped outputs, KnowX works end-to-end.
  6. Provenance is mandatory; epistemic.state ≠ extraction confidence.
  7. Four-field RelationshipLinks only — no associated*, no abstract collections.

Labels: Stored subject content · Virtual abstract projection · Operational run ledgers.


Case file

KNOWX · 00

The central mental model

text + knowledgeSource
  → knowx-extract          (drafts only)
  → write-record knowx     (knowledge added)
  → knowx-associate-knowledge
  → relationship-write     (known / supports / contradicts / derived-from)
  → knowx-associate-entities
  → relationship-write     (edge-from / edge-to)
flowchart LR
  Text[text plus knowledge source] --> Extract[knowx-extract]
  Extract --> Write[write-record knowx]
  Write --> AssocK[knowx-associate-knowledge]
  AssocK --> RelK[relationship-write knowledge links]
  RelK --> AssocE[knowx-associate-entities]
  AssocE --> RelE[relationship-write entity links]

Case file

KNOWX · 00

A — Vocabulary

A.1 Content type (platform-native)

memorix-format registers knowx and confirmations. Payload rules:

Layer Name Stored?
Content type knowx Yes
Discriminator data.kind: NODE | EDGE Inside .data
Abstract KnowXEntity Virtual only
Forbidden KnowXNode / KnowXEdge types or collections

A.2 Agent pack layout

Package: @x12i/memorix-knowx-pack

metadata/
  agents/knowx.json          # parentAgentId: ops
  abstract-types.json        # KnowXEntity (+ People/WorkItems restated for standalone validate)
  abstract-bindings.json     # knowx-entity-union
  object-types.json          # employees/contractors/work-items overlays + assertions
  relationship-definitions.json
  services.json
  pipelines-and-sources.json
fixtures/knowx-activity-log.jsonl
src/knowx-services.ts        # deterministic stubs

Known pack id: knowxmemorix-metadata/examples/knowx/normalized/pack.json (explicit install only).

A.3 Object types

OT Role
employees / contractors / work-items Host OTs — knowx pack replaces ops defs to add CT knowx + KnowXEntity
assertions Claim subjects — CTs knowx (required), workflow, confirmations

NODE facets share the host recordId. EDGE claims get their own recordId on assertions.

A.4 Relationships

Id Classification / use
knowx-same-as known — matches existing claim
knowx-supports Reinforces existing
knowx-contradicts contradicts existing
knowx-derived-from Derived from another claim
knowx-edge-from EDGE → domain from-endpoint
knowx-edge-to EDGE → domain to-endpoint

Domain assignment links may still use ops people-assigned-to-work-items after human accept (operator flow).

A.5 Provenance (mandatory)

type SourceSpan =
  | { jsonPath: string }
  | { lineStart: number; lineEnd: number }
  | { byteStart: number; byteEnd: number };

type KnowxProvenance = {
  sourceClass: "measured" | "inferred" | "asserted" | "imported";
  sources: Array<{
    docId: string;
    docType: string;
    docHash: string; // sha-256 of exact source bytes
    span: SourceSpan;
    retrievedAt: string;
  }>;
  extraction: {
    method: string;
    extractorId: string;
    confidence: number; // ≠ epistemic.state
  };
};

Missing provenance ⇒ reject writes / fail the extract step.


Case file

KNOWX · 00

B — Service specs (Memorix contracts)

These are the Memorix-facing contracts. Implement real bodies against them; fixture stubs in @x12i/memorix-knowx-pack satisfy acceptance without live AI.

Shared rules for all three

  • Capability class: analyze (pipeline stepKind: "analyze").
  • Invocation: kind: "worker" + operation matching the service id.
  • Must not write Mongo, install metadata, or invent associated*.
  • Scope headers: orgId + agentIds (use ["knowx"]).
  • Fail closed: return structured errors the pipeline can surface.

B.1 knowx-extract

Role Turn text + knowledge source into KnowX drafts (NODE/EDGE), not yet classified.
serviceId knowx-extract
operation knowx-extract
Inputs text — string to analyze; knowledgeSource — exact bytes or Memory DataRef + envelope (docId, docType, retrievedAt)
Output knowxDrafts: KnowxDraft[] plus docHash of exact source bytes
Draft shape { objectType, contentType: "knowx", recordId, data } with data.kind, provenance, epistemic; EDGE also has data.refs.{from,to,predicate}
Errors MISSING_SOURCE, INVALID_SOURCE_BYTES, MISSING_PROVENANCE
Handoff Pipeline step write-knowx (write-record, contentType: "knowx") consumes knowxDrafts
Fixture stub extractKnowxFromActivityLog — parses fixtures/knowx-activity-log.jsonl → employee NODE, work-item NODE, ASSERTION-99 EDGE

B.2 knowx-associate-knowledge

Role Classify drafts against existing KnowX scope: known, novel, contradicts; emit knowledge relationship plans.
serviceId knowx-associate-knowledge
operation knowx-associate-knowledge
Inputs drafts — from extract (or already written knowx); existingKnowx — current contentType=knowx in scope
Output classification: { known[], novel[], contradicts[] }; relationshipPlans[]
Plan item { definitionId, from: { objectType, recordId }, to: { objectType, recordId }, reason? } where definitionIdknowx-same-as | knowx-supports | knowx-contradicts | knowx-derived-from
Errors MISSING_DRAFTS, INVALID_CLASSIFICATION
Handoff Step write-knowledge-links (relationship-write) consumes relationshipPlans
Fixture stub Same objectType+recordId → known + knowx-same-as; EDGE same endpoints different predicate → contradicts + knowx-contradicts; else novel

B.3 knowx-associate-entities

Role Associate novel KnowX (especially EDGE) to existing domain entities.
serviceId knowx-associate-entities
operation knowx-associate-entities
Inputs novelDrafts — from classification.novel (resolve full drafts); entityCatalog — available entity endpoints / abstracts
Output entityRelationshipPlans[] with definitionIdknowx-edge-from | knowx-edge-to (optional domain defs)
Errors MISSING_NOVEL, UNRESOLVED_ENDPOINT
Handoff Step write-entity-links (relationship-write) consumes entityRelationshipPlans
Fixture stub For each novel EDGE, emit plans from data.refs.from / data.refs.to

B.4 Swap stub → real implementation

  1. Keep the same serviceId / operation / output field names.
  2. Bind your worker in the pipeline PortHandler registry (same pattern as other analyze services).
  3. Return contract-shaped JSON; pipeline persist steps stay unchanged.
  4. Keep a deterministic path for acceptance (fixture or golden inputs).

Case file

KNOWX · 00

C — Pipeline `knowx-ingest-associate`

Step id kind Binding
extract analyze serviceId: knowx-extract
write-knowx write-record contentType: knowx
associate-knowledge analyze serviceId: knowx-associate-knowledge
write-knowledge-links relationship-write plans → knowledge defs
associate-entities analyze serviceId: knowx-associate-entities
write-entity-links relationship-write plans → edge-from/to

Optional later (operator-driven): workflow + confirmations before treating epistemic as fact; materialize domain links such as people-assigned-to-work-items.

Run evidence lives in the pipeline operational ledger — not in subject content.


Case file

KNOWX · 00

D — Install and sandbox run

# 1) Install parent ops, then knowx (never auto-install)
POST /api/metadata/install  { "packId": "ops", "confirm": true }
POST /api/metadata/install  { "packId": "knowx", "confirm": true }

# 2) Scope — child agent collapses ops inheritance
X-Memorix-Org-Id: sandbox…
X-Memorix-Agent-Ids: knowx

# 3) Start pipeline with text + knowledge source inputs
POST /api/pipelines/start
{ "pipelineId": "knowx-ingest-associate", … }

Isolation: fresh sandbox* org; beginIsolationSession({ agentIds: ["knowx"] }) when running KnowX acceptance. Default isolation remains ["ops"].

Package tests: cd memorix-knowx-pack && npm test.


Case file

KNOWX · 00

Human review (siblings)

On assertion recordId:

  • knowx — claim + provenance + epistemic
  • workflow — review assignment (PUT /api/workflow)
  • confirmations — accept/reject

Accepted EDGE → optional domain relationship materialize (Explore / relationship APIs). Heavy JSON stays on the claim; links are navigation only.


Case file

KNOWX · 00

Checklist

  • Agent knowx with parentAgentId: "ops"
  • KnowXEntity union + assertions OT + knowx CT on host OTs
  • Six KnowX relationship definitions
  • Three services with Memorix contracts above
  • Pipeline knowx-ingest-associate wired end-to-end
  • Known pack packId: "knowx" installable after ops
  • No live AI required for fixture acceptance
  • No associated*, no abstract collections, provenance on every draft