Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ jobs:
run: pnpm example
- name: Check package artifacts
run: pnpm run release:check
- name: Prove authenticated agent protocol
run: pnpm run agent:proof
41 changes: 34 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ tests. The approved scope is the [Support Desk enhancement plan](https://github.
validation/evidence bindings, approval, publication, and retirement.
- KB-01 owns pure domain work. KB-02 adds declared persistence and authorized
application services. KB-03 extends the application with bounded retrieval,
authoritative confirmation, and repair; it adds no package. API/MCP and live
host interfaces remain later tasks; do not create their packages early.
authoritative confirmation, and repair; it adds no package. KB-04 adds the
optional `@pegma/knowledge-base-mcp` package for the shared five-operation
dispatcher, versioned HTTP contract, and MCP transport. Live host interfaces
remain host work; do not create later packages early.
- Independent partial KB-05 source preparation adds local D1 conformance and
a public synthetic composition. It does not complete KB-04 credentials or
the full KB-05 release/publication task. All three packages remain unpublished.
the full KB-05 release/publication task. KB-04 source is in progress; all four
packages remain unpublished at synchronized version `0.1.0`.
- Never implement a database, authorization role model, identity/session/token
system, audit log, request limiter, or durable scheduler here. Compose the
corresponding Pegma package in the owning later task.
Expand Down Expand Up @@ -44,7 +47,20 @@ tests. The approved scope is the [Support Desk enhancement plan](https://github.
count, content, or citation. Whole source serialization uses the trusted local
token counter; do not truncate article procedures into partial steps.
- Base packages require no Support Desk, GitHub, model, framework, HTTP, or
provider SDK. Evidence is data; never execute code or fetch submitted URLs.
provider SDK. Only the optional MCP package depends on the official MCP SDK
and Zod. Evidence is data; never execute code or fetch submitted URLs.
- Initial agent access exposes exactly `getDraft`, `createDraft`, `updateDraft`,
`getValidationRequirements`, and `submitEvidence`. Reuse `knowledgePermissions`
draft-read/write/evidence-submit values as scopes; requirements need
`draftWrite` or `evidenceSubmit`, never `draftRead` or `validationManage` alone.
Agent credentials grant no staff/Admin role, collection/evidence/provenance
reads, review, publication, policy administration, or grant management.
- The host composes Agent Access with its existing human login and current
Admin-only consent. Device linking uses RFC 8628; authorization-code linking
requires S256 PKCE. Initial authoring consent is app-instance-wide;
collection-specific delegation is a future host seam. New capabilities need
explicit scope registration, policy, and fresh consent. KB owns no credential
issuer, login, role model, or request limiter.
- Constrain content and links; host renderers must disable executable content
and raw HTML. Staff evidence/provenance never enters customer or bot DTOs.
- Use fictional fixtures only. Commercial host internals, credentials, customer
Expand All @@ -60,9 +76,11 @@ tests. The approved scope is the [Support Desk enhancement plan](https://github.
## Workflow

Work on a `claude/*` branch and open a PR. Required checks are
`pnpm run format:check`, `pnpm run check`, `pnpm test`, `pnpm example`, and
`pnpm run release:check`, on Node 22 and 24. Run the applicable review/security
checks for the current head. Do not bypass pending, skipped, or failing gates.
`pnpm run format:check`, `pnpm run check`, `pnpm test`, `pnpm example`,
`pnpm run release:check`, and `pnpm run agent:proof`, on Node 22 and 24.
Require a clean current-head OpenRouter review with zero actionable findings
and the applicable current-head security checks. Do not bypass pending,
skipped, or failing gates.
Repository development and the TypeScript example require Node 22.6.0+ or 24.
The root engine floor covers the example's `--experimental-strip-types` flag;
published package engines remain `>=22`, and CI tracks current Node 22/24.
Expand All @@ -71,6 +89,12 @@ Each published package needs its own README and MIT LICENSE, a build-on-prepack
script, and compiled-test exclusion. Merging source does not publish packages.
See [release operations](docs/RELEASING.md); first publication and external
trusted-publisher configuration are separate maintainer operations.
The protocol proof may build the reviewed, pinned public AUTH-01 source in an
isolated temporary consumer with all four KB tarballs and the official SDK.
That test-only exception never authorizes an unpublished production dependency.
Agent Access publication and KB-05 publication both precede real host assembly.
Keep actual existing-login/Admin-consent and every requested client/mode proof
open in P-00 and PG-01/RG-01 until both hosts record them before activation.

## Reading order

Expand All @@ -82,5 +106,8 @@ durable operations and [host composition](docs/HOST_COMPOSITION.md) before
changing authorization, verifier, replay, or DTO boundaries.
For KB-03, read [retrieval](docs/RETRIEVAL.md) and the declared projection
layout before changing query work, citations, or repair.
For KB-04, read the [agent API](docs/AGENT_API.md) and
[agent workflow](docs/AGENT_WORKFLOW.md) before changing transport, credential,
client, or evidence-proof boundaries.
For partial KB-05, read [source preparation](docs/SOURCE_PREPARATION.md) before
changing local D1 fixtures, synthetic composition, or release-readiness claims.
81 changes: 54 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,51 @@ Hosts own their users, storage, authorization policy, interfaces, and deployment
Knowledge Base owns collection policy, immutable article revisions, validation,
and exact publication approval. It requires no GitHub connection or AI provider.

> Development status: KB-01 provides contracts and pure domain transitions;
> KB-02 adds authorized application/persistence source, and KB-03 extends that
> application with bounded retrieval and repair. Implementation and repository
> gates determine source evidence. Independent partial KB-05 preparation adds
> local D1 conformance and a public synthetic example. KB-04 credentials and the
> full KB-05 release task remain unfinished. All three packages are unpublished
> at `0.1.0`. API/MCP and live customer/staff interfaces remain later tasks. This
> repository is not yet an operational hosted KB or a production dependency.
> Development status: KB-01 through KB-03 provide contracts, pure domain
> transitions, authorized application/persistence, and bounded retrieval/repair.
> Independent partial KB-05 preparation adds local D1 conformance and a public
> synthetic example. KB-04 source work adds the optional five-operation HTTP/MCP
> adapter and authenticated protocol proof; it is in progress until current-head
> gates and review pass. All four packages are unpublished at `0.1.0`.
> KB-05 publication and actual two-host existing-login/client acceptance remain
> separate gates. This repository is not an operational hosted KB or a
> production dependency.

| Package | Scope |
| --------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| [`@pegma/knowledge-base-contracts`](packages/contracts/README.md) | Collection, article, evidence, and approval vocabulary |
| [`@pegma/knowledge-base-core`](packages/core/README.md) | Pure validation and lifecycle transitions |
| [`@pegma/knowledge-base-application`](packages/application/README.md) | Authorized services, bounded persistence/retrieval, private DTOs, and exact publication |
| [`@pegma/knowledge-base-mcp`](packages/mcp/README.md) | Optional bounded agent dispatcher, versioned HTTP API, and MCP adapter |

Collections default to private and independently specify portal and bot-answer
audiences. Articles inherit collection policy. Staff approval binds the exact
revision, content, collection policy, applicability, validation requirements,
and evidence. A revised guide requires fresh review; prior publication never
authorizes edited content.

Core transitions accept explicit inputs and return new values. They do not
authenticate a runner or staff member, enforce host roles, fetch evidence URLs,
or execute guide steps. The application enforces current named permissions
and resource checks; hosts authenticate scoped access contexts and trusted
evidence/source facts. Private draft, evidence, provenance, and review reads
have separate DTOs. The keyed published read returns portal-safe content only.
Local agents will test guides against authorized staging and submit evidence
through the later API/MCP adapter.
Core transitions accept explicit inputs and return new values. The application
enforces current named permissions and resource checks; hosts authenticate
access contexts and evidence/source facts. Private draft, evidence, provenance,
and review reads have separate DTOs. The keyed published read returns
portal-safe content only. The three base packages remain independent of HTTP,
MCP, and provider SDKs.

The optional adapter exposes exactly `getDraft`, `createDraft`, `updateDraft`,
`getValidationRequirements`, and `submitEvidence` over the same application.
Its scopes reuse `knowledgePermissions.draftRead`, `draftWrite`, and
`evidenceSubmit`; validation requirements need write or evidence-submit
authority. Agents receive no Admin/staff role, collection or evidence reads,
private provenance, review, publication, policy, or grant-management operations.
Read the [agent API](docs/AGENT_API.md) for the exact contract and
[agent workflow](docs/AGENT_WORKFLOW.md) for linking and draft/test/evidence use.

Hosts compose the separate [Agent Access](https://github.com/pegma-dev/agent-access)
producer with their existing human login and current Admin consent. AUTH-01's
[merged source](https://github.com/pegma-dev/agent-access/pull/1) supplies the
source prerequisite; publication remains separate. Initial authoring grants are
app-instance-wide. Collection-specific delegation is a future host seam.
The KB does not issue credentials or implement login, roles, or a limiter.

KB-02 stores normalized heads and bounded immutable history with same-partition
CAS, Audit, replay receipts, and causal jobs. Application generation is separate
Expand All @@ -54,9 +70,12 @@ physical work/source budgets, whole-article token accounting, and repair.
Partial [source preparation](docs/SOURCE_PREPARATION.md) runs shared public KB
conformance against memory, local Azurite, and real local Miniflare D1 through
the released D1 adapter. The [synthetic composition](examples/composition/README.md)
demonstrates the public author/test/review/publish/retrieve flow with fictional
trust inputs. Local emulators and that example establish neither live Workers
deployment nor scoped API/MCP credentials, publication, or host acceptance.
demonstrates author/test/review/publish/retrieve with fictional trust inputs.
The separate `agent:proof` gate composes reviewed pinned AUTH-01 source and all
four packed KB artifacts in a temporary consumer with the official MCP SDK
`1.32.2`, exercising OAuth, the five tools, evidence binding, and HTTP/MCP parity.
Current-head results establish execution; these proofs establish neither actual
requested-client compatibility nor either real host's login/staging acceptance.

Develop on Node 22.6.0+ or 24 with pnpm 10.34.5:

Expand All @@ -67,25 +86,33 @@ pnpm run check
pnpm test
pnpm example
pnpm run release:check
pnpm run agent:proof
```

The npm and pnpm workspace declarations deliberately name the same source
The npm and pnpm workspace declarations deliberately name the same four source
packages: pnpm links them for development, while npm supplies artifact packing.
The release check installs all three tarballs in a consumer outside either workspace
to verify dependency resolution without source links.
The release check installs all four tarballs in a consumer outside either
workspace to verify dependency resolution without source links. The Agent
Access source fixture is confined to the temporary protocol-proof consumer;
production hosts must consume exact published Agent Access and KB versions.
Frozen installation permits the pinned native `workerd` install script only;
test workers/timeouts and per-factory D1 disposal remain bounded.

The [approved enhancement plan](https://github.com/pegma-dev/support-desk/blob/main/docs/KNOWLEDGE_AI_PLAN.md)
defines KB-01 through KB-05 and the later Support Desk/host integrations.
Its [P-00 handoff](https://github.com/pegma-dev/support-desk/pull/33) records
source/registry baselines, synthetic acceptance cases, and open activation
prerequisites. These two launch hosts use separate stores and policies; the
packages do not introduce a shared tenant control plane.
frozen baselines and activation prerequisites; the
[source/publication clarification](https://github.com/pegma-dev/support-desk/pull/36)
retains actual two-host acceptance in PG-01/RG-01 before activation and pilots.
Codex, Claude Code, Grok Bot's desktop hosted agent, and T3 Code's Codex-provider
mode each need real recorded runs on both hosts. SDK proof cannot close those
gates. The two hosts keep separate stores and policies without a shared control
plane.

Read [AGENTS.md](AGENTS.md) before changing code and
[release operations](docs/RELEASING.md) before preparing artifacts. Merging
source does not publish a package. Each new npm name needs the maintainer's
first publication and trusted-publisher setup before hosts can consume it.
source does not publish a package. Each of the four npm names needs the
maintainer's first publication and its own trusted-publisher setup before host
consumption; Agent Access follows its separate release process.

Built in the open by RetireGolden, LLC.
Loading
Loading