flowviant 0.77.2 → 0.77.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/lib/work.mjs +51 -2
  2. package/package.json +1 -1
package/bin/lib/work.mjs CHANGED
@@ -567,6 +567,21 @@ export function createWorkManager({
567
567
  const worktreeSeen = new Set();
568
568
  let lastWorktreeFetch = 0;
569
569
  let sweepingWorktrees = false;
570
+ /**
571
+ * WHERE THE NEXT SWEEP STARTS.
572
+ *
573
+ * A safety valve with a rotation, and the rotation is the load-bearing half.
574
+ * The sweep used to take `activeIds.slice(0, 20)` — a silent truncation of a
575
+ * list the server builds tabs-first and agent places LAST, so on a project
576
+ * with twenty live tabs no agent was EVER measured: no branch diff, no head
577
+ * sha, and none of their trailered commits ever reached a card. Permanently,
578
+ * because the same twenty won every pass.
579
+ *
580
+ * Chunking removes the cut for any realistic project (see below). The cursor
581
+ * is what makes the residual cap fair rather than arbitrary: past it, the
582
+ * places that missed one sweep are the ones that lead the next.
583
+ */
584
+ let worktreeCursor = 0;
570
585
  const postWorktrees = async (reports) => {
571
586
  if (!reports.length) return;
572
587
  try {
@@ -800,12 +815,46 @@ export function createWorkManager({
800
815
  // landed. Best-effort like everything in this sweep.
801
816
  void landed.observe().catch(() => {});
802
817
  }
818
+ /**
819
+ * MEASURED IN CHUNKS, not truncated to one.
820
+ *
821
+ * The server's endpoint takes twenty entries per request, and this read
822
+ * that bound as "measure twenty places" — so everything past the
823
+ * twentieth was silently never measured, and the server builds that
824
+ * list with agent places at the END. A project with twenty live tabs
825
+ * therefore measured no agent at all: their review pane showed no
826
+ * branch diff, `checkIsStale` had no head to compare against, and their
827
+ * commits never reached the cards they name.
828
+ *
829
+ * The cap on a REQUEST is not a cap on the WORK. Several requests of
830
+ * twenty cost several round trips and each is validated per entry
831
+ * exactly as before, so no contract changes and no floor is needed.
832
+ *
833
+ * `SWEEP_MAX_PLACES` is a bound on the MACHINE — each place costs a
834
+ * `git diff`, a listener scan and a process scan — and the cursor
835
+ * rotates so a project past it still measures everything, just across
836
+ * successive sweeps instead of one.
837
+ */
838
+ const SWEEP_MAX_PLACES = 60;
839
+ const CHUNK = 20;
840
+ const total = activeIds.length;
841
+ const start = total > SWEEP_MAX_PLACES ? worktreeCursor % total : 0;
842
+ const take = Math.min(total, SWEEP_MAX_PLACES);
843
+ // Rotated slice, so the tail of a long list leads the next sweep rather
844
+ // than never being reached.
845
+ const order = Array.from({ length: take }, (_, i) => activeIds[(start + i) % total]);
846
+ worktreeCursor = total > SWEEP_MAX_PLACES ? (start + take) % total : 0;
803
847
  const reports = [];
804
- for (const id of activeIds.slice(0, 20)) {
848
+ for (const id of order) {
805
849
  const r = sessionWorktreeReport(id);
806
850
  if (r) reports.push(r);
807
851
  }
808
- await postWorktrees(reports);
852
+ // One POST per chunk. Awaited in sequence rather than fired together:
853
+ // this runs on the machine's own poll beat and a burst of parallel
854
+ // writes to the same rows buys nothing.
855
+ for (let i = 0; i < reports.length; i += CHUNK) {
856
+ await postWorktrees(reports.slice(i, i + CHUNK));
857
+ }
809
858
  } finally {
810
859
  sweepingWorktrees = false;
811
860
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowviant",
3
- "version": "0.77.2",
3
+ "version": "0.77.3",
4
4
  "description": "Run your own coding CLIs as build agents for Flowviant \u2014 Claude Code, Codex or Antigravity, on your own credentials. Holds your sessions, keeps a worktree per tab, and ships branches on your word.",
5
5
  "type": "module",
6
6
  "bin": {