Compare commits

..

2 Commits

Author SHA1 Message Date
Jarvis
aac4e51f14 fix(backlog): claim locks one ready row (LIMIT 1) to prevent claimer starvation
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 09:45:21 -05:00
Jarvis
e42ae47505 feat(fleet): native Mosaic backlog on @mosaicstack/db (atomic claim + TTL)
Add Mosaic's own backlog-of-record on the existing Postgres storage layer,
replacing the former Hermes adapter (no Hermes dependency) and the earlier
sqlite idea (no sqlite, no new client).

- packages/db: `backlog` table (drizzle) + enum + migration 0011; BacklogService
  taking a Db handle so it runs on both createDb (server PG) and createPgliteDb
  (embedded). Atomic claim via SELECT ... FOR UPDATE SKIP LOCKED inside one tx,
  TTL claims + reclaim of expired, deps DAG gate, idempotency-key dedup, stats.
- packages/mosaic: `mosaic fleet backlog <sub> --json` (create/list/claim/
  reclaim/link/stats/block/complete). Embedded PGlite default at
  <mosaicHome>/fleet/backlog; full Postgres via DATABASE_URL — same code.
  Migrations run on first use.
- install.sh: preserve fleet/backlog across `mosaic update`.
- docs/fleet/backlog-conventions.md: schema, phase convention, atomic-claim +
  TTL semantics, PGlite-default/Postgres-by-config, Mosaic-native (no Hermes).
- Tests (in-memory PGlite, real PG semantics): create/list, exactly-one-winner
  concurrency (and N-card no-double-claim), deps gate, reclaim of expired, stats.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 09:41:02 -05:00
3 changed files with 26 additions and 82 deletions

View File

