fix(supabase): V1-2.1 owner self-review grant and the text size measure
M6 option A: grant_catalog_right no longer refuses an owner granting itself sheet_reviewer; authors stay refused at acknowledgment, approval and publication. The document cap is the UTF-8 bytes of the JSON text: check_document_structure drops pg_column_size and M5 replaces the base table CHECK by octet_length(content::text). pgTAP 015 and 017 cover the owner-reviewer journey and cap - 1, cap, cap + 1, multi-byte, dense.
This commit is contained in:
1 parent
2af61e72cc
commit
b1de87b5d0
6 files changed
+131
-34
No files matched your search
@@ -5,14 +5,14 @@
|
||||
*
|
||||
* The core's at-caps fixture belongs to V1-2.2, which has not started. This
|
||||
* suite builds an equivalent document for what SQL does with one: the
|
||||
* structural guards, the 2 MiB serialised size, the status walk at approval
|
||||
* structural guards, the 2 MiB size (UTF-8 bytes of the JSON text), the status walk at approval
|
||||
* and publication, the group coverage, the drawing checks. It reaches every
|
||||
* cap those depend on: 64 views (one main, three with their own drawing, the
|
||||
* rest crops), 1 024 annotations, 8 192 finding nodes counting categories
|
||||
* (1 024 zones, each a category and a chain of seven nodes: depth 8), four
|
||||
* drawings near 2 MiB, labels sized so the document is as close to 2 MiB as
|
||||
* the stricter of PostgreSQL's two measures allows (its text, which the save
|
||||
* guard reads, and its stored jsonb, which the table CHECK reads), every status
|
||||
* drawings near 2 MiB, labels sized so the document's text (`::text`, the
|
||||
* contract's measure, §12.2) is as close to 2 MiB as the variants allow; its
|
||||
* binary jsonb, larger, is reported and is not the measure, every status
|
||||
* `reviewed`, a verdict of 1 089 groups (general, 64 views, 1 024 zones). The
|
||||
* core never parses it (SQL holds no business rule, §12.2), so it says nothing
|
||||
* about the verifier's 120 s budget, which V1-2.3 measures.
|
||||
@@ -76,8 +76,8 @@ function capsDocument(assets: string[], labelLength: number, variant: number): R
|
||||
|
||||
/**
|
||||
* The two sizes PostgreSQL gives the document: its text (`octet_length`, the
|
||||
* contract's measure) and its stored jsonb (`pg_column_size`, the table's
|
||||
* CHECK). A document of many small objects is larger as jsonb, so that one binds.
|
||||
* contract's measure, read by the save guard and the table CHECK) and its
|
||||
* binary jsonb (`pg_column_size`, reported only: not the measure).
|
||||
*/
|
||||
const pgSizes = async (doc: Record<string, unknown>) => {
|
||||
const [text, jsonb] = (await sql(`select octet_length(d::text) || ' ' || pg_column_size(d)
|
||||
@@ -85,14 +85,14 @@ const pgSizes = async (doc: Record<string, unknown>) => {
|
||||
return { text, jsonb }
|
||||
}
|
||||
|
||||
/** The largest label length whose document stays under both measures (with 4 KiB for the variants). */
|
||||
/** The largest label length whose document's text stays under the cap (with 4 KiB for the variants). */
|
||||
async function calibrate(assets: string[]): Promise<number> {
|
||||
let low = 1
|
||||
let high = 200
|
||||
while (low < high) {
|
||||
const mid = Math.ceil((low + high) / 2)
|
||||
const size = await pgSizes(capsDocument(assets, mid, 0))
|
||||
if (Math.max(size.text, size.jsonb) <= DOC_CAP - 4096) low = mid
|
||||
if (size.text <= DOC_CAP - 4096) low = mid
|
||||
else high = mid - 1
|
||||
}
|
||||
return low
|
||||
@@ -205,8 +205,8 @@ describe('timing at the caps (§15)', () => {
|
||||
save: stats(samples.save), submit: stats(samples.submit), approve: stats(samples.approve), publish: stats(samples.publish),
|
||||
}
|
||||
console.info(`AT-CAPS TIMING ${JSON.stringify(report)}`)
|
||||
expect(Math.max(docSize.text, docSize.jsonb)).toBeGreaterThan(DOC_CAP - 64 * 1024)
|
||||
expect(Math.max(docSize.text, docSize.jsonb)).toBeLessThanOrEqual(DOC_CAP)
|
||||
expect(docSize.text).toBeGreaterThan(DOC_CAP - 64 * 1024)
|
||||
expect(docSize.text).toBeLessThanOrEqual(DOC_CAP)
|
||||
for (const op of ['save', 'submit', 'publish'])
|
||||
expect(Math.max(...samples[op]), `${op} at the caps`).toBeLessThan(BUDGET_MS)
|
||||
}, 600_000)
|
||||
|
||||
Reference in new issue
Block a user