openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
365 lines (315 loc) • 22.9 kB
Markdown
<!-- Generated by scripts/sync-skill-references.mjs; edit skills/shared/publication.md. -->
# Publishing and retrying Knowledge records
## Prepare
1. Confirm `knowledge_status` is non-sample and `writesEnabled: true`. Retain the
observed vault UUID (`vault`) as `expectedVaultId` on uploads and saves.
2. Search for an existing page before creating one. Match source IDs/URLs,
original hashes, title/date and content, not merely a similar title. For source-bound batches use `knowledge_source_check` with provider, stable
source key and exact original-byte sha256 before uploading again. An unchanged
receipt is reusable publication history: verify its IDs, inspect dependencies
for follow-on work, and never recreate inactive outputs. A changed source needs
explicit reconciliation. Legacy individual writes are not in this registry;
"missing" does not prove the source was never ingested. Same content under a
different source key is not automatically semantically deduplicated. Reuse verified existing evidence/pages when possible.
3. For edits read the entire body and observed revision/hash; request
`includeMetadata: true` if changing domain fields. Preserve unrelated prose.
Omit `fields` to preserve them; supplying `fields` replaces the complete object.
Only use fields allowed by the selected ontology. `save_page` also supports
aliases, tags and dependencies: omitted preserves, supplied replaces, empty
clears. It cannot set lifecycle, entity IDs, arbitrary frontmatter, claim kinds
or relationships; do not smuggle these into `fields`. Existing
type cannot be changed by this editor. Record unsupported information in
clearly attributed prose where appropriate, not fictitious structured state.
## Large pages and local edits
Complete records may occupy 5,000,000 UTF-8 bytes including frontmatter, but each
body/replacement input is bounded to 48,000 characters. Use `knowledge_edit_body`
for a small active-page body range: inspect relevant body windows and surrounding
context, supply observed vault/revision/hash/ontology fences, exact UTF-16 body
start/end offsets, replacement, reason and fresh mutation UUID. Equal offsets
insert; empty replacement deletes. Preserve semantic review; never infer offsets
from raw/frontmatter or overwrite unread prose. Each edit is a complete normal
revision, not a staged upload. Retain exact payloads for replay; reread/reconcile
on stale fences. Attach sources rather than copying large originals into profiles.
Page bodies also have a size budget, smaller for hub pages; growth past it is
rejected with section sizes and connected candidates. Extract sections with
`knowledge_extract_section` rather than trimming prose (see
[page budgets](publish.md#page-budgets)).
Record, revision and recovery reads remain paginated. Follow returned offsets;
for recovery use file offset plus contentField/charOffset and compare field hashes.
A search hit with snippet.matchLocated=false is an opening excerpt, not a located
match; full-record matching/ranking still apply. Read the record for context.
## Retain the source
Prefer `knowledge_attach_file` for an original already acquired in the host workspace.
Compute its SHA-256 with an authorized host tool and pass `filePath`, `sha256`,
filename, attribution, optional mediaType, observed vault UUID and a fresh request
UUID. The plugin streams the exact bytes internally and returns only a receipt.
Paths are confined to the host-selected workspace; sandbox/remote files must use
programmatic byte transfer instead. Do not reinterpret a remote path as a host path.
For programmatic/remote clients, use `knowledge_attach` with a fresh UUID per
original. Send exact bytes
as base64 in sequential chunks of at most 49,152 decoded bytes, starting at
`offset: 0`. Keep request ID, filename, mediaType, attribution and vault precondition
unchanged; set `final: true` only on the last chunk (an empty file is one empty
final chunk). Follow `receivedBytes`. Retry the identical chunk after a lost
response; never guess a new offset or silently restart under a new request ID.
Generate lowercase UUIDs with the host's UUID facility (for example,
`crypto.randomUUID()`); filenames, provider note IDs and descriptive slugs are
not request IDs. Different originals need different UUIDs, even in one meeting.
Never copy, regenerate or print base64 through model-visible output or
model-authored tool arguments. With Code Mode, chain the authorized byte-reading
tool result directly into `knowledge_attach` in the same program; emit only
receipts, byte counts, hashes and errors. Do not delegate mechanical byte copying
to a language-model child. Keep completed receipts in task working context and
reuse them after interruption rather than uploading completed files again.
If no authorized programmatic transfer is available, report original retention
as blocked rather than generating encoded payloads. For small inline user text,
`save_page.source: {text, attribution}` is also supported; pass the exact text.
Only `state: complete` returns usable `evidence`. Supply that object in
`save_page.attachments`, optionally adding verified text line locators/quote.
Attachments append and existing evidence remains; uploading alone creates no
page. Failed page publication can leave an unattached retained file: report it,
reuse its receipt, and do not promise automatic garbage collection.
## Canonical ingestion sequence
1. `knowledge_status` and targeted `knowledge_ontology` definitions.
2. `knowledge_source_check` for a stable provider/key and exact original hash;
`knowledge_grep` to discover existing entities and legacy outputs, or
`knowledge_lookup` only for already-known exact record IDs, full titles or
declared aliases (fall back to grep on `missing`). Inspect records and bounded
`knowledge_connections`. Do not confuse source identity with speaker identity.
3. `knowledge_attach_file` transfers a host-workspace original without model-visible
bytes; `knowledge_attach` uploads programmatic chunks and
`knowledge_attachment` downloads retained bytes.
4. Prepare reconciled page/claim/relationship outputs, then
`knowledge_publish_batch` for related records (up to 25, at most 1 MiB).
Use the individual create/save tools for isolated writes or follow-on work.
5. `knowledge_verify` once for all returned IDs and supplied expectations.
Read substantive prose/evidence for semantic checks and investigate exceptions.
## Publish related records together
Use one generated UUID `requestId`, observed `expectedVaultId` and
`expectedOntologyFingerprint`, and an `items` array. Each item contains a unique
`key`, `kind` (`page`, `claim`, `relationship`), and ordinary write `input` without
its own request/vault/ontology fields. Upload originals first; inline `source`
text is not accepted inside a batch. Page edits retain exact revision/hash fences.
Batch item keys must match `^[a-z][a-z0-9_-]{0,39}$`: 1–40 characters,
starting with a lowercase ASCII letter, followed only by lowercase ASCII letters,
digits, underscores or hyphens. For example, `morgan_hale` is valid; `MorganHale`
is not. This applies to temporary batch keys, not titles or people's names.
References must match the key exactly: `` or `[[|Morgan Hale]]`.
Typed ID positions accept ``, including forward references, dependencies,
entities, owner, endpoints, source_page, identity candidates and continuity IDs.
Page edit `id` must identify an existing record, never ``. Authored body
wikilinks can use `[[ |label ]]` **without the spaces**, e.g.
`[[|Review]]` or `[[|Morgan]]`; these become stable-ID links at
publication, including self-links. Ordinary prose, fields, attribution, evidence
and original bytes are not substituted. Resolve actual entities before batching.
The whole batch is validated before acceptance. Receipt `items` maps keys to
IDs/paths/revisions/hashes; every item shares the batch's requestId, publication
state and Git checkpoint. A crash can leave partially installed files, but reads
are blocked until the existing journal finishes. Replay the exact request or
`knowledge_resume` with the batch requestId. No automatic rollback or conflict
bypass. Preserve the receipt; an accepted batch is not yet published.
An optional `source: {provider, key, sha256}` binds this **publication batch** to
an exact retained original. Its hash must match evidence on a batch record.
An unchanged source returns the prior receipt **without applying the new input**.
Changed bytes require `expectedPreviousRequestId` from source_check, after the
agent reconciles existing pages/assertions; this is not permission to overwrite
or duplicate them. Semantic correction still uses `knowledge_correct`.
Choose a stable key for a logical publication unit (include a stable segment ID
for split meetings). For additional batches, use separate stable unit keys or omit
source binding and retain their receipts; the first receipt does not cover all
later entity enrichment. There is no extraction/workflow-completion ledger.
## Publish one page
Keep a fresh UUID `requestId` and the exact payload for each distinct save. Use
the JSON tool arguments, not shell interpolation of imported text.
Create payload shape (replace the symbolic values with observed/generated ones):
```json
{
"requestId": "<new UUID>",
"expectedVaultId": "<observed vault UUID>",
"type": "note",
"title": "Source title",
"body": "Attributed summary with source citations"
}
```
Replace the symbolic UUIDs before use and add `attachments` as an array of
returned evidence objects when attaching originals. An edit additionally
supplies `id`, `expectedRevision`, and `expectedHash` from the complete current
read. Creates must omit those three fields: client-chosen IDs are not supported.
The page body is limited to 48,000 characters; this is NOT an original-file limit.
Keep long originals attached and write a focused page; never silently truncate
the original to make it fit.
The backend chooses descriptive filenames from titles; do not predict a slug or
choose a client-side ID. For a new source page needing self-citations, publish its
substantive body with retained evidence first, then use the returned path for
readable inline self-links. Likewise add cross-links after target pages exist.
Read the current revision/hash before each follow-up edit and preserve unrelated
content/metadata. The workflow is not complete until final links pass the shared
readback checks. After a rename, reread preconditions even if body bytes did not
change; the observer may have advanced the revision.
## Retry and reconcile
The shared service serializes vault operations, including reads, so simultaneous
tool/UI calls cannot invalidate one another's publication snapshot. Individual calls are not
a batch transaction or cross-process writer lock; publish_batch is the explicit
multi-record journal operation. Keep dependent calls sequential
(create before linking; read current preconditions before editing).
- Lost/uncertain save response: inspect `knowledge_mutation({requestId, includeFiles: false})`. Replay
the exact payload with that ID, or use `knowledge_resume({requestId})` for a
known accepted publication. Never replace an uncertain request with a new ID.
A null receipt is not proof of failure while a call is still in flight; wait
for it to settle and replay the original payload/ID. Uploads use their chunk
receipts instead of `knowledge_mutation`.
- `state: accepted` is durable intent, not completion. `state: published` means
the page was saved. `indexed: false` describes publication-time state; a fresh
search reconciles indexing. A pending/unavailable Git checkpoint does not undo
publication or justify another save.
- A rejection before acceptance leaves no saved draft. Preserve the proposed
text, reread, reconcile changes, then use a new request ID for the new payload.
- `state: conflict` retains recovery material. Inspect mutation/history and
report the conflict; resume does not resolve it. Do not overwrite, bypass
preconditions, delete the journal or blindly loop. A repeated unchanged failure
needs inspection, not more retries.
- Invalid arguments/ontology fields: correct the payload against the actual
tool schema and `knowledge_ontology({view: "definitions", name: "<type>"})`.
Do not retry unchanged validation failures. Page evidence uses `attachments`;
claims/relationships use `evidence`; collection fields replace, not merge.
- Vault identity/checkpoint/storage unavailable: this is not an API credential
error. Inspect the original mutation/history and availability. If availability
returns, retry the exact request; if it persists, report the blocker rather
than changing credentials, vault configuration or request IDs.
- For several records, keep an itemized work log of source identity, upload request
IDs/evidence, page/claim/relationship request IDs/exact payloads, returned record IDs and verified
outcomes. Use authorized task storage if durable continuation is needed; this
is an agent work log, not a Knowledge ingestion checkpoint. If it is lost,
inspect history and existing pages before proceeding. When uncertain whether
an item was published, stop that item rather than create a possible duplicate.
`knowledge_publish_batch` provides a bounded multi-record logical publication,
not whole-workflow atomicity, rollback, semantic dedup or extraction-job resume.
For recovery material request `knowledge_mutation` files only when needed and
follow `nextOffset` (at most 3 files/call).
## Supported structured assertions
`knowledge_create_claim` publishes one claim with title/body, claim_kind
(fact/preference/decision/commitment/event/belief), assertion_origin
(source/user_belief/agent_inference), attribution and nonempty retained evidence.
`knowledge_create_relationship` publishes from/to page IDs, a declared ontology
label, title/body, attribution and evidence. Both require a fresh requestId and
`expectedOntologyFingerprint` from `knowledge_ontology`; also supply observed
expectedVaultId. Existing source evidence can be reused with verified locators.
Claims may reference page `entities` and record `dependencies`; relationships may
have dependencies and ontology fields. References must be active and authorized.
A commitment may have a known owner page ID and due_at. An event may have
occurred_at. Dates preserve source precision (date-only or timestamp with explicit
timezone); unknown values remain absent. Valid_from/valid_until/expires_at use the
exact snake-case keys `valid_from`, `valid_until`, `expires_at` and UTC timestamps.
Capture never schedules work. Unresolved speakers remain attributed source labels.
These create tools do not deduplicate semantically or overwrite claims. Use
`knowledge_correct` for a revision-fenced evidence-backed replacement and
`knowledge_withdraw` for an explicit retraction, and `knowledge_merge` when two pages
are one entity; follow the knowledge-correct skill.
Use the same publication/retry/readback rules above. Inspect typed metadata with
`knowledge_record` and incoming/outgoing edges, reverse dependencies or entity
claims with `knowledge_connections`; paginate and verify evidence. Do not report
full ingestion completion merely because individual assertions published. The agent
reconciles the workflow using this work log and the existing per-write guarantees;
there is no ingestion-system prerequisite.
## Choose assertions and reconcile reruns
### Structured context and continuity
Create operations and page saves accept `source_page`, `record_class`, `identity`,
`attribution_confidence` and `continuity` where semantically applicable. Inspect
the actual tool schema. Source pages must already exist; do not reference a
page's own ID as `source_page`. Use the meeting/source ID on the extracted
assertions and attendance edges. This groups source context, not an ingestion job.
`attribution_confidence: {level: "high"|"medium"|"low", basis, evidence}` means
speaker/identity attribution confidence only. Preserve source-grounded reasoning;
do not invent a calibrated truth score or replace assertion origin with it.
Use `knowledge_annotate` for revision/hash-fenced contextual metadata updates or
`addEvidence` on an unchanged assertion. Supply a fresh request ID, observed
vault, ID/revision/hash, reason and `annotations` object (empty is allowed only
with added evidence). Omitted annotations are preserved; supplied arrays replace.
Read back the receipt and record. This operation cannot change assertion text or
lifecycle; historical records accept only fixture classification.
Before creating another claim, compare meaning, owner, source and dates:
- Same assertion and same source: reuse the existing ID.
- Same assertion with additional source support: append verified evidence with
`knowledge_annotate`; preserve the original statement and attribution. New
evidence must support the same qualifications, not merely a related subject.
- A separately useful dated reaffirmation, updated plan or contrary account:
create the sourced claim and add `continuity: [{id, relation: "reaffirms" |
"updates" | "contradicts", basis, evidence}]`. This does NOT supersede the
earlier claim, establish completion, or make the newer source authoritative.
- An explicit correction: use `knowledge_correct`, not an annotation or silent
replacement. Missing/uncertain outcomes still follow mutation replay rules.
- A standing statement (preference, decision, rule) that the same person or
authority later explicitly replaces: `knowledge_correct` the earlier claim with
the new one; the reason quotes the replacing statement. Different holders,
contrary evidence or your own inference never qualify; use `continuity`.
An event claim that specifically represents the source meeting itself may set
`source_event: true` with its `source_page`. Keep one shared event association for
all relevant entities. Do not mark other events mentioned in a meeting this way.
The UI can fold this representation into a meeting entry without deleting it.
Use structured records for independently useful, sourced assertions, not every
sentence of a summary. Keep the page as readable synthesis with inline citations.
| Source meaning | Claim representation |
| ------------------------------- | --------------------------------------------------------------------------------------------------------- |
| Material factual statement | `claim_kind: fact`, `assertion_origin: source`, attribution names the actual source |
| Explicit decision | `decision`; preserve conditions, decision maker and source date in body/attribution |
| Explicit commitment | `commitment`; resolved `owner` when known, `due_at` only when supported |
| Dated event / timeline material | `event`; `occurred_at` at source precision, all relevant resolved page IDs in `entities` |
| Stated belief/preference | `belief`/`preference`; source origin for a document's speaker, `user_belief` for the user's own assertion |
| Agent analysis worth saving | appropriate kind with `agent_inference`; evidence supports the premises, not an invented quotation |
One independently correctable assertion per claim. Holder/speaker belongs in
attribution; `entities` describes resolved relevant pages, not automatic endorsement.
Unknown speaker identity does not block a source-attributed claim, but omit a
claimed owner or person association that would guess that identity. Proposals,
jokes and provisional targets are not decisions or commitments unless the source
actually establishes that meaning.
Publish the source page and resolved endpoint/entity pages before dependent
assertions. Supply the source page ID in `dependencies`, relevant entity page IDs
in `entities`, and retained original evidence with verified locators in `evidence`.
If an assertion genuinely relies on another claim, include that claim dependency;
do not add dependencies merely for every prose mention. Dependencies are not
citations: inactive dependencies can withhold dependent records from discovery.
Before creating on a rerun:
1. Resolve the source page by source ID/hash/content. Inspect its
`knowledge_connections({id, direction: "dependents"})` and relevant entities'
`claims` plus `incoming`/`outgoing` edges. Follow `nextOffset` with unchanged
filters; restart a paginated read if `snapshot` changes.
2. Read candidate metadata, evidence and lifecycle. Compare assertion meaning,
speaker, qualifications, event/date, entity IDs, and original evidence. For
relationships compare directed endpoints, label and evidential context, not
only the pair. Use lookup/grep when existing records lack dependencies.
3. Reuse a matching active assertion. A genuinely different source assertion may
coexist with contrary evidence; do not silently supersede. New source coverage
does not justify recreating all assertions already accounted for.
4. If a work-log request has an uncertain outcome, inspect `knowledge_mutation`
and replay/resume the original payload. If missing from active results, inspect
known IDs/history (and `historical: true` connections where appropriate) before
inferring absence. Never resurrect a withdrawn/superseded assertion on reimport.
If you cannot determine the outcome safely, mark the item unresolved.
5. An explicit correction uses `knowledge-correct`; reconcile affected source-page
prose and entity references within scope. A new request ID is not a way around
a conflict or a changed payload under an existing ID.
Structured create example (replace placeholders with observed/generated values):
```json
{
"requestId": "<new UUID>",
"expectedVaultId": "<observed vault UUID>",
"expectedOntologyFingerprint": "<observed fingerprint>",
"title": "Send reliability report",
"body": "Speaker 2 offered to send the report on Friday; their identity is unresolved.",
"claim_kind": "commitment",
"assertion_origin": "source",
"attribution": "Speaker 2, retained transcript line 5",
"dependencies": ["<meeting page ID>"],
"evidence": [
{
"path": "<returned artifact path>",
"sha256": "<returned hash>",
"start_line": 5,
"end_line": 5
}
]
}
```
This intentionally omits owner and due date: neither an anonymous label nor a
relative date without adequate date context supplies a resolved value. Creating
this claim records the source statement; it does not assign work or schedule it.