Skip to content

refactor(storage, conversation): Store base config separately#515

Merged
JeanMertz merged 1 commit intomainfrom
prr84
Apr 5, 2026
Merged

refactor(storage, conversation): Store base config separately#515
JeanMertz merged 1 commit intomainfrom
prr84

Conversation

@JeanMertz
Copy link
Copy Markdown
Collaborator

Previously, events.json packed the conversation's base config as a synthetic first element — a ConfigDelta containing the full AppConfig. This made the file difficult to inspect: opening it in an editor meant scrolling past hundreds of lines of config JSON before reaching actual conversation events.

The base config is now stored in a separate base_config.json file, written once at conversation creation time and never overwritten. events.json contains only InternalEvent entries (config deltas and conversation events), with no synthetic leading element.

The custom Serialize/Deserialize impls on ConversationStream are removed in favour of explicit from_parts/to_parts methods used by the storage layer. InternalEvent is demoted from pub to pub(crate) since nothing outside jp_conversation references it.

The compat module's deserialize_config_delta is renamed to deserialize_partial_config and now operates directly on PartialAppConfig. A new deserialize_config_delta in stream.rs delegates to it for the timestamp + delta extraction pattern used when deserializing individual ConfigDelta stream events.

Backward compatibility is handled transparently in the load path: if base_config.json is absent, the loader falls back to extracting the base config from the first element of events.json. On the next persist, base_config.json is written and events.json is rewritten without the leading config entry.

Implements RFD 054.

Previously, `events.json` packed the conversation's base config as a
synthetic first element — a `ConfigDelta` containing the full
`AppConfig`. This made the file difficult to inspect: opening it in an
editor meant scrolling past hundreds of lines of config JSON before
reaching actual conversation events.

The base config is now stored in a separate `base_config.json` file,
written once at conversation creation time and never overwritten.
`events.json` contains only `InternalEvent` entries (config deltas and
conversation events), with no synthetic leading element.

The custom `Serialize`/`Deserialize` impls on `ConversationStream` are
removed in favour of explicit `from_parts`/`to_parts` methods used by
the storage layer. `InternalEvent` is demoted from `pub` to `pub(crate)`
since nothing outside `jp_conversation` references it.

The `compat` module's `deserialize_config_delta` is renamed to
`deserialize_partial_config` and now operates directly on
`PartialAppConfig`. A new `deserialize_config_delta` in `stream.rs`
delegates to it for the timestamp + delta extraction pattern used when
deserializing individual `ConfigDelta` stream events.

Backward compatibility is handled transparently in the load path: if
`base_config.json` is absent, the loader falls back to extracting the
base config from the first element of `events.json`. On the next
persist, `base_config.json` is written and `events.json` is rewritten
without the leading config entry.

Implements RFD 054.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz merged commit 05ea9e7 into main Apr 5, 2026
12 checks passed
@JeanMertz JeanMertz deleted the prr84 branch April 5, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant