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
36 changes: 36 additions & 0 deletions examples/channel-memory/.claw-describe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": 2,
"description": "Channel-memory adapter for source-backed Discord channel awareness digests",
"endpoints": [
{
"method": "POST",
"path": "/ingest",
"description": "Retain one source channel message with stable message identity and content hash"
},
{
"method": "POST",
"path": "/source-messages",
"description": "Fetch exact retained source messages by channel and message id"
},
{
"method": "POST",
"path": "/digest",
"description": "Return deterministic digest blocks over retained source messages"
},
{
"method": "POST",
"path": "/coverage-gaps",
"description": "Record an explicit source coverage gap for a channel and time range"
},
{
"method": "POST",
"path": "/forget",
"description": "Suppress retained source messages and mark derived blocks dirty"
},
{
"method": "GET",
"path": "/health",
"description": "Health check"
}
]
}
15 changes: 15 additions & 0 deletions examples/channel-memory/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.23-alpine AS builder
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY examples/channel-memory ./examples/channel-memory
RUN CGO_ENABLED=0 go build -o /channel-memory ./examples/channel-memory

FROM alpine:3.20
RUN apk add --no-cache wget
COPY --from=builder /channel-memory /channel-memory
COPY examples/channel-memory/.claw-describe.json /.claw-describe.json
EXPOSE 8080
HEALTHCHECK --interval=5s --timeout=3s --retries=6 \
CMD wget -qO- http://localhost:8080/health > /dev/null || exit 1
CMD ["/channel-memory"]
59 changes: 59 additions & 0 deletions examples/channel-memory/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Channel Memory Adapter

This is the first executable slice of the digest-backed channel-awareness design.
It is a standalone HTTP service; `claw-wall` does not call it yet.

The adapter stores Discord-style channel messages in SQLite and keeps exact
source provenance for later digest-backed `channel-awareness` work.

## Endpoints

- `POST /ingest` stores one source message. Idempotency is keyed by
`(source_kind, channel_id, message_id, content_hash)`.
- `POST /source-messages` fetches exact retained source messages by channel and
message id. By default it returns the current non-deleted version; set
`include_history: true` to inspect older content-hash versions.
- `POST /digest` returns deterministic digest blocks over already-retained
messages. It does not call an LLM.
- `POST /coverage-gaps` records an explicit missing source range.
- `POST /forget` suppresses source messages and marks derived blocks dirty.
- `GET /health` reports process liveness.

## Deterministic Processor

The deterministic path is intentionally conservative:

- preserves obvious hard events as faithful `hard_event` blocks
- keeps ordinary retained content as `raw_excerpt` blocks
- collapses runtime/status noise into sparse `telemetry_count` blocks
- emits coverage-gap metadata from stored gap records
- creates tombstone blocks for deleted messages without carrying deleted content

Higher-quality `topic_rollup` and `sequence_rollup` blocks belong to the async
LLM worker tracked separately.

## Storage

State is stored under `CHANNEL_MEMORY_DIR` and defaults to
`/data/channel-memory`. Set `CHANNEL_MEMORY_DB` to choose an exact SQLite file.

The schema includes:

- `source_messages`
- `derived_blocks`
- `derived_block_sources`
- `coverage_gaps`
- `processing_queue`

`source_messages` uses explicit `observed_seq`, `observed_at`, and `is_current`
fields so edited messages create new rows while exact retrieval can still select
the current version deterministically.

## Build

This Dockerfile expects the repository root as build context because the service
uses the repository Go module:

```sh
docker build -f examples/channel-memory/Dockerfile -t channel-memory:latest .
```
Loading
Loading