@@ -7,7 +7,7 @@
## Mission ## Mission
A self-driving Mosaic system that 24/7 unattended converts a machine-readable goal set into merged, CI-green, budget-bounded change — looping plan→backlog→assign→execute→verify→merge→reassess — on Mosaic's OWN native backlog/dispatch engine. Mosaic is general-purpose: the user declares the system type they want (software delivery, personal assistant, research, business/operations, …) and the orchestrator provisions the matching persona roster and structure; the delivery fleet is one profile among many. A self-driving Mosaic delivery fleet that 24/7 unattended converts a machine-readable goal set into merged, CI-green, budget-bounded change — looping plan→backlog→assign→execute→verify→merge→reassess — on Mosaic's OWN native backlog/dispatch engine.
## Substrate ## Substrate
@@ -23,7 +23,6 @@ The Mosaic Backlog is the backlog of record + dispatch engine, built on Mosaic's
- **NS-6** — Context cleared between tasks for ephemeral runners (reset_between_tasks); persona+mission re-injected per task. - **NS-6** — Context cleared between tasks for ephemeral runners (reset_between_tasks); persona+mission re-injected per task.
- **NS-7** — Meta-loop (session-review + enhancer) continuously proposes small fleet-improvement PRs. - **NS-7** — Meta-loop (session-review + enhancer) continuously proposes small fleet-improvement PRs.
- **NS-8** — Single operator-flippable PAUSE kill-switch (fleet/run/PAUSED) honored before every dispatch and every merge. - **NS-8** — Single operator-flippable PAUSE kill-switch (fleet/run/PAUSED) honored before every dispatch and every merge.
- **NS-9** — Mosaic is a general-purpose multi-agent system: the user declares the SYSTEM TYPE to run (e.g. software delivery, personal assistant, research, business/operations) and the orchestrator provisions the matching persona roster and org structure from a cross-domain baseline persona library; the delivery/coding fleet is one profile among many.
## Success criteria ## Success criteria
@@ -32,25 +31,22 @@ The Mosaic Backlog is the backlog of record + dispatch engine, built on Mosaic's
- **AC-NS-3** — No PR merges with failure/error/no-status/timeout CI, and none bypass pr-merge.sh. - **AC-NS-3** — No PR merges with failure/error/no-status/timeout CI, and none bypass pr-merge.sh.
- **AC-NS-4** — TTL is enforced on claims; token caps remain advisory until a real meter exists. - **AC-NS-4** — TTL is enforced on claims; token caps remain advisory until a real meter exists.
- **AC-NS-5** — Flipping fleet/run/PAUSED halts dispatch and merges within one tick. - **AC-NS-5** — Flipping fleet/run/PAUSED halts dispatch and merges within one tick.
- **AC-NS-6** — A user can declare a system type and the fleet provisions the matching persona roster + topology from the baseline library, with no code change.
- **AC-NS-7** — A user-customized persona (edited or added via the orchestrator) survives `mosaic update`: baseline reseed never clobbers user overrides.
## Workstreams ## Workstreams
| id | title | | id | title |
| --- | ----------------------------------------------------------------------------------------------------------- | | --- | ---------------------------------------------------------------- |
| A | Substrate — Mosaic Backlog on native Postgres storage service | | A | Substrate — Mosaic Backlog on native Postgres storage service |
| B | Supervisor — movement guarantee, two-agent floor, dispatch/claim | | B | Supervisor — movement guarantee, two-agent floor, dispatch/claim |
| C | Planner — goal decomposition into independently-shippable cards | | C | Planner — goal decomposition into independently-shippable cards |
| D | Merge-gate — single approver, pr-merge.sh after CI wait | | D | Merge-gate — single approver, pr-merge.sh after CI wait |
| E | Meta-loop — session-review + enhancer improvement PRs | | E | Meta-loop — session-review + enhancer improvement PRs |
| F | Safety-rails — TTL claims, advisory spend, PAUSE kill-switch | | F | Safety-rails — TTL claims, advisory spend, PAUSE kill-switch |
| H | Personas & system profiles — cross-domain library, system-type provisioning, update-surviving customization |
## Goals (backlog projection) ## Goals (backlog projection)
| id | title | phase | priority | depends_on | | id | title | phase | priority | depends_on |
| --- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | ----------- | ---------- | | --- | ---------------------------------------------------------------------- | ----- | ----------- | ---------- |
| A1 | Machine-readable NORTH_STAR.yaml + Markdown projection | 1 | must-have | — | | A1 | Machine-readable NORTH_STAR.yaml + Markdown projection | 1 | must-have | — |
| A2 | Mosaic Backlog schema + storage-service card store (drizzle/PGlite) | 1 | must-have | A1 | | A2 | Mosaic Backlog schema + storage-service card store (drizzle/PGlite) | 1 | must-have | A1 |
| A3a | Card lifecycle — create/claim/release with stable ids + depends_on DAG | 1 | must-have | A2 | | A3a | Card lifecycle — create/claim/release with stable ids + depends_on DAG | 1 | must-have | A2 |
@@ -61,17 +57,12 @@ The Mosaic Backlog is the backlog of record + dispatch engine, built on Mosaic's
| B3a | Planner decompose — goal added to YAML → cards | 2 | must-have | A2, B1 | | B3a | Planner decompose — goal added to YAML → cards | 2 | must-have | A2, B1 |
| B3b | Replan request on empty backlog; escalate on no-decompose | 2 | should-have | B3a | | B3b | Replan request on empty backlog; escalate on no-decompose | 2 | should-have | B3a |
| G1 | PAUSE kill-switch + merge-gate honored before dispatch and merge | 2 | must-have | B2 | | G1 | PAUSE kill-switch + merge-gate honored before dispatch and merge | 2 | must-have | B2 |
| H1 | Cross-domain baseline persona library (exec, marketing, ops, research, assistant + engineering roles) | 1 | must-have | A1 |
| H2 | System-type profiles — declarative mapping of system type to persona roster + topology | 2 | must-have | H1 |
| H3 | System-type provisioning — user declares type; orchestrator instantiates the matching roster + structure | 2 | must-have | H2 |
| H4 | Update-surviving persona customization — ad-hoc edits/additions persisted in a PRESERVE-protected override layer (baseline merged with overrides) | 2 | must-have | H1 |
## Assumptions (vetoable) ## Assumptions (vetoable)
- **ASM-1** (vetoable) — The Mosaic Backlog on the native Postgres storage service is the backlog of record. - **ASM-1** (vetoable) — The Mosaic Backlog on the native Postgres storage service is the backlog of record.
- **ASM-2** (vetoable) — Claude gate roles have no native busy status, so readiness = pane-idle + heartbeat. - **ASM-2** (vetoable) — Claude gate roles have no native busy status, so readiness = pane-idle + heartbeat.
- **ASM-3** (vetoable) — Two-agent floor = 1 orchestrator + >=1 enhancer. - **ASM-3** (vetoable) — Two-agent floor = 1 orchestrator + >=1 enhancer.
- **ASM-4** (vetoable) — Baseline personas ship in framework/fleet/roles/ (reseeded on update); user overrides live in a separate PRESERVE_PATHS-protected layer and win on merge.
## Spend ## Spend

View File

