feat(mindspace): add page quota grace write and local delivery guardrails.
Memind CI / Test, build, and release guards (pull_request) Failing after 18s

Centralize page HTML quota checks with grace-write semantics across page
services and workspace tools, keep localhost MindSpace links clickable in
chat display, and expand Page Data/static-page skill plus local dev docs
for quota, delivery URLs, and native Aider/OpenHands tooling.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-30 10:27:16 +08:00
parent b553107817
commit 371900bae5
18 changed files with 503 additions and 39 deletions
+49
View File
@@ -0,0 +1,49 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {
assertPageWriteQuota,
evaluatePageWriteQuota,
isMindSpacePageWriteRelativePath,
} from './mindspace-space-quota.mjs';
const baseSpace = {
quota_bytes: 100,
used_bytes: 80,
reserved_bytes: 0,
};
test('evaluatePageWriteQuota allows normal writes within headroom', () => {
assert.deepEqual(evaluatePageWriteQuota(baseSpace, 15).reason, 'sufficient');
});
test('evaluatePageWriteQuota allows grace write when headroom is insufficient but not over quota', () => {
const result = evaluatePageWriteQuota(baseSpace, 30);
assert.equal(result.reason, 'grace_write');
assert.equal(result.allowed, true);
assert.equal(result.grace, true);
});
test('evaluatePageWriteQuota blocks next write after quota is exhausted', () => {
const over = { quota_bytes: 100, used_bytes: 100, reserved_bytes: 0 };
const result = evaluatePageWriteQuota(over, 1);
assert.equal(result.reason, 'over_quota');
assert.equal(result.allowed, false);
});
test('assertPageWriteQuota throws over-quota message for subsequent writes', () => {
const over = { quota_bytes: 100, used_bytes: 101, reserved_bytes: 0 };
assert.throws(
() => assertPageWriteQuota(over, 1),
(error) =>
error.code === 'quota_exceeded' &&
error.message.includes('空间已满') &&
error.details?.overQuota === true,
);
});
test('isMindSpacePageWriteRelativePath matches public and draft html only', () => {
assert.equal(isMindSpacePageWriteRelativePath('public/bug-tracker.html'), true);
assert.equal(isMindSpacePageWriteRelativePath('draft/report.html'), true);
assert.equal(isMindSpacePageWriteRelativePath('private/notes.html'), false);
assert.equal(isMindSpacePageWriteRelativePath('public/data.json'), false);
});