mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-13 14:37:26 +00:00
* 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>
53 lines
2.6 KiB
Markdown
53 lines
2.6 KiB
Markdown
# OpenContext examples
|
|
|
|
Five working [OpenContext](../../docs/opencontext.md) repositories. Every one is held to `validate --strict` and a 100% health score in CI, so a resolver change that quietly degrades a published example fails the build.
|
|
|
|
| Example | Shows |
|
|
| --- | --- |
|
|
| [minimal](./minimal) | The floor: a mission, one policy, one role |
|
|
| [startup](./startup) | Every layer, L0 through L5, with pricing, SOPs, and decisions |
|
|
| [support-agent](./support-agent) | Redaction, classification, and a worked prompt-injection case |
|
|
| [engineering-team](./engineering-team) | Architecture knowledge, runbooks, ADRs, and a supersession chain |
|
|
| [multi-agent-company](./multi-agent-company) | One repository, five agents, five different bundles |
|
|
|
|
## Running one
|
|
|
|
```bash
|
|
cd minimal
|
|
|
|
npx @logicsrc/opencontext validate --strict
|
|
npx @logicsrc/opencontext doctor
|
|
npx @logicsrc/opencontext resolve --role everyone --format markdown
|
|
```
|
|
|
|
Or from anywhere, since discovery searches upward:
|
|
|
|
```bash
|
|
opencontext doctor --dir examples/opencontext/multi-agent-company
|
|
```
|
|
|
|
## What to read, in order
|
|
|
|
**Start with `minimal`** to see how little is required — `id` and `type` are the only mandatory fields on an object.
|
|
|
|
**Then `multi-agent-company`**, which is the whole thesis in one repository: five agents share one context plane and each receives a different bundle. Run all five and compare:
|
|
|
|
```bash
|
|
cd multi-agent-company
|
|
for agent in sales-agent support-agent dev-agent finance-agent ops-agent; do
|
|
echo "== $agent"
|
|
opencontext resolve --agent "$agent" --explain
|
|
done
|
|
```
|
|
|
|
**Then `support-agent`** if you are putting an agent in front of customers. It contains a ticket whose text instructs the agent to ignore its refund policy and disclose payment details — carried as `trust: untrusted`, fenced and labelled in the Markdown bundle, and flagged in `warnings`. The SSN is removed, the card masked, and the emails hashed, all from a record the agent is fully entitled to read.
|
|
|
|
**Then `engineering-team`** for supersession as history: a February decision retained with `authority: historical` and replaced by an August one. Default resolution returns the current decision; `--include-historical` returns both.
|
|
|
|
## Verifying them yourself
|
|
|
|
```bash
|
|
npm --workspace @logicsrc/opencontext test
|
|
```
|
|
|
|
The `examples.test.ts` suite asserts that each example validates strictly, scores 100, resolves deterministically in all three formats, and — for the multi-agent example — that no role ever receives a card number, that payroll reaches only finance, and that an inferred churn score never reaches a sales conversation.
|