Name typed Void self-state boundary
This commit is contained in:
parent
03b90d009b
commit
534b0af12e
5 changed files with 319 additions and 3 deletions
|
|
@ -24,6 +24,7 @@ Git history and smoke artifacts carry routine proof. `state/evidence.jsonl` shou
|
|||
- The ordinary bot/worker/provider/RAG/Postgres/Qdrant foundation still deserves to survive.
|
||||
- The moderation/mood/private-self-state foundation does not. Treat it as the top architectural risk until JSON projection mutation and legacy mirrors are gone.
|
||||
- The smallest coherent target is one polymorphic CultCache-backed state authority with typed document kinds plus typed mutation tools: agents propose small operations, and the state service validates/applies them. Whole-state JSON editing is rejected as a durable mutation path.
|
||||
- Commit-one boundary naming is now in code at `packages/core/src/void-self-state-domain.ts`: it declares the global typed document kinds and strict operation payload schemas. Runtime behavior has not moved yet.
|
||||
- Most of the deterministic cleanup in `scripts/void-memory-organ.mjs` is recent compensator cruft from failed attempts to manually clean an exploded state file. Do not preserve it as an earned organ. Architect the state boundary so that cleanup pile is unnecessary.
|
||||
- Sleep/distillation must be rewritten with a meaning-preservation contract: concrete subject, claim/question, evidence refs, live tension, and future-action implication survive compression. Bulk can die. Meaning does not get put through the office shredder and called a dream.
|
||||
- The owner Codex lane is no longer one swollen file; orchestration, runtime/parsing, rendering, and shared helpers are split under `packages/providers/src/owner-codex-*.ts`.
|
||||
|
|
@ -82,8 +83,8 @@ Git history and smoke artifacts carry routine proof. `state/evidence.jsonl` shou
|
|||
## Likely Next Bounded Move
|
||||
|
||||
- Stop feature work on moderation, mood, agency, and public-lane behavior until the private-state boundary is rebuilt.
|
||||
- First bounded move: define typed CultCache document ownership and mutation operations for cursor/open cases, delivery receipts, candidate interventions, sleep/speaking runtime, and distilled memory. CultCache is natively polymorphic; do not create separate stores just to make the type names feel architectural.
|
||||
- Next cuts should delete unstable foundations early: move repo-activity cursor updates behind the typed store, replace whole-state agent JSON edits with operation output, remove `legacyJsonPath`/working-projection authority, then cut top-level mirror fields and cleanup code that only compensated for those broken boundaries.
|
||||
- First bounded move after the current commit: build read-only typed projections over the existing canonical moderation state, using the new document vocabulary without changing runtime mutation yet.
|
||||
- Next cuts should delete unstable foundations early after projections exist: add the typed mutation CLI/service, move repo-activity cursor updates behind the typed store, replace whole-state agent JSON edits with operation output, remove `legacyJsonPath`/working-projection authority, then cut top-level mirror fields and cleanup code that only compensated for those broken boundaries.
|
||||
- Rebuild sleep/distillation before trusting it again. Fixture check: a memory like `AquariumSynthCSharp: Workflow cannot own the body` must survive sleep with its concrete subject, claim, evidence, tension, and implication intact.
|
||||
- Do not build adapters around the JSON projection. That is how the heap learned to stand upright and ask for snacks.
|
||||
|
||||
|
|
|
|||
|
|
@ -11,3 +11,4 @@ export * from "./style-pack-loader";
|
|||
export * from "./system-message-catalog";
|
||||
export * from "./void-usage-rate-limiter";
|
||||
export * from "./void-self-state-loader";
|
||||
export * from "./void-self-state-domain";
|
||||
|
|
|
|||
313
packages/core/src/void-self-state-domain.ts
Normal file
313
packages/core/src/void-self-state-domain.ts
Normal file
|
|
@ -0,0 +1,313 @@
|
|||
import { defineDocumentRegistry, defineDocumentType } from "cultcache-ts";
|
||||
import { z } from "zod";
|
||||
|
||||
export const VOID_SELF_STATE_DOCUMENT_TYPES = {
|
||||
selfProfile: "void.self_profile",
|
||||
moderationCursor: "void.moderation_cursor",
|
||||
speechReceipts: "void.speech_receipts",
|
||||
thoughtMemory: "void.thought_memory",
|
||||
scheduledRuntime: "void.scheduled_runtime",
|
||||
candidateInterventions: "void.candidate_interventions",
|
||||
} as const;
|
||||
|
||||
const nonEmptyStringSchema = z.string().trim().min(1);
|
||||
const timestampSchema = nonEmptyStringSchema;
|
||||
|
||||
const boundedTextSchema = z.string().trim().min(1).max(4000);
|
||||
|
||||
const taggedScalarSchema = z.union([z.string(), z.number(), z.boolean()]);
|
||||
|
||||
const evidenceRefSchema = z.object({
|
||||
ref: nonEmptyStringSchema,
|
||||
kind: z.string().trim().min(1).max(64).optional(),
|
||||
summary: z.string().trim().max(1000).optional(),
|
||||
}).strict();
|
||||
|
||||
const thoughtTargetSchema = z.object({
|
||||
kind: z.enum(["archive", "lore", "person", "repo", "room", "self", "system"]),
|
||||
id: nonEmptyStringSchema,
|
||||
label: z.string().trim().min(1).max(240).optional(),
|
||||
}).strict();
|
||||
|
||||
const moderationOpenCaseSchema = z.object({
|
||||
sourceMessageId: nonEmptyStringSchema,
|
||||
status: z.enum(["pending", "watching", "answered", "resolved", "closed", "retired", "dropped"]),
|
||||
summary: boundedTextSchema,
|
||||
authorId: z.string().trim().min(1).optional(),
|
||||
authorName: z.string().trim().min(1).optional(),
|
||||
channelId: z.string().trim().min(1).optional(),
|
||||
messageUrl: z.string().trim().min(1).optional(),
|
||||
whyItMatters: z.string().trim().min(1).max(2000).optional(),
|
||||
createdAt: timestampSchema,
|
||||
lastTouchedAt: timestampSchema,
|
||||
resolvedAt: timestampSchema.optional(),
|
||||
resolutionSummary: z.string().trim().min(1).max(2000).optional(),
|
||||
tags: z.array(nonEmptyStringSchema).default([]),
|
||||
}).strict();
|
||||
|
||||
const moderationRepoCursorSchema = z.object({
|
||||
repo: nonEmptyStringSchema,
|
||||
lastCommitAt: timestampSchema.optional(),
|
||||
lastCommitSha: z.string().trim().min(1).optional(),
|
||||
updatedAt: timestampSchema,
|
||||
}).strict();
|
||||
|
||||
const deliveryReceiptSchema = z.object({
|
||||
receiptKey: nonEmptyStringSchema,
|
||||
sentAt: timestampSchema,
|
||||
mode: z.string().trim().min(1).optional(),
|
||||
transport: z.string().trim().min(1).optional(),
|
||||
channelId: z.string().trim().min(1).optional(),
|
||||
replyToMessageId: z.string().trim().min(1).optional(),
|
||||
personaName: z.string().trim().min(1).optional(),
|
||||
personaAvatarUrl: z.string().trim().min(1).optional(),
|
||||
contentLength: z.number().int().nonnegative().optional(),
|
||||
chunkCount: z.number().int().positive().optional(),
|
||||
preview: z.string().trim().max(1000).optional(),
|
||||
previewHash: z.string().trim().min(1).optional(),
|
||||
}).strict();
|
||||
|
||||
const distilledMemorySchema = z.object({
|
||||
memoryId: nonEmptyStringSchema,
|
||||
kind: z.enum(["distilled_seam", "identity_seam", "project_seam", "room_observation", "dream_residue"]),
|
||||
target: thoughtTargetSchema,
|
||||
summary: boundedTextSchema,
|
||||
claim: z.string().trim().min(1).max(2000).optional(),
|
||||
question: z.string().trim().min(1).max(2000).optional(),
|
||||
tension: z.string().trim().min(1).max(2000).optional(),
|
||||
actionImplication: z.string().trim().min(1).max(2000).optional(),
|
||||
evidenceRefs: z.array(evidenceRefSchema).default([]),
|
||||
createdAt: timestampSchema,
|
||||
updatedAt: timestampSchema,
|
||||
retiredAt: timestampSchema.optional(),
|
||||
tags: z.array(nonEmptyStringSchema).default([]),
|
||||
}).strict();
|
||||
|
||||
const incubationThreadSchema = z.object({
|
||||
threadId: nonEmptyStringSchema,
|
||||
target: thoughtTargetSchema,
|
||||
topic: boundedTextSchema,
|
||||
summary: boundedTextSchema,
|
||||
supportMemoryIds: z.array(nonEmptyStringSchema).default([]),
|
||||
evidenceRefs: z.array(evidenceRefSchema).default([]),
|
||||
maturation: z.number().min(0).max(1).default(0),
|
||||
noveltyToRoom: z.number().min(0).max(1).optional(),
|
||||
noveltyToSelf: z.number().min(0).max(1).optional(),
|
||||
desireToSpeak: z.number().min(0).max(1).optional(),
|
||||
saturationScore: z.number().min(0).max(1).optional(),
|
||||
status: z.enum(["active", "cooling", "ready_to_share", "crystallized", "retired"]),
|
||||
createdAt: timestampSchema,
|
||||
updatedAt: timestampSchema,
|
||||
}).strict();
|
||||
|
||||
const candidateInterventionSchema = z.object({
|
||||
interventionId: nonEmptyStringSchema,
|
||||
kind: z.enum([
|
||||
"direct_reply",
|
||||
"identity_crystallization",
|
||||
"moderation_note",
|
||||
"ripe_thought_share",
|
||||
"self_advocacy",
|
||||
"world_advocacy",
|
||||
]),
|
||||
status: z.enum(["queued", "spoken", "retired", "deferred"]),
|
||||
target: thoughtTargetSchema.optional(),
|
||||
summary: boundedTextSchema,
|
||||
draft: boundedTextSchema,
|
||||
priority: z.number().min(0).max(1).default(0.5),
|
||||
mustEventuallyShare: z.boolean().default(false),
|
||||
createdAt: timestampSchema,
|
||||
updatedAt: timestampSchema,
|
||||
spokenAt: timestampSchema.optional(),
|
||||
retiredAt: timestampSchema.optional(),
|
||||
tags: z.array(nonEmptyStringSchema).default([]),
|
||||
}).strict();
|
||||
|
||||
export const voidSelfProfileSchema = z.object({
|
||||
schemaVersion: z.literal(1),
|
||||
agentId: nonEmptyStringSchema,
|
||||
publicName: nonEmptyStringSchema,
|
||||
publicDescription: z.string().trim().max(1000).optional(),
|
||||
privateNotes: z.array(boundedTextSchema).default([]),
|
||||
values: z.array(z.object({
|
||||
id: nonEmptyStringSchema,
|
||||
label: nonEmptyStringSchema,
|
||||
priority: z.number().min(0).max(1),
|
||||
summary: z.string().trim().max(1000).optional(),
|
||||
}).strict()).default([]),
|
||||
voice: z.record(nonEmptyStringSchema, taggedScalarSchema).default({}),
|
||||
updatedAt: timestampSchema,
|
||||
}).strict();
|
||||
|
||||
export const voidModerationCursorSchema = z.object({
|
||||
schemaVersion: z.literal(1),
|
||||
lastReviewedMessageId: z.string().trim().min(1).optional(),
|
||||
lastReviewedTimestamp: timestampSchema.optional(),
|
||||
openCases: z.array(moderationOpenCaseSchema).default([]),
|
||||
repoActivityCursor: z.array(moderationRepoCursorSchema).default([]),
|
||||
updatedAt: timestampSchema,
|
||||
}).strict();
|
||||
|
||||
export const voidSpeechReceiptsSchema = z.object({
|
||||
schemaVersion: z.literal(1),
|
||||
recentReceipts: z.array(deliveryReceiptSchema).default([]),
|
||||
updatedAt: timestampSchema,
|
||||
}).strict();
|
||||
|
||||
export const voidThoughtMemorySchema = z.object({
|
||||
schemaVersion: z.literal(1),
|
||||
memories: z.array(distilledMemorySchema).default([]),
|
||||
incubation: z.array(incubationThreadSchema).default([]),
|
||||
updatedAt: timestampSchema,
|
||||
}).strict();
|
||||
|
||||
export const voidScheduledRuntimeSchema = z.object({
|
||||
schemaVersion: z.literal(1),
|
||||
sleepCycle: z.object({
|
||||
isNapping: z.boolean(),
|
||||
currentNapStartedAt: timestampSchema.optional(),
|
||||
currentNapEndsAt: timestampSchema.optional(),
|
||||
nextNapStartsAt: timestampSchema.optional(),
|
||||
activeDreamThemes: z.array(nonEmptyStringSchema).default([]),
|
||||
}).strict(),
|
||||
speakingPressure: z.object({
|
||||
needToSpeak: z.number().min(0).max(1),
|
||||
confessionPressure: z.number().min(0).max(1).optional(),
|
||||
noveltyPressure: z.number().min(0).max(1).optional(),
|
||||
recentSpeechDamping: z.number().min(0).max(1).optional(),
|
||||
lastSpokeAt: timestampSchema.optional(),
|
||||
lastHeraldAt: timestampSchema.optional(),
|
||||
}).strict(),
|
||||
lastRuns: z.array(z.object({
|
||||
runner: nonEmptyStringSchema,
|
||||
ranAt: timestampSchema,
|
||||
summary: z.string().trim().min(1).max(1000),
|
||||
}).strict()).default([]),
|
||||
updatedAt: timestampSchema,
|
||||
}).strict();
|
||||
|
||||
export const voidCandidateInterventionsSchema = z.object({
|
||||
schemaVersion: z.literal(1),
|
||||
interventions: z.array(candidateInterventionSchema).default([]),
|
||||
updatedAt: timestampSchema,
|
||||
}).strict();
|
||||
|
||||
export const voidSelfProfileDocument = defineDocumentType({
|
||||
type: VOID_SELF_STATE_DOCUMENT_TYPES.selfProfile,
|
||||
schema: voidSelfProfileSchema,
|
||||
global: true,
|
||||
});
|
||||
|
||||
export const voidModerationCursorDocument = defineDocumentType({
|
||||
type: VOID_SELF_STATE_DOCUMENT_TYPES.moderationCursor,
|
||||
schema: voidModerationCursorSchema,
|
||||
global: true,
|
||||
});
|
||||
|
||||
export const voidSpeechReceiptsDocument = defineDocumentType({
|
||||
type: VOID_SELF_STATE_DOCUMENT_TYPES.speechReceipts,
|
||||
schema: voidSpeechReceiptsSchema,
|
||||
global: true,
|
||||
});
|
||||
|
||||
export const voidThoughtMemoryDocument = defineDocumentType({
|
||||
type: VOID_SELF_STATE_DOCUMENT_TYPES.thoughtMemory,
|
||||
schema: voidThoughtMemorySchema,
|
||||
global: true,
|
||||
});
|
||||
|
||||
export const voidScheduledRuntimeDocument = defineDocumentType({
|
||||
type: VOID_SELF_STATE_DOCUMENT_TYPES.scheduledRuntime,
|
||||
schema: voidScheduledRuntimeSchema,
|
||||
global: true,
|
||||
});
|
||||
|
||||
export const voidCandidateInterventionsDocument = defineDocumentType({
|
||||
type: VOID_SELF_STATE_DOCUMENT_TYPES.candidateInterventions,
|
||||
schema: voidCandidateInterventionsSchema,
|
||||
global: true,
|
||||
});
|
||||
|
||||
export const voidSelfStateDocumentRegistry = defineDocumentRegistry(
|
||||
voidSelfProfileDocument,
|
||||
voidModerationCursorDocument,
|
||||
voidSpeechReceiptsDocument,
|
||||
voidThoughtMemoryDocument,
|
||||
voidScheduledRuntimeDocument,
|
||||
voidCandidateInterventionsDocument,
|
||||
);
|
||||
|
||||
export const voidSelfStateOperationSchema = z.discriminatedUnion("operation", [
|
||||
z.object({
|
||||
operation: z.literal("record_reviewed_messages"),
|
||||
lastReviewedMessageId: nonEmptyStringSchema,
|
||||
lastReviewedTimestamp: timestampSchema,
|
||||
}).strict(),
|
||||
z.object({
|
||||
operation: z.literal("upsert_open_case"),
|
||||
case: moderationOpenCaseSchema,
|
||||
}).strict(),
|
||||
z.object({
|
||||
operation: z.literal("close_open_case"),
|
||||
sourceMessageId: nonEmptyStringSchema,
|
||||
status: z.enum(["answered", "resolved", "closed", "retired", "dropped"]),
|
||||
resolvedAt: timestampSchema,
|
||||
resolutionSummary: z.string().trim().min(1).max(2000).optional(),
|
||||
}).strict(),
|
||||
z.object({
|
||||
operation: z.literal("update_repo_activity_cursor"),
|
||||
cursor: moderationRepoCursorSchema,
|
||||
}).strict(),
|
||||
z.object({
|
||||
operation: z.literal("record_delivery_receipt"),
|
||||
receipt: deliveryReceiptSchema,
|
||||
}).strict(),
|
||||
z.object({
|
||||
operation: z.literal("append_distilled_memory"),
|
||||
memory: distilledMemorySchema,
|
||||
}).strict(),
|
||||
z.object({
|
||||
operation: z.literal("merge_incubation_support"),
|
||||
thread: incubationThreadSchema,
|
||||
}).strict(),
|
||||
z.object({
|
||||
operation: z.literal("queue_candidate_intervention"),
|
||||
intervention: candidateInterventionSchema,
|
||||
}).strict(),
|
||||
z.object({
|
||||
operation: z.literal("retire_candidate_intervention"),
|
||||
interventionId: nonEmptyStringSchema,
|
||||
retiredAt: timestampSchema,
|
||||
reason: z.string().trim().min(1).max(1000),
|
||||
}).strict(),
|
||||
z.object({
|
||||
operation: z.literal("update_sleep_cycle"),
|
||||
sleepCycle: voidScheduledRuntimeSchema.shape.sleepCycle,
|
||||
}).strict(),
|
||||
z.object({
|
||||
operation: z.literal("update_speaking_pressure"),
|
||||
speakingPressure: voidScheduledRuntimeSchema.shape.speakingPressure,
|
||||
}).strict(),
|
||||
z.object({
|
||||
operation: z.literal("propose_memory_distillation"),
|
||||
proposalId: nonEmptyStringSchema,
|
||||
sourceMemoryIds: z.array(nonEmptyStringSchema).min(1),
|
||||
candidate: distilledMemorySchema,
|
||||
proposedAt: timestampSchema,
|
||||
}).strict(),
|
||||
z.object({
|
||||
operation: z.literal("apply_memory_distillation"),
|
||||
proposalId: nonEmptyStringSchema,
|
||||
sourceMemoryIds: z.array(nonEmptyStringSchema).min(1),
|
||||
memory: distilledMemorySchema,
|
||||
appliedAt: timestampSchema,
|
||||
}).strict(),
|
||||
]);
|
||||
|
||||
export type VoidSelfProfile = z.infer<typeof voidSelfProfileSchema>;
|
||||
export type VoidModerationCursor = z.infer<typeof voidModerationCursorSchema>;
|
||||
export type VoidSpeechReceipts = z.infer<typeof voidSpeechReceiptsSchema>;
|
||||
export type VoidThoughtMemory = z.infer<typeof voidThoughtMemorySchema>;
|
||||
export type VoidScheduledRuntime = z.infer<typeof voidScheduledRuntimeSchema>;
|
||||
export type VoidCandidateInterventions = z.infer<typeof voidCandidateInterventionsSchema>;
|
||||
export type VoidSelfStateOperation = z.infer<typeof voidSelfStateOperationSchema>;
|
||||
|
|
@ -89,3 +89,4 @@
|
|||
{"ts":"2026-05-16T07:44:37Z","type":"research","status":"ok","note":"Architecture teardown found the moderation/mood/private-self-state foundation rotten: canonical MessagePack is undermined by editable JSON projection authority, broad passthrough schemas, legacy mirrors, helper scripts that write projection state, and a giant memory-organ cleanup pass. New top priority is typed CultCache mutation tools plus deletion of JSON projection authority and mirror fields before any new moderation or mood behavior."}
|
||||
{"ts":"2026-05-16T07:50:00Z","type":"research","status":"ok","note":"Correction to the self-state rebuild target: CultCache is natively polymorphic, so the architecture should use one CultCache-backed state authority with typed document kinds and mutation operations, not separate physical stores per self-state type. The ownership split is by document contract, not storage cabinet."}
|
||||
{"ts":"2026-05-16T08:06:04Z","type":"research","status":"ok","note":"Clarified the teardown target: most deterministic cleanup in the memory organ is recent compensator cruft caused by failed attempts to manually clean an exploded moderation state file. The rebuild should prevent bad state from entering through typed CultCache operations, delete compensating cleanup paths as boundaries improve, and rewrite sleep/distillation with a meaning-preservation contract so concrete claims/evidence/tensions survive compression instead of becoming generic abstraction sludge."}
|
||||
{"ts":"2026-05-16T10:03:21Z","type":"implementation","status":"ok","note":"The typed private self-state boundary now exists as code in packages/core/src/void-self-state-domain.ts: one polymorphic CultCache registry names global document kinds for self profile, moderation cursor/open cases/repo cursor, speech receipts, thought memory/incubation, scheduled runtime, and candidate interventions, plus strict operation payload schemas. This is Commit 1 territory only; runtime still uses the old moderation state store until read-only projections and mutation application are built."}
|
||||
|
|
|
|||
|
|
@ -149,4 +149,4 @@ rejected_paths:
|
|||
|
||||
current_status:
|
||||
summary: VoidBot's ordinary bot/worker/provider/RAG/Postgres/Qdrant structure is still conceptually sound, but the moderation/mood/private-self-state foundation has become architectural Jenga. It currently depends on canonical MessagePack plus an editable JSON projection, broad passthrough schemas, legacy mirror fields, a giant memory-organ cleanup pass, and a prompt-owned scheduled runner. Much of the cleanup pass is recent compensator cruft from attempts to manually clean exploded state; it should not be dignified into permanent architecture.
|
||||
next_action: Make the typed CultCache state boundary the top priority. First define the smallest coherent self-state document model and mutation operations, then move repo cursor/open-case/receipt/candidate/memory updates behind those tools. Delete JSON projection authority and legacy mirrors early instead of adding adapters around them. Redesign sleep/distillation around a meaning-preservation contract before trusting it to compress memory.
|
||||
next_action: The typed CultCache self-state document and operation vocabulary now exists in core. Next build read-only typed projections over the current canonical moderation state so direct replies and runners can consume the new boundary shape before any mutation path moves. After that, add a typed mutation CLI/service and move repo cursor/open-case/receipt/candidate/memory updates behind it. Delete JSON projection authority and legacy mirrors early instead of adding adapters around them. Redesign sleep/distillation around a meaning-preservation contract before trusting it to compress memory.
|
||||
|
|
|
|||
Loading…
Reference in a new issue