Data model

Organization. Project. Many Learning Containers.

Each Container has a developer-set stable ID unique inside its Project. A Thread can stay unassigned or bind once to one Container in the same Organization and Project.

Schema

Scope and provenance stay in every row

Table or fieldJobKey identity
learning_containersProject-owned context and developer-facing identityorganization_id + project_id + stable id
threads.learning_container_idOptional immutable Thread bindingsame Organization + Project + Container
learning_runsQueue and runner stateOrganization + Project + Container + run
learning_run_snapshotsDerived immutable input identityexact agent run + assigned Thread + digest
learning_run_snapshot_membersFrozen ordered run inputrun + snapshot + scoped Container + ordinal
learning_insightsCited Learning outputrun + Container + evidence + Skill eligibility
learning_skillsPublished or retired artifactContainer + source Insight + revision
learning_skill_insightsFull Skill provenanceSkill + every supporting Insight + ordinal

Input contract

Reduce one run, then freeze it

1 · DISCOVER

Find terminal assigned runs

The harvester reads agent_runs, run_events, and the Thread’s immutable Container assignment.

2 · REDUCE

Keep the exact run

The canonical reducer reads events for that persisted agent run, not the Thread’s newer full history.

3 · DERIVE

Write a bounded snapshot

Object storage receives content-addressed derived bytes. Postgres stores scoped metadata and SHA-256.

4 · FREEZE

Build one bounded manifest

The first attempt caps snapshots, active Insights, and published Skills at 500 each, then selects stable Insight and Skill prefixes that leave room for the first snapshot.

Budget

No zero-snapshot escape hatch

The fixed context must fit first.

Container prompt text, active Insights, and published Skills share one token budget. The planner projects both semantic lists before packing snapshots and still rejects a fixed prompt that cannot fit on its own.

Provenance

A Skill keeps every cited reason

Insight → Skill is not a lossy copy.

Each Skill records its source Insight, change reason, immutable revision, published or retired state, and ordered links to all supporting Insights. Each Insight keeps Thread and message IDs for product review.