Repository navigation
feat: sqlite storage, web settings, squads and agent upgrades - #40
Merged
Merged
Conversation
Add @nestjs/typeorm, typeorm and better-sqlite3 to the server. typeorm 1.x declares better-sqlite3 ^12 as its peer, so the driver stays on 12.x. better-sqlite3 is a native module whose install script downloads the prebuilt binary for the platform and Node ABI (linux x64 and arm64 glibc included). pnpm 12 refuses to install a dependency with an unapproved build script, so pnpm-workspace.yaml allows it with allowBuilds.
Add the database module: TypeORM over better-sqlite3 at DATA_DIR/arc.sqlite in WAL mode, with versioned migrations run on boot and entities and migrations listed as classes. The web conversations and the prompt history move from JSON files to the conversation, conversation_entry and prompt_history tables, behind the same ports. An entry upsert is one statement that keeps the position of a stored entry and gives a new one the next position, so the debounced writes of the JSON store are gone and flush has nothing left to write. On boot, before the server takes connections, LegacyJsonImportService runs every registered importer not yet recorded in legacy_import, each in one transaction, and moves the files it read to DATA_DIR/legacy-json-backup/<timestamp>/. The legacy files are read under the locks their JSON stores wrote them with; a corrupt file is logged and left in place. pnpm migrate:legacy runs the same import without starting the server.
SqliteTransactionService runs a read-change-write as one immediate better-sqlite3 transaction on the connection TypeORM holds, so no other query of the process or of another process lands between its read and its write.
Add the settings module: a catalog of the runtime settings, a SQLite store, saved values over environment variables over defaults, and a change notifier. The config services, the whisper adapter, the idle timeout, the allowed origins, the log retention and remote access read through it, and remote access restarts when its settings change. The user language moves to SQLite with a legacy importer. An empty environment variable now wins over the .env file.
The Discord client starts, stops and restarts from the settings, on a new discord.js client each time, and registers the slash commands again when the shell or agent login flags change. DISCORD_ENABLED turns the bot off. A use case tests a bot token, and a server, through the REST API before it is saved.
The web channel answers settings.get, settings.set, settings.reset and settings.discord.test, broadcasting every saved change. The /settings page, behind a gear icon in the header, shows each setting by section with where its value comes from, checks drafts with the protocol schemas, keeps secrets write-only, tests the Discord token before it is saved and tells which settings need a restart.
One row per conversation and one per role, changed in one transaction, and the agent-settings.json of earlier versions imported once.
A squad saves the agent, model and effort of each role and is copied into a conversation in one go; the default squad is what a conversation without settings starts with. The web channel lists, saves, deletes and applies squads, and the profiles event says which squad a conversation applied and whether a role left it. PROTOCOL_VERSION is 4.
A squads page lists, edits and deletes squads, and the conversation settings sheet applies one, shows whether the roles still match it and saves the conversation's roles as a new squad. The role editor is controlled, so the sheet and the squad editor share it.
One route-driven ConversationNav replaces the narrow-window tabs and the header switch: Chat | Tasks | Squad across the width below 820 px, Chat | Tasks in the header above it, where the squad stays the side panel. The new /c/:id/squad route opens the panel on a wide window. Selecting a waiting station from another section goes to the chat before scrolling to the question.
The board view is one List | Kanban toggle group, and the kanban's task or feature cards become a Cards choice among the filters. Below @2XL of the board the filters fold into a bottom sheet behind a Filters button that counts the active ones, New turns icon-only, and the kanban snaps one column at a time with chips to jump between columns. The kanban ignores the list's type filter.
The button variants put inline-flex after the hidden class, so the Skills and Settings links stayed visible beside the More menu on narrow screens. Merging the classes keeps them hidden there.
The developer finds the project's checks once per task and records them in a Checks line of its notes, runs only the checks of the files it changes while it works and the full checks of the affected packages before its verdict. A running-checks skill gives the developer, the reviewer and the tester the per-file and per-package commands of each ecosystem.
The Product Owner and the Tech Lead map the decisions and their dependencies before the first round, ask every decision whose prerequisites are settled in each round, look up facts instead of asking them, recommend with the reason of their area and confirm a summary of the decisions before writing the board. The Tech Lead also gives the commands that check one changed file and each affected package.
Every board lives in relational tables keyed by conversation and artifact id, with the JSON boards imported once on boot.
The ACP session bindings of each conversation live in the session and agent_session tables, with sessions.json imported once on boot.
The work a restart interrupts lives in the open_work table, with open-work.json imported once on boot.
Refinements become a list of kinds, business, design and technical, that every rule, request attribute, tool schema, prompt and channel iterates. The create command of the web channel takes one switch per kind, so the protocol version rises to 6. Stored artifacts without the design kind read it as skipped. Adds the ux_design section.
The UX_DESIGNER settles the design refinement between the business refinement and technical planning. It designs screens, flows and states, proves them in a prototype on a design branch that is never merged and records the design in the ux_design section. The CEO routing lists the refinements in the order of their kinds.
Eleven built-in skills hold the interface design craft: visual foundations, layout, responsive and mobile, interaction states, accessibility, motion, data visualization, design systems, prototyping, UX writing and visual polish. The designer prompt says which to read for which moment; the developer reads the four it needs to build an interface.
The UX Designer joins the team between the Product Owner and the Tech Lead, at the Design stage, with a pen-nib glyph whose ink pulses while it works and a coral color token for the light and dark themes.
A refinement left out of a creation takes its entry in DEFAULT_REFINEMENT_STATES, the map that also fills a kind an artifact was stored without: business and technical are owed, design is skipped, so only work that asks for a design owes one. The skills and the tool schemas say so. Owed refinements read as a proper list, and the protocol version stays at 5, a single bump since version 4.
A delegation to a role already at work goes to that agent as the CEO chooses with on_busy. On the same work of an agent that takes steering the instruction is steered into the running prompt, or kept for its next prompt when it is between prompts, never restarting it. "wait" runs the instruction after the current run, in the same session on the same work, and "interrupt" cancels the running prompt and continues in the same session, or ends other work and waits for its artifact to be released before starting. The validator asks for on_busy where steering cannot apply. sendSteeringPrompt reports injected, not_running, unsupported or failed, without the prompt fallback, and the unused steering activity is gone. Each coding agent's steering support is recorded at connect and shown in [TEAM_PROFILES], instructions reach the agent framed as [INSTRUCTION_UPDATE], channels get a steered delegation event, the open work keeps every instruction after its task, and receipts reach the CEO with its next prompt instead of a round of their own.
The core prompt says when a delegation to an agent already at work needs on_busy, and the delegation-protocol skill explains steering, waiting and interrupting, what each costs and the receipts that follow.
The virtual list calls the load callback it holds on its own schedule, so a call landing after a click, before the render that followed, passed the same guard and sent conversation.entries twice for one position. The hook now decides from refs.
The create dialog specs rendered the whole app for every case and the squad creation spec drove four selects in one test; under the full coverage run they reached the 5 s limit. The dialog now renders over its providers alone, with one case opening it from the board, and the squad creation splits the role profile picks into their own test.
A conversation runs one turn at a time. A message that arrives while one runs joins its inbox: it is steered into the CEO's prompt running when the CEO's agent takes steering, read with the next prompt of the turn otherwise, read at once in a round of its own when the CEO waits for its delegates, and starts the next turn when the turn ends first. Turns resuming interrupted work wait for the running one. Steered and read messages are part of the turn's input: a prompt that carried one validates as user-initiated, a retried prompt carries the messages steered into it, the root's open work keeps every message that joined, and a failed or cancelled turn tells the next one which messages it had read. A stop cancels the messages still waiting. Channels hear onDelivery (queued, steered, delivered, cancelled). The web user_message gains a delivery chip, a message that joined gets no agent_response, and recaps, the team state, the delivery moment and the working indicator follow one turn at a time. Discord posts a notice for each delivery.
douglasjunior
commented
Nov 20, 2026
douglasjunior
left a comment
Owner
Author
There was a problem hiding this comment.
Review findings, one inline comment each, ordered by severity. Found by reading the code; pnpm ts, pnpm lint and pnpm test were not run for this review. Not covered in depth: the second half of run-delegation.use-case.ts, the legacy JSON importers, the web package, the prompts and the skills.
Turn each entry of a history written by an earlier version into a current ConversationEntry: steered responses become notices, missing roles, delegation ids and question fields get documented defaults, and an entry that stays invalid becomes a warning notice instead of being dropped.
The web-conversations importer rejected a whole history file for a single invalid entry and was recorded as done, so those conversations stayed empty for good. Split the histories into the web-histories importer, which runs after web-conversations, converts every entry through the upgrader and imports a file only when its conversation exists and has no entries. Installs that already recorded web-conversations recover their leftover files on the next boot. Files of no conversation and *.tmp leftovers stay in place and are logged.
A conversation whose leftover history file was not imported may have gained entries since. The web-histories importer now places the file's entries before the existing ones, shifting their positions inside the import transaction, and skips a file whose entry ids the conversation already holds.
Add a constant for `CLAUDE_CODE_ARTIFACT` to enable artifacts in Clovis sessions and set it in the environment during agent initialization.
The CEO's Response Protocol said text outside protocol tags reaches the user, while the final response rules said text outside <final_response> is only narration. Agents that followed the first rule never used the envelope, so their notes before tool calls joined the answer. The repair prompts now name the block too.
A response with several final response blocks is answered again through the protocol repair instead of joined, and the instructions state that a turn has exactly one block, last in the turn.
The INCOMPLETE verdict covered anything short of done, so a developer ended each delegation after a small step without any blocker. It now covers only what is outside the developer's reach, and the prompt and the re-entry note ask for the whole task in one turn.
A resumed session received only the short re-entry note, so a session created before a prompt change kept the old rules for good. The session binding now records a hash of the system prompt the agent received, with the skill catalog that goes with it. A resumed session whose hash differs from the current system prompt, or has none, gets the full system prompt again and the new hash is stored.
DEVELOPER, CODE_REVIEWER and QA take session="new" again, with the default staying the session of the task. With an artifact, a delegation that sets session="new" starts a fresh session for the task and replaces its stored binding, so later delegations resume the new one. A new session cannot join the prompt running in the session being left, so for a role already working on that task it needs on_busy like other work does: wait starts it after the current run, interrupt ends the current work first. The validator accepts session with an artifact only for roles whose contract has a session mode. The agent-team and delegation-protocol skills show the attribute and say when to use it.
A feature links one or more project folders (projectNames) and a task
works in exactly one (projectName), which must be one of its feature's
projects. A task under a feature without a project takes the feature's
only project, and is refused when the feature links several.
Removing a project a task still works in from a feature is refused, and
a task changes project or feature only within its feature's projects.
A pull request link carries the repository relative to the task's
project folder ("." by default), so a task can change several
repositories of its project.
The migration adds artifact_project, makes artifact.project_name
nullable by rebuilding the table, adds artifact_pull_request.repository
and moves each feature's project into artifact_project. The legacy JSON
importer reads files with a single projectName per artifact.
Agent board tags and tools accept projects for features and repository
on pull requests. The web interface reads the new shapes and keeps
working with a feature's first project.
The agent of a feature works from the workspaces root, so its session has no project. Sessions stored under the first project of a feature take that key and are resumed.
A delegation with a feature runs at the workspaces root and names the project folders its agent may change in the delegated artifact block and in the context of its updates. The project attribute is refused with a feature. One agent that modifies files works in each project folder: a feature takes every project of its feature, a task its own. The stopped-work prompt names every project.
A feature spans several projects and a task works in one project that may hold several git repositories. The board prompts and skills say so; the Developer works on the task branch in each repository it changes and opens one pull request per repository, recorded with its repository; a missing base branch is INCOMPLETE; Git Ops creates it on demand and merges each pull request; the Code Reviewer and QA judge every repository of the task.
A feature picks and edits several projects with a combobox of chips, a task under a multi-project feature picks one of its projects, the list shows a feature under each of its projects with that project's tasks, and the kanban chip shows the first project plus a count.
Antigravity can answer session/load before its history replay ends. The rest of the replay reached the next prompt of the resumed session: the feed showed earlier work and an old final response became the agent's answer.
douglasjunior
commented
Nov 22, 2026
douglasjunior
left a comment
Owner
Author
There was a problem hiding this comment.
Review of the server package: three issues worth fixing before merge, one bug that already exists on main, and one comment-wording nit. Details are in the inline comments.
Migrations run before the legacy importers, so KeyFeatureSessionsToRoot never sees the sessions and open work imported from the JSON files. The importers apply the same rule to the features the artifacts importer wrote.
A stop that reached a delegation after it stopped waiting, or while it was opening, found no cancel handler in place, so the delegation ran its whole task while the stopped turn waited for it. Each started delegation remembers the stop, open() checks it around the assignment, and the cancel handler is set as soon as the delegation is registered. The agent port and its info are created before the artifact is assigned, so an agent that cannot be created leaves the artifact free.
A round prompt and a steering during it both read the pending agent receipts, so the CEO could get a receipt twice, and the count-based acknowledgement could then drop a receipt that arrived later. Each prompt now takes the receipts it carries, a retry carries again the ones steered into it, and a prompt that does not deliver them gives them back in the order they arrived. A steering that came back undelivered after the user stopped the turn put its messages back in the inbox, and they drove a new turn. They are cancelled instead. A steering that throws counts as not delivered, so its messages wait for the next prompt.
Any delegation to a role at work freed that agent's folders for the other roles, while steered, kept, queued and waiting work keeps running there, and an interrupted agent is still stopping while the other delegations of the response start. An agent at work now keeps its folders until it ends, and a delegation never conflicts with the agent of its own role.
Node fires a timer at once when its delay is above 2^31 - 1 ms, so a timeout saved above about 24 days expired immediately.
An importer that reads the rows of another ran and was recorded even when that one had failed, so it imported nothing (web histories) or keyed feature sessions and open work to a project, and never ran again. An importer now names the importers it requires and waits for a boot on which they are all recorded.
The settings page took any `settings` event as the answer to a save, such as the one fetched after a reconnect or another page's broadcast, and any `error` without a conversation as its failure. `settings.set` and `settings.reset` now carry a `requestId` that `settings.result` answers, and a connection that closes before the answer ends the wait with the drafts kept.
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
One delivery of a set of improvements. Here is what each part changes:
Changes
Storage: SQLite (TypeORM + better-sqlite3)
modules/database/:DATA_DIR/arc.sqlite, versioned migrations run on boot, WAL, and a synchronousSqliteTransactionServicefor every read-change-write.profiles.setno longer lose a write);DATA_DIR/legacy-json-backup/<timestamp>/. Corrupt files are logged and left in place. An importer that reads another's rows (requires) waits for a boot on which that one is recorded.pnpm migrate:legacyruns it by hand.Settings from the web (
/settings).env.STT_PROVIDERneeds a restart. Secrets are write-only.settings.setandsettings.resetcarry arequestId, answered to the requester bysettings.resultafter thesettingsbroadcast.*_MS) are capped at 2^31 - 1 ms, above which Node fires a timer at once.Squads
/squads: CRUD of presets per role, with a default squad for new conversations./squad.Web navigation
Chat | Tasks | Squadnavigation on phones. On desktop it isChat | Tasks, with the squad as the side panel.List | Kanbantoggle. Filters fold into a bottom sheet on narrow boards, and kanban columns get chips.Agents
Developer: a
### Checksprocedure:Checks:line;running-checksskill.Product owner and tech lead:
UX/UI designer (
UX_DESIGNER):business,design,technical). Design isskippedunless asked.design/<id>-<slug>branch that is never merged, and it reviews its own work visually.ux_designsection and 11 design skills; four of them are shared with the developer.Steering a busy agent:
on_busy="wait|interrupt"when it does not or when the work differs.on_busysays.<agent_result>receipt reaches the CEO once, in the round prompt or in a steered message, and a retry carries again the receipts steered into it.User messages to the CEO:
Multi-project features
projectNames), and each task works in exactly one of them.repository, the path of the git repository inside the task's project (.for the project folder).artifact_projecttable, makeartifact.project_namenullable (table rebuild), addartifact_pull_request.repositoryand key feature sessions to the workspace root.project=is refused for a feature.first +N.Agent protocol and sessions
<final_response>block; a response with several is repaired, and the CEO prompt keeps its answer inside the block.agent_session.prompt_hash).INCOMPLETEonly for a blocker outside its reach.session/load) are dropped.PROTOCOL_VERSIONis 5.Testing
pnpm ts,pnpm lint,pnpm test,pnpm test:covandpnpm test:e2epass on the branch.DATA_DIRs, and a second boot is a no-op.