Skip to content

feat: sqlite storage, web settings, squads and agent upgrades - #40

Merged
douglasjunior merged 70 commits into
mainfrom
feat/improvements
Nov 26, 2026
Merged

douglasjunior merged 70 commits into
mainfrom
feat/improvements

Conversation

@douglasjunior

@douglasjunior douglasjunior commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

One delivery of a set of improvements. Here is what each part changes:

  • Every domain store moves from JSON files to SQLite.
  • Settings are edited from the web app, including the Discord bot token.
  • Squads are reusable agent/model/effort presets per role.
  • The conversation screen gets one navigation, built for phones.
  • A UX/UI designer agent joins the team, with design skills.
  • The developer, product owner and tech lead prompts are sharper.
  • Steering knows whether each provider supports it.
  • A feature can span several projects, and a task can change several nested repositories of its project.

Changes

Storage: SQLite (TypeORM + better-sqlite3)

  • modules/database/: DATA_DIR/arc.sqlite, versioned migrations run on boot, WAL, and a synchronous SqliteTransactionService for every read-change-write.
  • Stores:
    • web conversations, histories and prompt history;
    • preferences and settings;
    • agent settings (one row per conversation and role, so concurrent profiles.set no longer lose a write);
    • the whole board in relational tables: artifacts, refinements per kind, sections, dependencies, pull requests, history, counters;
    • agent sessions and open work.
  • Legacy import on first boot: every old JSON file is imported once in a transaction and moved to 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:legacy runs it by hand.

Settings from the web (/settings)

  • Resolution order: saved value > environment variable > default. An empty env var now overrides .env.
  • Changes apply live; only STT_PROVIDER needs a restart. Secrets are write-only.
  • settings.set and settings.reset carry a requestId, answered to the requester by settings.result after the settings broadcast.
  • Timer settings (*_MS) are capped at 2^31 - 1 ms, above which Node fires a timer at once.
  • Discord: the bot restarts when its token, server or on/off flag change. "Test connection" checks a typed token before it is saved.

Squads

  • /squads: CRUD of presets per role, with a default squad for new conversations.
  • In the conversation settings sheet: "Apply squad", "Squad X · customized" and "Save as squad". Per-role editing stays as before.
  • Discord: /squad.

Web navigation

  • Conversation screen: one route-driven Chat | Tasks | Squad navigation on phones. On desktop it is Chat | Tasks, with the squad as the side panel.
  • Board: one List | Kanban toggle. Filters fold into a bottom sheet on narrow boards, and kanban columns get chips.
  • Header: fits at 320px; Skills, Settings and the theme move into a "More" menu.
  • Fix: earlier conversation pages are requested once per position (a race sent duplicate requests).

Agents

  • Developer: a ### Checks procedure:

    • find the checks once and record them in a Checks: line;
    • run only the changed files while working;
    • run only the affected packages before the verdict;
    • never the whole monorepo unless shared root config changed.
    • New running-checks skill.
  • Product owner and tech lead:

    • interviews run in rounds over the frontier of open decisions;
    • facts are looked up, not asked;
    • each recommendation comes with its reason;
    • a final round confirms the summary.
    • The tech lead hands over per-file and per-package check commands.
  • UX/UI designer (UX_DESIGNER):

    • Refinement becomes a list of kinds (business, design, technical). Design is skipped unless asked.
    • The designer settles the design between discovery and technical planning, with fast and robust regimes.
    • Its prototype lives on a design/<id>-<slug> branch that is never merged, and it reviews its own work visually.
    • New ux_design section and 11 design skills; four of them are shared with the developer.
  • Steering a busy agent:

    • The CEO sees whether each working agent supports steering, and must pick on_busy="wait|interrupt" when it does not or when the work differs.
    • Interrupting the same task reuses the ACP session.
    • Instructions are kept with the open work, so they survive a restart.
    • Confirmations no longer cost an extra CEO round.
    • Fixes the assignment race when replacing an agent.
    • An agent at work keeps its project folders against other roles until it ends, whatever on_busy says.
    • Each <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:

    • Each conversation has one inbox and runs one turn at a time.
    • A message that arrives while the CEO is mid-prompt is steered when its agent supports steering, and waits for the next round otherwise.
    • While the CEO waits for delegates, a message joins the current turn instead of starting a concurrent one.
    • Steered and queued messages survive retry, failure and restart.
    • A round carrying the user's message counts as user-initiated.
    • Stop also cancels the waiting messages, including one whose steering comes back undelivered after the stop.
    • Each message shows how it was delivered (queued, steered, delivered, cancelled) on the web, and Discord posts matching notices.

Multi-project features

  • Board:
    • A feature links one or more projects (projectNames), and each task works in exactly one of them.
    • A task under a single-project feature takes that project by default.
    • A project still used by tasks cannot be removed from its feature.
  • Pull requests: each link records its repository, the path of the git repository inside the task's project (. for the project folder).
  • Database: migrations add the artifact_project table, make artifact.project_name nullable (table rebuild), add artifact_pull_request.repository and key feature sessions to the workspace root.
  • Feature delegations:
    • Feature delegations (product owner, tech lead, UX designer) run from the workspace root.
    • The delegation block lists the project folders the agent may change.
    • project= is refused for a feature.
    • Within a conversation, a feature's agent occupies every project of the feature and a task's agent occupies its project.
  • Prompts:
    • An initiative across projects is one feature.
    • The developer uses the task's branch in every nested repository it changes, with one pull request per repository.
    • A missing base branch is created by Git Ops on demand.
    • The reviewer and QA cover every repository of the task.
  • Web:
    • Features take a multi-select of projects, and a task picks only among its feature's projects.
    • The list shows a feature under each of its projects with only that project's tasks.
    • Kanban chips show first +N.

Agent protocol and sessions

  • Every turn ends with exactly one <final_response> block; a response with several is repaired, and the CEO prompt keeps its answer inside the block.
  • A resumed session gets the full system prompt again when its role prompt changed (agent_session.prompt_hash).
  • The developer delivers the whole task in its turn and answers INCOMPLETE only for a blocker outside its reach.
  • The CEO can force a new session on a task for the developer, reviewer and QA.
  • Antigravity session updates that arrive outside a prompt (late history replay after session/load) are dropped.

PROTOCOL_VERSION is 5.

Testing

  • pnpm ts, pnpm lint, pnpm test, pnpm test:cov and pnpm test:e2e pass on the branch.
  • Legacy imports were checked by booting against old DATA_DIRs, and a second boot is a no-op.
  • The navigation, settings, squads and the narrow header were checked in a browser at 320, 390 and 1280 px.
  • The multi-project migration was checked on a populated database, up and down; the multi-project web UI is covered by specs but was not checked in a browser.

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 douglasjunior left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 douglasjunior left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@douglasjunior
douglasjunior merged commit 6dd2e3c into main Nov 26, 2026
2 checks passed
@douglasjunior
douglasjunior deleted the feat/improvements branch November 26, 2026 15:10
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