logicsrc/packages/schemas/fixtures/opencontext/conformance.json
Anthony Ettinger 3ab8a4b38b
Add the LogicSRC OpenContext specification (#132)
* Add the LogicSRC OpenContext specification

OpenContext is an open specification for durable, portable, permissioned,
provenance-aware context shared between humans and AI agents. It defines how
organizational knowledge is described, authorized, versioned, resolved,
audited, and handed between replaceable workers without losing institutional
state.

Follows the OpenPRD/OpenOntology pattern already in the repo: self-contained
JSON Schemas in @logicsrc/schemas, a reference implementation package, CLI
subcommands, docs, examples, and an OpenPRD record.

Schemas (8, all self-contained so a third party can fetch one file and
validate against it with no further resolution):
  manifest, object, bundle, role, provenance, decision, diagnostic,
  audit-event — registered in @logicsrc/validators and schemas:validate.

Reference implementation (@logicsrc/opencontext):
  loader with upward manifest discovery, the full resolution pipeline,
  authority/supersession, permissions, redaction, lifecycle, provenance,
  deterministic digests, doctor, search, graph, history/diff, guarded writes,
  audit events, and file/http/git/sqlite adapters.

CLI: all 15 specified commands, as a standalone `opencontext` binary and as
`logicsrc context`, sharing one implementation so the two cannot drift.

Design decisions worth noting:

- Supersession is declared, never inferred from version numbers. Inferring it
  would hide the governance failure it represents and make
  multiple-active-versions and duplicate-canonical impossible to detect.

- The bundle digest identifies the resolved context, not the moment it was
  computed, so generated_at/bundle_id/digest/as_of are excluded while objects,
  lifecycle states, exclusions and warnings are covered. That is what lets a
  decision record cite exactly the context that produced it.

- A role's own max_classification beats an inherited one, so a ceiling on a
  shared base role cannot silently cap a role deliberately granted more;
  requesting several roles at once still takes the lowest, so combining roles
  never escalates.

- Scope wildcards match whole dotted segments only. A trailing .* covers a
  subtree; an interior * matches exactly one segment. Substring matching here
  would be an access-control bug.

- --include narrows an existing scope and is applied after it, never merged
  into it, so a request can never widen what a role holds.

Verified: 226 tests across core primitives, permissions/redaction, the
resolution pipeline, security, the published conformance fixtures (13 valid,
35 invalid, 8 resolution scenarios), project behaviour, and the five shipped
examples — which are held to --strict and a 100% health score. Benchmarks meet
every published budget (resolve 1,000 objects in ~33ms against a 2s target).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Point install docs at @logicsrc/opencontext; record the npm name collision

The unscoped `opencontext` name is already published on npm by an unrelated
third party (federicodeponte/opencontext, 2.0.0), so `npx opencontext` would
install a stranger's package. Docs now use `npx @logicsrc/opencontext`; the bin
stays named `opencontext` so the command reads as the PRD specifies once
installed.

Recorded in PRD 0003 as a blocker to resolve before any publication, along with
the fact that no @logicsrc spec package has ever been published, so there is no
existing release path to slot into.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Advance the logicsrc-mcp next-PRD-id assertion to 0004

standards.test.ts asserts prd_next_id against the live prd/ directory, so
adding PRD 0003 makes the next free id 0004. The test's own comment
anticipates this: "advances with every PRD added".

Caught by CI, not locally — the earlier verification ran per-package tests for
the packages this branch touches, and logicsrc-mcp is coupled to the PRD
directory without importing from it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-09 11:46:11 -07:00

279 lines
8.8 KiB
JSON

{
"opencontextConformance": "1.0",
"description": "Conformance fixtures for LogicSRC OpenContext. A third-party implementation can run these against the published JSON Schemas with no LogicSRC code: every valid fixture MUST validate, and every invalid fixture MUST fail for the stated reason. The resolution/ scenarios go further and pin resolver behaviour — scope, authority, supersession, lifecycle, and redaction — which schemas alone cannot express.",
"schemas": {
"manifest": "https://logicsrc.com/schemas/opencontext/manifest.schema.json",
"object": "https://logicsrc.com/schemas/opencontext/object.schema.json",
"bundle": "https://logicsrc.com/schemas/opencontext/bundle.schema.json",
"role": "https://logicsrc.com/schemas/opencontext/role.schema.json",
"provenance": "https://logicsrc.com/schemas/opencontext/provenance.schema.json",
"decision": "https://logicsrc.com/schemas/opencontext/decision.schema.json",
"diagnostic": "https://logicsrc.com/schemas/opencontext/diagnostic.schema.json",
"audit-event": "https://logicsrc.com/schemas/opencontext/audit-event.schema.json"
},
"valid": [
{
"fixture": "valid/manifest.json",
"kind": "opencontext-manifest"
},
{
"fixture": "valid/manifest-minimal.json",
"kind": "opencontext-manifest"
},
{
"fixture": "valid/object-policy.json",
"kind": "opencontext-object"
},
{
"fixture": "valid/object-minimal.json",
"kind": "opencontext-object"
},
{
"fixture": "valid/object-structured.json",
"kind": "opencontext-object"
},
{
"fixture": "valid/object-untrusted.json",
"kind": "opencontext-object"
},
{
"fixture": "valid/decision.json",
"kind": "opencontext-decision"
},
{
"fixture": "valid/role.json",
"kind": "opencontext-role"
},
{
"fixture": "valid/provenance.json",
"kind": "opencontext-provenance"
},
{
"fixture": "valid/provenance-canonical.json",
"kind": "opencontext-provenance"
},
{
"fixture": "valid/bundle.json",
"kind": "opencontext-bundle"
},
{
"fixture": "valid/diagnostic.json",
"kind": "opencontext-diagnostic"
},
{
"fixture": "valid/audit-event.json",
"kind": "opencontext-audit-event"
}
],
"invalid": [
{
"fixture": "invalid/manifest-missing-version.json",
"kind": "opencontext-manifest",
"why": "manifest has no opencontext version"
},
{
"fixture": "invalid/manifest-bad-id.json",
"kind": "opencontext-manifest",
"why": "namespace id must be a lowercase slug"
},
{
"fixture": "invalid/manifest-unknown-key.json",
"kind": "opencontext-manifest",
"why": "unknown top-level key (contexts vs context)"
},
{
"fixture": "invalid/manifest-bad-authority.json",
"kind": "opencontext-manifest",
"why": "authority precedence contains a level that is not defined"
},
{
"fixture": "invalid/manifest-bad-ttl.json",
"kind": "opencontext-manifest",
"why": "duration must look like 30d"
},
{
"fixture": "invalid/manifest-role-bad-pattern.json",
"kind": "opencontext-manifest",
"why": "a wildcard must be a whole segment, never a substring"
},
{
"fixture": "invalid/manifest-bad-extension.json",
"kind": "opencontext-manifest",
"why": "extension keys must be reverse-DNS namespaced"
},
{
"fixture": "invalid/object-missing-type.json",
"kind": "opencontext-object",
"why": "type is required"
},
{
"fixture": "invalid/object-missing-id.json",
"kind": "opencontext-object",
"why": "id is required"
},
{
"fixture": "invalid/object-bad-id.json",
"kind": "opencontext-object",
"why": "id must be a dotted lowercase slug"
},
{
"fixture": "invalid/object-unknown-authority.json",
"kind": "opencontext-object",
"why": "authority must be one of the six defined levels"
},
{
"fixture": "invalid/object-unknown-classification.json",
"kind": "opencontext-object",
"why": "classification must be public/internal/confidential/restricted"
},
{
"fixture": "invalid/object-unknown-trust.json",
"kind": "opencontext-object",
"why": "trust must be trusted/verified/untrusted"
},
{
"fixture": "invalid/object-extra-property.json",
"kind": "opencontext-object",
"why": "unknown field must go under extensions"
},
{
"fixture": "invalid/object-confidence-out-of-range.json",
"kind": "opencontext-object",
"why": "confidence must be between 0 and 1"
},
{
"fixture": "invalid/object-bad-digest.json",
"kind": "opencontext-object",
"why": "source digest must be sha256:<64 hex>"
},
{
"fixture": "invalid/object-bad-layer.json",
"kind": "opencontext-object",
"why": "layer must be L0 to L5"
},
{
"fixture": "invalid/object-source-without-uri.json",
"kind": "opencontext-object",
"why": "every source needs a uri"
},
{
"fixture": "invalid/object-bad-supersedes.json",
"kind": "opencontext-object",
"why": "version pin must be @<integer>"
},
{
"fixture": "invalid/object-bad-redaction-mode.json",
"kind": "opencontext-object",
"why": "redaction mode must be remove/mask/hash"
},
{
"fixture": "invalid/decision-missing-decision.json",
"kind": "opencontext-decision",
"why": "a decision record must state the decision"
},
{
"fixture": "invalid/decision-wrong-type.json",
"kind": "opencontext-decision",
"why": "type must be decision"
},
{
"fixture": "invalid/decision-bad-status.json",
"kind": "opencontext-decision",
"why": "status must be proposed/accepted/rejected/superseded/deprecated"
},
{
"fixture": "invalid/bundle-missing-digest.json",
"kind": "opencontext-bundle",
"why": "a bundle must carry a digest"
},
{
"fixture": "invalid/bundle-bad-digest.json",
"kind": "opencontext-bundle",
"why": "digest must be sha256:<64 hex>"
},
{
"fixture": "invalid/bundle-bad-id.json",
"kind": "opencontext-bundle",
"why": "bundle_id must be prefixed ocb_"
},
{
"fixture": "invalid/bundle-unknown-exclusion-reason.json",
"kind": "opencontext-bundle",
"why": "exclusion reasons are a closed set"
},
{
"fixture": "invalid/role-bad-classification.json",
"kind": "opencontext-role",
"why": "max_classification must be one of the four bands"
},
{
"fixture": "invalid/role-bad-include.json",
"kind": "opencontext-role",
"why": "scope patterns are lowercase"
},
{
"fixture": "invalid/provenance-no-source.json",
"kind": "opencontext-provenance",
"why": "must declare sources or canonical_source"
},
{
"fixture": "invalid/provenance-canonical-false.json",
"kind": "opencontext-provenance",
"why": "canonical_source: false does not satisfy the requirement"
},
{
"fixture": "invalid/diagnostic-unknown-code.json",
"kind": "opencontext-diagnostic",
"why": "diagnostic codes are normative and closed"
},
{
"fixture": "invalid/diagnostic-missing-ok.json",
"kind": "opencontext-diagnostic",
"why": "ok is required — it is what the exit code follows"
},
{
"fixture": "invalid/audit-event-unknown-event.json",
"kind": "opencontext-audit-event",
"why": "event names are a closed set"
},
{
"fixture": "invalid/audit-event-missing-actor.json",
"kind": "opencontext-audit-event",
"why": "an audit event without an actor is not attributable"
}
],
"resolution": [
{
"scenario": "resolution/authority-conflict",
"expected": "resolution/authority-conflict/expected.json"
},
{
"scenario": "resolution/classification-ceiling",
"expected": "resolution/classification-ceiling/expected.json"
},
{
"scenario": "resolution/deny-overrides-allow",
"expected": "resolution/deny-overrides-allow/expected.json"
},
{
"scenario": "resolution/duplicate-canonical",
"expected": "resolution/duplicate-canonical/expected.json"
},
{
"scenario": "resolution/lifecycle",
"expected": "resolution/lifecycle/expected.json"
},
{
"scenario": "resolution/object-permissions",
"expected": "resolution/object-permissions/expected.json"
},
{
"scenario": "resolution/redaction",
"expected": "resolution/redaction/expected.json"
},
{
"scenario": "resolution/supersession",
"expected": "resolution/supersession/expected.json"
}
]
}