feat(openontology): implement OpenOntology Phase 0 + local engine and CLI (#99)
Some checks failed
CI / build (push) Has been cancelled
test / test (push) Has been cancelled

Implements OpenPRD 0001 through Phase 0 (specification, schemas, example,
docs surface) and Phase 1 (local engine, CLI, conformance tests).

Schemas (17 contracts, JSON Schema Draft 2020-12, additionalProperties:false)
  manifest, namespace, entity-type, property, relationship-type, constraint,
  query, action, entity, claim, source, evidence, changeset, review, approval,
  event, package — registered in @logicsrc/validators and exported from
  @logicsrc/schemas under https://logicsrc.com/schemas/openontology/.

@logicsrc/openontology
  - canonical JSON + sha256 package digests; YAML, JSON, NDJSON, and inline
    authoring all compile to the same bytes, so digests are authoring-agnostic
  - id profile: compact / IRI / urn with one canonicalization rule, prefix
    bound by a Namespace object so IRIs reverse unambiguously
  - validation: schema, graph (domain/range, datatypes, dangling refs),
    provenance (source-or-firstParty, agent runId, derivation inputs), policy
    (excerpt limits, licensing, visibility, staleness) and declared
    constraints; four severities, stable codes, text/json/yaml/markdown
  - portable triple-pattern query AST: multi-hop, 14 operators, asOf and
    recordedAsOf, per-status filtering, distinct/order/limit, explanation
    mode, and enforced depth/binding/row limits
  - append-only store: claims are immutable; dispute/retract/supersede append
    status transitions and the effective status is the latest one
  - change sets: 9 operations, atomic pre-flight, conflict detection on stale
    base revisions, semantic diff with duplicate-identity warnings and
    affected-query deltas, per-operation reviewer decisions
  - policy: agents propose but can never apply — the denial keys on actor
    type, so every scope plus high confidence plus --yolo still cannot apply;
    merges need approval, bulk retractions need two, undeclared action side
    effects are denied
  - JSON-LD 1.1 export/import with PROV-O aliases and lossy-field reporting
  - pluggable signature envelope with a jws-ed25519 reference profile and a
    fail-closed trust policy

CLI: logicsrc ontology init|validate|lint|build|inspect, entity, claim, query,
changeset, import, export, audit. Reads take --format, writes default to a
proposal, exit codes are stable for CI.

Example: examples/openontology/ethereum-ecosystem — 12 entity types, 17
relationship types, 63 entities, 169 claims, 25 sources, 31 evidence records,
5 saved queries, every claim lifecycle state, and a pending merge proposal.
All data is fictional; the directory is removable without affecting any core
test.

Docs: docs/openontology{,-governance,-interoperability}.md, a real
/openontology route, homepage + nav + sitemap entries, and a root README
section.

Verification: 112 new tests; full monorepo build and every workspace test
pass; conformance bundle (18 valid + 13 invalid fixtures) runs against the
published schemas alone; Node.js 25 and Bun 1.3 produce byte-identical
digests, revisions, event trails, and query results.

Not included (later PRD phases): MCP resources, REST/SSE, Turso adapter, TUI
and PWA surfaces, RDF/SHACL mappings, source adapters, governed actions.

Refs: prd/0001-add-logicsrc-openontology-spec.md

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Anthony Ettinger 2026-07-26 02:10:13 -07:00 committed by GitHub
parent 0d9dab0447
commit 58c942c67f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
101 changed files with 11934 additions and 10 deletions

View file

@ -0,0 +1,43 @@
- openontology: "0.1"
kind: Constraint
id: codebase-has-language
description: Every codebase should record its primary implementation language.
severity: info
remediation: Add a language claim for the codebase.
rule:
type: required-predicate
entityType: Codebase
predicate: language
- openontology: "0.1"
kind: Constraint
id: layer2-settles-somewhere
description: Every layer 2 must declare the network it settles to.
severity: error
remediation: Add a deployedOn claim from the layer 2 to its base network.
rule:
type: cardinality
predicate: deployedOn
entityType: Layer2
min: 1
max: 1
- openontology: "0.1"
kind: Constraint
id: chain-ids-unique
description: Two networks must not share a chain id.
severity: error
remediation: Correct the duplicated chainId claim.
rule:
type: unique
predicate: chainId
- openontology: "0.1"
kind: Constraint
id: proof-system-known
description: A layer 2's proof system must be one of the three recognised kinds.
severity: error
rule:
type: allowed-values
predicate: proofSystem
values:
- validity
- fraud
- hybrid

View file

@ -0,0 +1,113 @@
- openontology: "0.1"
kind: EntityType
id: Person
label: Person
description: A human participant in the ecosystem.
keyProperties:
- canonicalName
properties:
focus:
type: string
description: Primary area of work.
startedIn:
type: integer
description: Year they began working in the ecosystem.
- openontology: "0.1"
kind: EntityType
id: Organization
label: Organization
description: A company, foundation, DAO, collective, or working group.
properties:
homepage:
type: url
kind:
type: enum
enum:
- company
- foundation
- dao
- collective
- openontology: "0.1"
kind: EntityType
id: Project
label: Project
description: A named body of work people and organizations contribute to.
properties:
homepage:
type: url
startedOn:
type: date
- openontology: "0.1"
kind: EntityType
id: Codebase
label: Codebase
description: A specific repository or source tree.
properties:
language:
type: string
license:
type: string
repository:
type: url
- openontology: "0.1"
kind: EntityType
id: ResearchTopic
label: Research Topic
description: A research direction the ecosystem is actively working on.
- openontology: "0.1"
kind: EntityType
id: Protocol
label: Protocol
description: A specified protocol or standard.
properties:
specification:
type: url
- openontology: "0.1"
kind: EntityType
id: Network
label: Network
description: A live chain or network.
properties:
chainId:
type: integer
- openontology: "0.1"
kind: EntityType
id: Layer2
label: Layer 2
description: A layer-2 network settling to a base layer.
properties:
proofSystem:
type: enum
enum:
- validity
- fraud
- hybrid
- openontology: "0.1"
kind: EntityType
id: Application
label: Application
description: A user-facing application deployed on a network.
- openontology: "0.1"
kind: EntityType
id: FundingProgram
label: Funding Program
description: A grants program, fund, or funding round.
properties:
budgetUsd:
type: number
- openontology: "0.1"
kind: EntityType
id: Publication
label: Publication
description: A paper, spec, or long-form writeup.
properties:
published:
type: date
- openontology: "0.1"
kind: EntityType
id: Event
label: Event
description: A conference, workshop, or summit.
properties:
held:
type: date

View file

@ -0,0 +1,5 @@
- openontology: "0.1"
kind: Namespace
prefix: eth
uri: https://logicsrc.com/ontology/ethereum/
description: Compact id prefix for the Ethereum ecosystem example.

View file

@ -0,0 +1,84 @@
- openontology: "0.1"
kind: Property
id: focus
label: focus
description: A person's primary area of work.
type: string
- openontology: "0.1"
kind: Property
id: startedIn
label: startedIn
description: Year a person began working in the ecosystem.
type: integer
- openontology: "0.1"
kind: Property
id: homepage
label: homepage
description: Canonical URL.
type: url
- openontology: "0.1"
kind: Property
id: kind
label: kind
description: Organization kind.
type: string
- openontology: "0.1"
kind: Property
id: startedOn
label: startedOn
description: Date a project began.
type: date
- openontology: "0.1"
kind: Property
id: language
label: language
description: Primary implementation language of a codebase.
type: string
- openontology: "0.1"
kind: Property
id: license
label: license
description: SPDX license of a codebase.
type: string
- openontology: "0.1"
kind: Property
id: repository
label: repository
description: Repository URL.
type: url
- openontology: "0.1"
kind: Property
id: specification
label: specification
description: Specification URL.
type: url
- openontology: "0.1"
kind: Property
id: chainId
label: chainId
description: Network chain id.
type: integer
- openontology: "0.1"
kind: Property
id: proofSystem
label: proofSystem
description: Layer-2 proof system.
type: string
- openontology: "0.1"
kind: Property
id: budgetUsd
label: budgetUsd
description: Program budget in USD.
type: number
- openontology: "0.1"
kind: Property
id: published
label: published
description: Publication date.
type: date
- openontology: "0.1"
kind: Property
id: held
label: held
description: Event date.
type: date

View file

@ -0,0 +1,122 @@
- openontology: "0.1"
kind: SavedQuery
id: people-working-on-topic
label: People and organizations working on a research topic
description: Every person working on a project that investigates the given research topic.
parameters:
topic:
type: string
required: true
default: eth:topic:zero-knowledge
query:
match:
- subject: ?person
predicate: worksOn
object: ?project
- subject: ?project
predicate: investigates
object: $topic
select:
- ?person
- ?project
include:
claimStatus:
- asserted
labels: true
orderBy:
- variable: ?person
direction: asc
- openontology: "0.1"
kind: SavedQuery
id: codebases-implementing-protocol
label: Codebases implementing a protocol
description: Which codebases implement the given protocol, and who maintains them.
parameters:
protocol:
type: string
required: true
default: eth:protocol:proof-envelope
query:
match:
- subject: ?codebase
predicate: implements
object: $protocol
- subject: ?org
predicate: maintains
object: ?codebase
select:
- ?codebase
- ?org
include:
claimStatus:
- asserted
labels: true
- openontology: "0.1"
kind: SavedQuery
id: orgs-behind-a-network
label: Organizations behind the codebases a network depends on
description: "Three hops: layer 2 → application → codebase → maintaining organization."
query:
match:
- subject: ?l2
predicate: deployedOn
object: ?network
- subject: ?app
predicate: runsOn
object: ?l2
- subject: ?app
predicate: uses
object: ?codebase
- subject: ?org
predicate: maintains
object: ?codebase
select:
- ?network
- ?l2
- ?app
- ?org
include:
claimStatus:
- asserted
labels: true
distinct: true
- openontology: "0.1"
kind: SavedQuery
id: funded-work
label: Funded projects and research directions
description: Which funding programs support which projects or research topics.
query:
match:
- subject: ?fund
predicate: funds
object: ?target
select:
- ?fund
- ?target
include:
claimStatus:
- asserted
labels: true
orderBy:
- variable: ?fund
direction: asc
- openontology: "0.1"
kind: SavedQuery
id: claims-needing-review
label: Claims that still need a human decision
description: Proposed and disputed claims, which a curator should accept, reject, or resolve.
query:
match:
- subject: ?subject
predicate: ?predicate
object: ?object
bindClaim: ?claim
select:
- ?claim
- ?subject
- ?predicate
- ?object
include:
claimStatus:
- proposed
- disputed

View file

@ -0,0 +1,185 @@
- openontology: "0.1"
kind: RelationshipType
id: worksAt
label: works at
description: A person is affiliated with an organization.
from:
- Person
to:
- Organization
cardinality: many-to-many
temporal: true
- openontology: "0.1"
kind: RelationshipType
id: memberOf
label: member of
description: An organization belongs to a larger body.
from:
- Organization
to:
- Organization
cardinality: many-to-many
temporal: true
- openontology: "0.1"
kind: RelationshipType
id: worksOn
label: works on
description: A person actively contributes work to a project.
from:
- Person
to:
- Project
cardinality: many-to-many
temporal: true
inverse: hasContributor
- openontology: "0.1"
kind: RelationshipType
id: hasContributor
label: has contributor
description: Inverse of worksOn.
from:
- Project
to:
- Person
cardinality: many-to-many
- openontology: "0.1"
kind: RelationshipType
id: contributesTo
label: contributes to
description: A person contributes to a codebase.
from:
- Person
to:
- Codebase
cardinality: many-to-many
temporal: true
- openontology: "0.1"
kind: RelationshipType
id: maintains
label: maintains
description: An organization is responsible for a codebase.
from:
- Organization
to:
- Codebase
cardinality: many-to-many
- openontology: "0.1"
kind: RelationshipType
id: builds
label: builds
description: An organization builds a project.
from:
- Organization
to:
- Project
cardinality: many-to-many
temporal: true
- openontology: "0.1"
kind: RelationshipType
id: funds
label: funds
description: A funding program supports a project or research topic.
from:
- FundingProgram
to:
- Project
- ResearchTopic
cardinality: many-to-many
temporal: true
- openontology: "0.1"
kind: RelationshipType
id: investigates
label: investigates
description: A project or person investigates a research topic.
from:
- Project
- Person
- Organization
to:
- ResearchTopic
cardinality: many-to-many
temporal: true
- openontology: "0.1"
kind: RelationshipType
id: implements
label: implements
description: A codebase implements a protocol.
from:
- Codebase
to:
- Protocol
cardinality: many-to-many
- openontology: "0.1"
kind: RelationshipType
id: uses
label: uses
description: A project or application uses a protocol or codebase.
from:
- Project
- Application
to:
- Protocol
- Codebase
cardinality: many-to-many
- openontology: "0.1"
kind: RelationshipType
id: runsOn
label: runs on
description: An application runs on a network or layer 2.
from:
- Application
to:
- Network
- Layer2
cardinality: many-to-many
- openontology: "0.1"
kind: RelationshipType
id: deployedOn
label: deployed on
description: A layer 2 settles to a base network.
from:
- Layer2
to:
- Network
cardinality: many-to-many
- openontology: "0.1"
kind: RelationshipType
id: dependsOn
label: depends on
description: A codebase depends on another codebase.
from:
- Codebase
to:
- Codebase
cardinality: many-to-many
- openontology: "0.1"
kind: RelationshipType
id: authored
label: authored
description: A person authored a publication.
from:
- Person
to:
- Publication
cardinality: many-to-many
- openontology: "0.1"
kind: RelationshipType
id: collaboratesWith
label: collaborates with
description: Two people work together.
from:
- Person
to:
- Person
cardinality: many-to-many
symmetric: true
- openontology: "0.1"
kind: RelationshipType
id: forkedFrom
label: forked from
description: A codebase was forked from another.
from:
- Codebase
to:
- Codebase
cardinality: many-to-many