fix(mindspace): release edited public pages and fix achievements dates
Memind CI / Test, build, and release guards (push) Successful in 3m37s

Finish now releases static HTML delivery contracts in a finally block so
re-edited pages are not stuck at HTTP 409, and M成果 groups pages by
Asia/Shanghai calendar dates to avoid duplicate day headings.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-13 06:41:40 +08:00
parent fdc234e5d0
commit 53b0d2c62f
6 changed files with 222 additions and 26 deletions
+41
View File
@@ -5,6 +5,7 @@ import {
markPageDeliveryContractReady,
normalizeDeliveryRelativePath,
preparePageDeliveryContract,
releaseMaterializedPageDeliveryContracts,
} from './mindspace-delivery-contract.mjs';
test('normalizes only safe public HTML delivery paths', () => {
@@ -40,3 +41,43 @@ test('contract lifecycle writes preparing then ready against the same route key'
assert.equal(await markPageDeliveryContractReady({ pool, userId: 'user-1', relativePath: 'public/form.html' }), true);
assert.ok(calls.some((call) => call.sql.includes("status = 'ready'")));
});
test('releaseMaterializedPageDeliveryContracts skips pg_required until allowed', async () => {
const calls = [];
const pool = {
async query(sql, params) {
calls.push({ sql, params });
if (sql.includes('SELECT id, data_mode')) {
const path = params?.[1];
if (path === 'public/form.html') {
return [[{ id: 'c1', data_mode: 'pg_required', status: 'preparing' }]];
}
if (path === 'public/report.html') {
return [[{ id: 'c2', data_mode: 'static', status: 'preparing' }]];
}
return [[]];
}
if (sql.includes("status = 'ready'")) return [{ affectedRows: 1 }];
return [{ affectedRows: 0 }];
},
};
assert.deepEqual(
await releaseMaterializedPageDeliveryContracts({
pool,
userId: 'user-1',
relativePaths: ['public/form.html', 'public/report.html'],
allowPgRequired: false,
}),
['public/report.html'],
);
assert.deepEqual(
await releaseMaterializedPageDeliveryContracts({
pool,
userId: 'user-1',
relativePaths: ['public/form.html'],
allowPgRequired: true,
}),
['public/form.html'],
);
});