@@ -12,13 +12,10 @@
version: 1 version: 1
mission: >- mission: >-
A self-driving Mosaic system that 24/7 unattended converts a machine-readable A self-driving Mosaic delivery fleet that 24/7 unattended converts a
goal set into merged, CI-green, budget-bounded change — looping machine-readable goal set into merged, CI-green, budget-bounded change —
plan→backlog→assign→execute→verify→merge→reassess — on Mosaic's OWN native looping plan→backlog→assign→execute→verify→merge→reassess — on Mosaic's OWN
backlog/dispatch engine. Mosaic is general-purpose: the user declares the native backlog/dispatch engine.
system type they want (software delivery, personal assistant, research,
business/operations, …) and the orchestrator provisions the matching persona
roster and structure; the delivery fleet is one profile among many.
substrate: substrate:
note: >- note: >-
@@ -62,13 +59,6 @@ standing_objectives:
text: >- text: >-
Single operator-flippable PAUSE kill-switch (fleet/run/PAUSED) honored Single operator-flippable PAUSE kill-switch (fleet/run/PAUSED) honored
before every dispatch and every merge. before every dispatch and every merge.
- id: NS-9
text: >-
Mosaic is a general-purpose multi-agent system: the user declares the
SYSTEM TYPE to run (e.g. software delivery, personal assistant, research,
business/operations) and the orchestrator provisions the matching persona
roster and org structure from a cross-domain baseline persona library; the
delivery/coding fleet is one profile among many.
success_criteria: success_criteria:
- id: AC-NS-1 - id: AC-NS-1
@@ -90,14 +80,6 @@ success_criteria:
- id: AC-NS-5 - id: AC-NS-5
text: >- text: >-
Flipping fleet/run/PAUSED halts dispatch and merges within one tick. Flipping fleet/run/PAUSED halts dispatch and merges within one tick.
- id: AC-NS-6
text: >-
A user can declare a system type and the fleet provisions the matching
persona roster + topology from the baseline library, with no code change.
- id: AC-NS-7
text: >-
A user-customized persona (edited or added via the orchestrator) survives
`mosaic update`: baseline reseed never clobbers user overrides.
workstreams: workstreams:
- id: A - id: A
@@ -112,8 +94,6 @@ workstreams:
title: Meta-loop — session-review + enhancer improvement PRs title: Meta-loop — session-review + enhancer improvement PRs
- id: F - id: F
title: Safety-rails — TTL claims, advisory spend, PAUSE kill-switch title: Safety-rails — TTL claims, advisory spend, PAUSE kill-switch
- id: H
title: Personas & system profiles — cross-domain library, system-type provisioning, update-surviving customization
goals: goals:
- id: A1 - id: A1
@@ -166,26 +146,6 @@ goals:
phase: 2 phase: 2
priority: must-have priority: must-have
depends_on: [B2] depends_on: [B2]
- id: H1
title: Cross-domain baseline persona library (exec, marketing, ops, research, assistant + engineering roles)
phase: 1
priority: must-have
depends_on: [A1]
- id: H2
title: System-type profiles — declarative mapping of system type to persona roster + topology
phase: 2
priority: must-have
depends_on: [H1]
- id: H3
title: System-type provisioning — user declares type; orchestrator instantiates the matching roster + structure
phase: 2
priority: must-have
depends_on: [H2]
- id: H4
title: Update-surviving persona customization — ad-hoc edits/additions persisted in a PRESERVE-protected override layer (baseline merged with overrides)
phase: 2
priority: must-have
depends_on: [H1]
assumptions: assumptions:
- id: ASM-1 - id: ASM-1
@@ -201,12 +161,6 @@ assumptions:
- id: ASM-3 - id: ASM-3
vetoable: true vetoable: true
text: 'Two-agent floor = 1 orchestrator + >=1 enhancer.' text: 'Two-agent floor = 1 orchestrator + >=1 enhancer.'
- id: ASM-4
vetoable: true
text: >-
Baseline personas ship in framework/fleet/roles/ (reseeded on update);
user overrides live in a separate PRESERVE_PATHS-protected layer and win
on merge.
spend: spend:
advisory: true advisory: true

View File

@@ -25,8 +25,7 @@ describe('NORTH_STAR.yaml', () => {
it('parses to a typed object with the required top-level keys', async () => { it('parses to a typed object with the required top-level keys', async () => {
const ns = await loadParsed(); const ns = await loadParsed();
expect(ns.version).toBeTypeOf('number'); expect(ns.version).toBeTypeOf('number');
expect(ns.mission).toContain('self-driving Mosaic system'); expect(ns.mission).toContain('self-driving Mosaic delivery fleet');
expect(ns.mission).toContain('Mosaic is general-purpose');
expect(ns.substrate.note).toBeTruthy(); expect(ns.substrate.note).toBeTruthy();
expect(ns.standing_objectives.length).toBeGreaterThan(0); expect(ns.standing_objectives.length).toBeGreaterThan(0);
expect(ns.success_criteria.length).toBeGreaterThan(0); expect(ns.success_criteria.length).toBeGreaterThan(0);