Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

chore(view): merge trunk for delta catch-up [N26,A2]

Corey Olson8c9a7675ff8d
diff --cc src/cockpit.js
index 023599ad,97c13d28..0b17bcfd
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@@ -3,10 -4,19 +4,20 @@@ import
IN_STATE,
MACHINE,
} from './machine.js';
+ import {
+ STAR_KEY,
+ starMarkup,
+ } from './view/star.js';
import { commandPhrases } from './help.js';
import { personNeeds } from './needs.js';
+ import {
+ drawHosted,
+ hostedBrowser,
+ hostedMarkup,
+ hostedState,
+ } from './view/hosted.js';
import { staleChip } from './view/stale.js';
+import { applyStateDelta } from './api-http.js';
/** The CLI's default phrases, ordered by depth for the existing prose inventory guard. */
export const PULLBOARD_COMMANDS = Object.freeze(commandPhrases().sort((left, right) => right.split(' ').length - left.split(' ').length));
diff --cc test/cockpit/live.test.js
index 66ac7bce,0427f59f..0f67e30e
--- a/test/cockpit/live.test.js
+++ b/test/cockpit/live.test.js
@@@ -299,30 -272,6 +299,65 @@@ test('a catch-up that cannot read the s
}
});
+// #555's fallback: when the server cannot extend the state the page holds, as after it forgot that base, the
+// answer resets and the page loads a fresh snapshot instead.
+test('a catch-up whose base the server does not keep loads a fresh snapshot [N26,A2]', async () => {
+ const box = machine();
+ const alpha = project(box, 'reset-alpha');
+ box.run(alpha.repo, 'add', 'web', 'Before', '--specs', 'G1', '--criterion', 'renders');
+ const view = await startView(box);
+ try {
+ const page = await openPage(view);
+ // Sequence 0 is a base this server never sent, so its answer resets with BASE_NOT_KEPT.
+ page.run('[...sentStates.values()].forEach((held) => { held.sequence = 0; })');
+ box.run(alpha.repo, 'add', 'web', 'After', '--specs', 'G1', '--criterion', 'renders');
+ const mark = page.requests.length;
+ await page.run(`refresh(new Set([${JSON.stringify(alpha.repo)}]))`);
+ const reads = page.requests.slice(mark).map((request) => request.path).filter((path) => /\/state(?:\?|$)/.test(path))
+ .map((path) => new URL(path, 'http://page').searchParams.get('since'));
+ assert.deepEqual(reads, ['0', null], 'the page asked for a delta, was told to reset, and read one fresh snapshot');
+ assert.deepEqual(JSON.parse(page.run('JSON.stringify(data.project.items.map((item) => item.title).sort())')), ['After', 'Before'], 'the fresh snapshot shows the change');
+ assert.equal(page.run(`[...sentStates.values()][0].sequence`), page.run('data.project.sequence'), 'the fresh snapshot is the next base');
+ } finally {
+ await view.stop();
+ }
+});
+
++/** Prove a reset response loads exactly one fresh snapshot and establishes the next delta base. */
++async function resetDeltaBase(label, corrupt) {
++ const box = machine();
++ const alpha = project(box, label);
++ box.run(alpha.repo, 'add', 'web', 'Before reset', '--specs', 'G1', '--criterion', 'renders');
++ const view = await startView(box);
++ try {
++ const page = await openPage(view);
++ page.run(corrupt);
++ const since = page.run('[...sentStates.values()][0].sequence');
++ box.run(alpha.repo, 'add', 'web', 'After reset', '--specs', 'G1', '--criterion', 'renders');
++ const mark = page.requests.length;
++ await page.run(`refresh(new Set([${JSON.stringify(alpha.repo)}]))`);
++ const reads = page.requests.slice(mark).map((request) => request.path).filter((path) => /\/state(?:\?|$)/.test(path))
++ .map((path) => new URL(path, 'http://page').searchParams.get('since'));
++ assert.deepEqual(reads, [String(since), null], 'a reset is followed by exactly one full snapshot');
++ assert.deepEqual(JSON.parse(page.run('JSON.stringify(data.project.items.map((item) => item.title).sort())')),
++ ['After reset', 'Before reset'], 'the recovered snapshot shows the real move');
++ assert.equal(page.run('[...sentStates.values()][0].sequence'), page.run('data.project.sequence'),
++ 'the recovered snapshot replaces the obsolete delta base');
++ } finally {
++ await view.stop();
++ }
++}
++
++// A reset/restored board can have fewer events than the page holds; the corrected #555 bar includes BASE_AHEAD.
++test('a catch-up ahead of the server loads a fresh snapshot [N26,A2]', async () => {
++ await resetDeltaBase('reset-ahead', '[...sentStates.values()].forEach((held) => { held.sequence += 1000000; })');
++});
++
++// Event-log formats are versioned independently of a board's sequence.
++test('a catch-up with a different event format loads a fresh snapshot [N26,A2]', async () => {
++ await resetDeltaBase('reset-format', '[...sentStates.values()].forEach((held) => { held.version = "different-format"; })');
++});
++
/**
* A project group of `count` real repos, opened in real Chrome as the group, where a claim on `mover`'s item must
* show within two seconds while the page follows every repo on one stream.