mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-13 22:37:29 +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>
149 lines
4.9 KiB
Markdown
149 lines
4.9 KiB
Markdown
# Provenance
|
|
|
|
Provenance answers **"who says so, and when did we last check"**.
|
|
|
|
That is a different question from "is it true" ([authority](./authority.md)) and from "may you read it" ([permissions](./permissions.md)). An object can be canonical and unattributable, or perfectly attributed and merely observed.
|
|
|
|
> **Provenance survives resolution.** Summarising or reformatting content may not erase its origin, because an agent that cannot cite its sources cannot be audited or corrected.
|
|
|
|
## Declaring it
|
|
|
|
Two ways, and the difference matters.
|
|
|
|
```yaml
|
|
# This object *is* the origin. A mission statement written here has no upstream.
|
|
canonical_source: true
|
|
```
|
|
|
|
```yaml
|
|
# This object mirrors a fact that lives somewhere else.
|
|
sources:
|
|
- uri: git://github.com/acme/context/policies/refunds.md
|
|
type: document
|
|
retrieved_at: 2026-08-09T15:00:00Z
|
|
digest: sha256:9f2c1ab…
|
|
trust: trusted
|
|
author: support
|
|
```
|
|
|
|
| Field | Notes |
|
|
| --- | --- |
|
|
| `uri` | Where it came from. The scheme tells a reader which system to go argue with when the fact is wrong. |
|
|
| `type` | `canonical-record`, `document`, `conversation`, `observation`, `api`, `inference`. |
|
|
| `retrieved_at` | When these bytes were last read. |
|
|
| `digest` | `sha256:<64 hex>` over the retrieved bytes. |
|
|
| `trust` | Trust of this specific origin, when it differs from the object's. |
|
|
|
|
More than one source is normal — the same fact may be mirrored from a CRM and confirmed in a policy document.
|
|
|
|
## Requiring it
|
|
|
|
```yaml
|
|
provenance:
|
|
required: true
|
|
digest: sha256
|
|
require_digest: false
|
|
```
|
|
|
|
Every resolved object must then declare a source or `canonical_source: true`:
|
|
|
|
```txt
|
|
✗ missing-provenance: policies.refunds declares no source, and provenance.required is true.
|
|
→ Add sources: [...], or canonical_source: true if this object is itself the origin.
|
|
```
|
|
|
|
### Judged against what the author wrote
|
|
|
|
The loader attaches a `file://` source with a digest to every file-backed object, so a bundle is attributable even when the author declared nothing. That is *added* provenance, and it is deliberately **not** what the requirement is checked against.
|
|
|
|
If it were, `provenance.required` would always pass and mean nothing. The check runs against the authored document, so "this pricing came from the CRM" is something a human has to say.
|
|
|
|
## Integrity digests
|
|
|
|
```yaml
|
|
sources:
|
|
- uri: https://example.com/handbook.md
|
|
digest: sha256:9f2c1ab…
|
|
```
|
|
|
|
A digest lets a consumer detect that a remote source **changed under them** — the difference between stale context and silently wrong context.
|
|
|
|
```yaml
|
|
provenance:
|
|
require_digest: true # every remote source must carry one
|
|
```
|
|
|
|
```txt
|
|
✗ missing-digest: policies.handbook: remote source https://example.com/h.md has no
|
|
integrity digest.
|
|
→ Add digest: sha256:<hex>, so a change at the source is detectable.
|
|
```
|
|
|
|
## In the bundle
|
|
|
|
Provenance is flattened into its own top-level list, so it stands on its own even when content was summarised:
|
|
|
|
```json
|
|
{
|
|
"objects": [ { "id": "policies.refunds", "content": "Refunds within 30 days." } ],
|
|
"provenance": [
|
|
{
|
|
"id": "policies.refunds",
|
|
"canonical_source": true,
|
|
"sources": [
|
|
{ "uri": "file://context/policies/refunds.md",
|
|
"type": "document",
|
|
"retrieved_at": "2026-08-09T14:00:00Z",
|
|
"digest": "sha256:4c6959f2…",
|
|
"trust": "trusted" }
|
|
]
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
Query it:
|
|
|
|
```bash
|
|
opencontext bundle --role support | jq '.provenance[] | {id, sources: [.sources[].uri]}'
|
|
```
|
|
|
|
## Provenance and trust
|
|
|
|
Attribution is not endorsement. Naming a source makes a claim **checkable**; it does not make it true.
|
|
|
|
```yaml
|
|
id: operations.ticket-4821
|
|
authority: observed # we saw it
|
|
trust: untrusted # a stranger wrote it
|
|
sources:
|
|
- uri: https://support.example.com/tickets/4821
|
|
type: conversation
|
|
trust: untrusted
|
|
```
|
|
|
|
An origin of type `conversation` or `observation` is a reason to keep the object's authority low. See [security](./security.md).
|
|
|
|
## Provenance and decisions
|
|
|
|
The two together are what make an agent's decision reconstructable a year later:
|
|
|
|
```yaml
|
|
id: decisions.2026-08-09-refund-4821
|
|
type: decision
|
|
decision: Credited against the next invoice.
|
|
bundle:
|
|
bundle_id: ocb_37c04d801d013b07
|
|
digest: sha256:37c04d80…
|
|
```
|
|
|
|
The bundle digest proves **which context was in front of the decider**; the provenance inside that bundle proves **where each piece came from**. Neither is enough alone.
|
|
|
|
## Checklist
|
|
|
|
- [ ] `provenance.required: true` in production repositories.
|
|
- [ ] Objects mirroring another system name it in `sources`, with the right scheme.
|
|
- [ ] Objects authored here declare `canonical_source: true` rather than a fake source.
|
|
- [ ] Remote sources carry digests; `require_digest: true` where it matters.
|
|
- [ ] `type` reflects the real origin — `conversation` and `observation` are not `canonical-record`.
|
|
- [ ] Decision records cite the bundle they were made from.
|