Repository navigation
feat: P1+P2 backend completion — 37 REST endpoints - #156
Merged
Merged
Conversation
- Add std::mutex to protect pending_agent_runs_ from concurrent access across HTTP threads, eliminating data race in start_agent_run and capture_agent_result. - In capture_agent_result, always erase the map entry regardless of run completion status, preventing unbounded memory growth from abandoned runs.
Add POST /api/worldbuilding/:wid/scenes/:sid/rewrite to start an agent-driven rewrite, and GET .../:sid/rewrite-result to retrieve it.
Adds a background poller thread that monitors pending agent runs and calls capture_agent_result when a run reaches Completed state. Terminal states (Failed, Cancelled, Interrupted) are cleaned up without capturing. The poller wakes immediately when a new run is started via start_agent_run, then falls back to a 2-second interval when idle.
19 endpoints across 5 modules: Pipeline control, Diary/Memory/Relation APIs, World import/export, Knowledge Graph queries, Timeline API. All synchronous CRUD, no async agent-driven flows.
- Wrap state fields under "state" key, add "ok": true at top level - Validate to_phase against creative_phase_from_string before retreating - Include recent_history in retreat response matching pipeline/state handler
Implements POST /api/worldbuilding/import to import a snapshot JSON exported by the export-full endpoint. Remaps all IDs to new IDs via make_id() and creates all entities in dependency order: - World, locations (two-pass parent fixup), agents (individuals, managers, groups), relations, arcs, chapters, scenes, diaries, memory summaries, factions (two-pass rival fixup), knowledge, foreshadowing (two-pass cross-refs), secrets, timeline events - Stores import metadata in world config - Imports inline base64 images (up to 256KB) via image_service_ - Adds base64_decode to ids.hpp for inline image decoding - Returns world_id, full id_mapping, and images_imported count
Add list_timeline_events and get_timeline_event to NarrativeStore, plus three HTTP endpoints: timeline list, timeline event get, and timeline advance (using time_label field).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
P1+P2 backend completion: 37 REST endpoints on top of P0.
P1 (18 endpoints)
Agent card/diary/relations CRUD, chapter export, scene/chapter PATCH, image upload, character appearances, Pipeline management, agent-driven previews, consistency checks, suggestions, scene generation, outline generation, rewrite
P2 (19 endpoints)
Pipeline retreat/clear-error, diary search/patch, memory summaries, voice fingerprint, relations upsert, world export/import, knowledge graph queries, timeline
Changes
libs/http/— WorldbuildingHttpHandler: 37 new handlerslibs/worldbuilding/— PipelineManager, WorldbuildingService, NarrativeStore: 5 new methodsdocs/api-reference.md— full API reference, endpoint count 104 → 123Test plan
cmake --build build