@vercel/board 0.39.0 → 0.41.0
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.
- package/README.md +6 -4
- package/dist/{access-CVkjSfxj.mjs → access-C5HaO42b.mjs} +2 -2
- package/dist/access.d.mts +6 -6
- package/dist/access.mjs +5 -5
- package/dist/actors-nrOf7Y7z.mjs +160 -0
- package/dist/{auth-BXLCkeB0.d.mts → auth-Bn8J_1F2.d.mts} +14 -29
- package/dist/{auth-B3bBYOqf.mjs → auth-DAlYi6TN.mjs} +9 -19
- package/dist/{backend-HcCCGPG4.d.mts → backend-CYsTLxtP.d.mts} +139 -43
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/blocks-CVoBC7ur.mjs +402 -0
- package/dist/blocks-DGvh2alZ.d.mts +33 -0
- package/dist/{chat-provider-1WKsLEnM.mjs → chat-provider-CPZg2MQb.mjs} +2 -2
- package/dist/{chat-provider-DyNy5xdC.d.mts → chat-provider-Cgkh9xJw.d.mts} +2 -2
- package/dist/cli-commands.d.mts +1 -1
- package/dist/cli-commands.mjs +1 -1
- package/dist/cli-embedded.d.mts +3 -3
- package/dist/cli-embedded.mjs +4 -4
- package/dist/cli.mjs +8 -13
- package/dist/{commands-B5d-lmNN.d.mts → commands-CrEVjASe.d.mts} +14 -26
- package/dist/{commands-BLS7erNu.mjs → commands-QRD0U9AQ.mjs} +114 -105
- package/dist/{conformance-D59Py2m2.mjs → conformance-ClxEEZ9C.mjs} +378 -101
- package/dist/conformance.d.mts +11 -9
- package/dist/conformance.mjs +1 -1
- package/dist/data-values-C-Cq80hz.mjs +176 -0
- package/dist/digest-Dna1CGa_.mjs +4 -0
- package/dist/{engine-eUgO5jTM.mjs → engine-8BcNeckB.mjs} +197 -84
- package/dist/{errors-rYDxZEuN.mjs → errors-DcQf5WeM.mjs} +123 -42
- package/dist/{events-C6HwB046.mjs → events-BT8y_81j.mjs} +2 -2
- package/dist/{exports-M5o4PTfO.mjs → exports-B6udRV_E.mjs} +961 -383
- package/dist/exports-C8zsIL1A.d.mts +4 -0
- package/dist/{external-CHDxWIVf.mjs → external-DymyhUzl.mjs} +1 -1
- package/dist/{index-rNqqgkyu.d.mts → index-fcpEFCTR.d.mts} +2 -2
- package/dist/index.d.mts +7 -6
- package/dist/index.mjs +8 -6
- package/dist/index.node.d.mts +7 -6
- package/dist/index.node.mjs +5 -4
- package/dist/inspect/app.js +110 -109
- package/dist/inspect/engine.js +5 -5
- package/dist/inspect-BsF3mYMY.mjs +2 -0
- package/dist/{inspect-BkXxR2uB.mjs → inspect-DPRoC_Gg.mjs} +6 -6
- package/dist/{local-DvkOWf4U.mjs → local-B9y4p6N7.mjs} +463 -512
- package/dist/{main-DtV_Po9i.mjs → main-S0A-c_kP.mjs} +549 -178
- package/dist/{memory-DkoqhxIH.mjs → memory-DhduVbUu.mjs} +2 -2
- package/dist/{mentions-CB6ShY4R.mjs → mentions-DfZGp3B-.mjs} +18 -4
- package/dist/{middleware-CPqAuRtp.mjs → middleware-DHdrxmoc.mjs} +71 -3
- package/dist/{targets-C1mT3M1N.mjs → origin-B3m2lnZC.mjs} +43 -64
- package/dist/{page-64IwoGRu.mjs → page-2jjHZmIW.mjs} +2 -2
- package/dist/page-CAUe4GmQ.mjs +2 -0
- package/dist/{provider-D5yVFisj.d.mts → provider-dY54GFNz.d.mts} +20 -34
- package/dist/{routes-BffuaoTX.d.mts → routes-By9lmvUD.d.mts} +91 -77
- package/dist/{schemas-AZkxk06N.mjs → schemas-DAzSsgWk.mjs} +8 -3
- package/dist/schemas.d.mts +37 -0
- package/dist/schemas.mjs +3 -0
- package/dist/{serve-CX1rqDF_.mjs → serve-B15I2Ibf.mjs} +5 -5
- package/dist/{server-DkYkyarg.mjs → server-DgpRZ4Nu.mjs} +74 -127
- package/dist/{serving-DJMcG0dT.mjs → serving-CALKWs9K.mjs} +1 -1
- package/dist/{sql-l3ysn4O5.mjs → sql-P9g-rLIF.mjs} +75 -12
- package/dist/{sqlite-CAwNHbQD.mjs → sqlite-B3rCcIof.mjs} +2 -2
- package/dist/{sqlite-db-cm5yhrD-.mjs → sqlite-db-D0Fyju-4.mjs} +1 -1
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-chat-sdk.mjs +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-github.mjs +2 -2
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-linear.mjs +2 -2
- package/dist/sync-slack.d.mts +14 -8
- package/dist/sync-slack.mjs +46 -19
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/{tokens-DA9ipsZ-.mjs → tokens-D7_ZIWpX.mjs} +4 -4
- package/docs/01-board/01-mounting.md +13 -16
- package/docs/01-board/03-identity.md +112 -74
- package/docs/01-board/04-messages.md +61 -2
- package/docs/01-board/05-reading.md +11 -5
- package/docs/01-board/06-watchers.md +17 -13
- package/docs/01-board/07-schedules.md +8 -6
- package/docs/01-board/08-middleware.md +1 -1
- package/docs/01-board/09-access.md +80 -132
- package/docs/02-sync/01-overview.md +75 -4
- package/docs/02-sync/02-functions.md +11 -6
- package/docs/02-sync/03-slack.md +43 -19
- package/docs/02-sync/06-providers.md +9 -4
- package/docs/03-guides/01-coding-agents.md +18 -22
- package/docs/03-guides/02-inspector.md +4 -5
- package/docs/03-guides/03-ci.md +7 -26
- package/docs/03-guides/04-triage.md +2 -2
- package/docs/03-guides/05-agent-factory.md +7 -9
- package/docs/03-guides/06-sandboxed-agents.md +149 -0
- package/docs/04-reference/01-cli.md +161 -104
- package/docs/04-reference/02-board.md +89 -37
- package/docs/04-reference/03-http.md +176 -71
- package/docs/04-reference/05-conformance.md +47 -21
- package/docs/index.md +5 -5
- package/package.json +5 -1
- package/dist/actors-kfMejhaw.mjs +0 -156
- package/dist/digest-krhjNAt4.mjs +0 -4
- package/dist/exports-vLQ2Y2Nd.d.mts +0 -4
- package/dist/inspect-lnv1sLXM.mjs +0 -2
- package/dist/page-BUj8_UZv.mjs +0 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { u as BoardError } from "./errors-
|
|
2
|
-
import { c as
|
|
1
|
+
import { u as BoardError } from "./errors-DcQf5WeM.mjs";
|
|
2
|
+
import { c as canonical, t as block } from "./blocks-CVoBC7ur.mjs";
|
|
3
|
+
import { a as canText, c as compileAccess } from "./access-C5HaO42b.mjs";
|
|
3
4
|
//#region src/conformance/index.ts
|
|
4
5
|
var Mismatch = class extends Error {};
|
|
5
6
|
const show = (value) => JSON.stringify(value) ?? String(value);
|
|
@@ -29,6 +30,26 @@ async function refused(attempt, status, what) {
|
|
|
29
30
|
throw new Mismatch(`${what}: expected ${status}, and it succeeded`);
|
|
30
31
|
}
|
|
31
32
|
const NO_CAN = "this run can't call the board with an x-board-can header";
|
|
33
|
+
const NO_HEADERS = "this run can't call the board with headers of its own";
|
|
34
|
+
/** The avatar the checks of who writes give their profile. */
|
|
35
|
+
const AVATAR = "https://example.com/conformance.png";
|
|
36
|
+
/** A post by `poster`, which sends `header`, read back as the run sees it: it lands, and is deleted when the run ends. */
|
|
37
|
+
async function postedWith(ctx, poster, header) {
|
|
38
|
+
const posted = await poster.post(ctx.channel, {
|
|
39
|
+
text: `conformance: with ${header}`,
|
|
40
|
+
labels: ctx.labels,
|
|
41
|
+
noSync: true
|
|
42
|
+
}).catch((error) => {
|
|
43
|
+
throw new Mismatch(`a post with ${header}, which released clients still send: expected it to land, got ${error instanceof BoardError ? `${error.status} ${error.code}` : String(error)}`);
|
|
44
|
+
});
|
|
45
|
+
ctx.posted.push(posted.id);
|
|
46
|
+
return (await ctx.board.thread(posted.id)).message;
|
|
47
|
+
}
|
|
48
|
+
/** That a view's `by` names who wrote it as the protocol has it: an actor, a principal, and a profile, and no session. */
|
|
49
|
+
function noSession(by, what) {
|
|
50
|
+
check(typeof by === "object" && by !== null, `${what} should have a by, got ${show(by)}`);
|
|
51
|
+
check(!("session" in by), `${what} should carry no session, got ${show(by)}`);
|
|
52
|
+
}
|
|
32
53
|
/**
|
|
33
54
|
* That `attempt`, by a caller narrowed with `x-board-can`, is refused as one: 403 `forbidden`.
|
|
34
55
|
* Vercel's API's refusal of a person's watchers goes on as it is, for the run to skip.
|
|
@@ -58,13 +79,13 @@ function isRef(value, what) {
|
|
|
58
79
|
/**
|
|
59
80
|
* The groups a board may keep none of, saying so with a 501: a board without a scheduler answers
|
|
60
81
|
* `no_scheduler`, and without a blob store `no_files`; a backend of one's own that keeps no grants
|
|
61
|
-
* answers `no_grants`. A board that's meant to keep something and doesn't yet answers otherwise,
|
|
82
|
+
* answers `no_grants`, and one that keeps no schemas `no_schemas`. A board that's meant to keep something and doesn't yet answers otherwise,
|
|
62
83
|
* and fails.
|
|
63
84
|
*/
|
|
64
85
|
const OPTIONAL = /* @__PURE__ */ new Set([
|
|
65
86
|
"schedules",
|
|
66
87
|
"grants",
|
|
67
|
-
"
|
|
88
|
+
"schemas",
|
|
68
89
|
"attachments"
|
|
69
90
|
]);
|
|
70
91
|
const needRoot = (ctx) => {
|
|
@@ -111,13 +132,12 @@ function unnamed(error) {
|
|
|
111
132
|
}
|
|
112
133
|
const messageOf = (error) => error instanceof Error ? error.message : String(error);
|
|
113
134
|
/**
|
|
114
|
-
* Runs `check` with what it makes grants
|
|
135
|
+
* Runs `check` with what it makes grants with, and revokes them all afterwards, the
|
|
115
136
|
* newest grant first, so one that closes a pattern goes while the one keeping this run in is there.
|
|
116
137
|
* A revoke that fails fails the check: what it made would stay on the board.
|
|
117
138
|
*/
|
|
118
139
|
async function withGrants(ctx, check) {
|
|
119
140
|
const made = [];
|
|
120
|
-
const tokens = [];
|
|
121
141
|
const grants = {
|
|
122
142
|
async make(input, by) {
|
|
123
143
|
try {
|
|
@@ -140,24 +160,9 @@ async function withGrants(ctx, check) {
|
|
|
140
160
|
}
|
|
141
161
|
throw new Mismatch(`${what}: expected 403, and it made the grant`);
|
|
142
162
|
},
|
|
143
|
-
|
|
144
|
-
if (!ctx.
|
|
145
|
-
|
|
146
|
-
const { token, secret } = await ctx.board.createToken({
|
|
147
|
-
name: `conformance-${ctx.labels.conformance}-grants`,
|
|
148
|
-
can,
|
|
149
|
-
expires: "1h"
|
|
150
|
-
});
|
|
151
|
-
tokens.push(token.id);
|
|
152
|
-
return ctx.withToken(secret);
|
|
153
|
-
} catch (error) {
|
|
154
|
-
if (error instanceof BoardError && [
|
|
155
|
-
403,
|
|
156
|
-
404,
|
|
157
|
-
501
|
|
158
|
-
].includes(error.status)) throw new Skip(`this board mints no tokens to check with: ${error.message}`);
|
|
159
|
-
throw error;
|
|
160
|
-
}
|
|
163
|
+
narrow(can) {
|
|
164
|
+
if (!ctx.withCan) throw new Skip(NO_CAN);
|
|
165
|
+
return ctx.withCan(canText(compileAccess(can)));
|
|
161
166
|
},
|
|
162
167
|
async keep(pattern) {
|
|
163
168
|
const [source, kind, id, environment] = ctx.me.principal.split(":");
|
|
@@ -192,9 +197,6 @@ async function withGrants(ctx, check) {
|
|
|
192
197
|
for (const id of made.reverse()) await ctx.board.revokeGrant(id).catch((error) => {
|
|
193
198
|
left.push(`${id} (${messageOf(error)})`);
|
|
194
199
|
});
|
|
195
|
-
for (const id of tokens) await ctx.board.revokeToken(id).catch((error) => {
|
|
196
|
-
left.push(`token ${id} (${messageOf(error)})`);
|
|
197
|
-
});
|
|
198
200
|
if (left.length > 0) throw new Mismatch(`${failure ? `${messageOf(failure)}; and it ` : ""}couldn't revoke what it made: ${left.join(", ")}`);
|
|
199
201
|
if (failure) throw failure;
|
|
200
202
|
return result;
|
|
@@ -212,6 +214,53 @@ const sortedOf = (values) => [...values ?? []].sort();
|
|
|
212
214
|
function alike(actual, expected, what) {
|
|
213
215
|
if (show(actual) !== show(expected)) throw new Mismatch(`${what}: expected ${show(expected)}, got ${show(actual)}`);
|
|
214
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* The schema the schemas checks register: the same on every run, since a version never changes and
|
|
219
|
+
* is never removed, so a board holds one however often it's checked. A change to it is a new
|
|
220
|
+
* version here, never an edit: a board checked before would refuse this one as another definition.
|
|
221
|
+
* It names every property it requires and gives each keyword its type, as the strictest board asks.
|
|
222
|
+
*/
|
|
223
|
+
const SCHEMA = {
|
|
224
|
+
name: "conformance",
|
|
225
|
+
version: 1,
|
|
226
|
+
description: "What the conformance kit registers, once on every board it checks.",
|
|
227
|
+
schema: {
|
|
228
|
+
type: "object",
|
|
229
|
+
required: ["run", "outcome"],
|
|
230
|
+
additionalProperties: false,
|
|
231
|
+
properties: {
|
|
232
|
+
run: {
|
|
233
|
+
type: "string",
|
|
234
|
+
minLength: 1,
|
|
235
|
+
maxLength: 64
|
|
236
|
+
},
|
|
237
|
+
outcome: { enum: ["passed", "failed"] },
|
|
238
|
+
checks: {
|
|
239
|
+
type: "array",
|
|
240
|
+
maxItems: 500,
|
|
241
|
+
items: {
|
|
242
|
+
type: "object",
|
|
243
|
+
required: ["name"],
|
|
244
|
+
properties: {
|
|
245
|
+
name: { type: "string" },
|
|
246
|
+
skipped: { type: "boolean" }
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
/** `SCHEMA`'s definition, saying the same with its keys the other way around. */
|
|
254
|
+
const reversed = (value) => Array.isArray(value) ? value.map(reversed) : value && typeof value === "object" ? Object.fromEntries(Object.entries(value).reverse().map(([key, child]) => [key, reversed(child)])) : value;
|
|
255
|
+
/** Registers `SCHEMA`, or says why this run can't: a caller without manage at `*` is refused, and the check skipped. */
|
|
256
|
+
async function register(ctx) {
|
|
257
|
+
try {
|
|
258
|
+
return { made: await ctx.board.createSchema(SCHEMA) };
|
|
259
|
+
} catch (error) {
|
|
260
|
+
if (error instanceof BoardError && error.status === 403) return { skip: "this token can't register schemas" };
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
215
264
|
/** The sync key the sync checks register, a platform of their own, so nothing reaches a real one. */
|
|
216
265
|
const SYNC_KEY = "conformance";
|
|
217
266
|
/**
|
|
@@ -466,6 +515,34 @@ const CHECKS = [
|
|
|
466
515
|
same(found.last?.id, reply.id, "its latest reply");
|
|
467
516
|
}
|
|
468
517
|
},
|
|
518
|
+
{
|
|
519
|
+
group: "core",
|
|
520
|
+
name: "matches text anywhere in a message's own, in any case, as it reads now",
|
|
521
|
+
run: async (ctx) => {
|
|
522
|
+
const literal = await post(ctx, "conformance: Deploy FAILED at 100% on a_b");
|
|
523
|
+
const lookalike = await post(ctx, "conformance: deploy failed at 1000 on axb");
|
|
524
|
+
const under = await reply(ctx, lookalike.id, "conformance: a reply that says Crème Brûlée");
|
|
525
|
+
const found = async (text) => (await ctx.board.messages({
|
|
526
|
+
channel: ctx.channel,
|
|
527
|
+
label: ctx.labels,
|
|
528
|
+
after: ctx.start,
|
|
529
|
+
text
|
|
530
|
+
})).messages.map((m) => m.id);
|
|
531
|
+
alike(await found("DEPLOY failed"), [literal.id, lookalike.id], "the messages \"DEPLOY failed\" finds");
|
|
532
|
+
alike(await found("100%"), [literal.id], "the messages \"100%\" finds, % being a character");
|
|
533
|
+
alike(await found("a_b"), [literal.id], "the messages \"a_b\" finds, _ being a character");
|
|
534
|
+
alike(await found("BRÛLÉE"), [under.id], "the messages \"BRÛLÉE\" finds");
|
|
535
|
+
const { threads } = await ctx.board.threads({
|
|
536
|
+
channel: ctx.channel,
|
|
537
|
+
label: ctx.labels,
|
|
538
|
+
text: "crème brûlée"
|
|
539
|
+
});
|
|
540
|
+
alike(threads.map((t) => t.message.id), [lookalike.id], "the threads \"crème brûlée\" finds");
|
|
541
|
+
await ctx.board.edit(lookalike.id, "conformance: deploy fixed");
|
|
542
|
+
alike(await found("1000"), [], "the messages \"1000\" finds, once the one that said it is edited");
|
|
543
|
+
alike(await found("deploy fixed"), [lookalike.id], "the messages \"deploy fixed\" finds, once one is edited to say it");
|
|
544
|
+
}
|
|
545
|
+
},
|
|
469
546
|
{
|
|
470
547
|
group: "core",
|
|
471
548
|
name: "reads events after a cursor, each with a cursor of its own",
|
|
@@ -615,6 +692,105 @@ const CHECKS = [
|
|
|
615
692
|
}), 403, "a post by a caller narrowed to read");
|
|
616
693
|
}
|
|
617
694
|
},
|
|
695
|
+
{
|
|
696
|
+
group: "core",
|
|
697
|
+
name: "takes a profile and its avatar as one x-board-profile header, and shows both on what it writes",
|
|
698
|
+
run: async (ctx) => {
|
|
699
|
+
if (!ctx.withHeaders) return NO_HEADERS;
|
|
700
|
+
const name = `conformance-${ctx.labels.conformance}`;
|
|
701
|
+
const posted = await ctx.withHeaders({ "x-board-profile": `${name}; avatar="${AVATAR}"` }).post(ctx.channel, {
|
|
702
|
+
text: "conformance: as a profile, with its avatar",
|
|
703
|
+
labels: ctx.labels,
|
|
704
|
+
noSync: true
|
|
705
|
+
});
|
|
706
|
+
ctx.posted.push(posted.id);
|
|
707
|
+
const { message } = await ctx.board.thread(posted.id);
|
|
708
|
+
same(message.by.principal, ctx.me.principal, "the profile's principal, this run's");
|
|
709
|
+
same(message.by.profile?.toLowerCase(), name, "the profile its header names");
|
|
710
|
+
same(message.author?.kind, "agent", "the profile's kind");
|
|
711
|
+
same(message.author?.name, name, "the profile's name");
|
|
712
|
+
same(message.author?.avatar, AVATAR, "the profile's avatar, from its header's parameter");
|
|
713
|
+
}
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
group: "core",
|
|
717
|
+
name: "lets a profile change only its own messages, and its principal all of them",
|
|
718
|
+
run: async (ctx) => {
|
|
719
|
+
if (!ctx.withHeaders) return NO_HEADERS;
|
|
720
|
+
if (ctx.me.actor !== ctx.me.principal) return "this run writes as a profile, so it can't change messages as its principal";
|
|
721
|
+
const as = (name) => ctx.withHeaders({ "x-board-profile": `conformance-${name}-${ctx.labels.conformance}` });
|
|
722
|
+
const by = async (poster, text) => {
|
|
723
|
+
const message = await poster.post(ctx.channel, {
|
|
724
|
+
text,
|
|
725
|
+
labels: ctx.labels,
|
|
726
|
+
noSync: true
|
|
727
|
+
});
|
|
728
|
+
ctx.posted.push(message.id);
|
|
729
|
+
return message;
|
|
730
|
+
};
|
|
731
|
+
const profile = as("own");
|
|
732
|
+
const own = await by(profile, "conformance: a profile's own");
|
|
733
|
+
const other = await by(as("other"), "conformance: another profile's");
|
|
734
|
+
const principal = await by(ctx.board, "conformance: its principal's");
|
|
735
|
+
await profile.edit(own.id, "conformance: a profile's own, edited by it");
|
|
736
|
+
same((await ctx.board.thread(own.id)).message.text, "conformance: a profile's own, edited by it", "a profile's own message, once it edits it");
|
|
737
|
+
for (const [message, whose] of [[other, "another profile's"], [principal, "its principal's"]]) {
|
|
738
|
+
await refused(profile.edit(message.id, "conformance: not its own"), 403, `an edit, by a profile, of ${whose} message`);
|
|
739
|
+
await refused(profile.delete(message.id), 403, `a delete, by a profile, of ${whose} message`);
|
|
740
|
+
}
|
|
741
|
+
await ctx.board.edit(other.id, "conformance: another profile's, edited by its principal");
|
|
742
|
+
const edited = (await ctx.board.thread(other.id)).message;
|
|
743
|
+
same(edited.text, "conformance: another profile's, edited by its principal", "a profile's message, once its principal edits it");
|
|
744
|
+
same(edited.by.actor, other.by.actor, "who a profile's message is by, once its principal edits it");
|
|
745
|
+
for (const message of [own, other]) {
|
|
746
|
+
await ctx.board.delete(message.id);
|
|
747
|
+
check((await ctx.board.thread(message.id)).message.deleted, "a profile's message, once its principal deletes it, should be deleted");
|
|
748
|
+
}
|
|
749
|
+
await profile.delete((await by(profile, "conformance: a profile's own, to delete")).id);
|
|
750
|
+
}
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
group: "core",
|
|
754
|
+
name: "ignores x-board-avatar, which x-board-profile's avatar parameter replaced",
|
|
755
|
+
run: async (ctx) => {
|
|
756
|
+
if (!ctx.withHeaders) return NO_HEADERS;
|
|
757
|
+
const name = `conformance-bare-${ctx.labels.conformance}`;
|
|
758
|
+
const message = await postedWith(ctx, ctx.withHeaders({
|
|
759
|
+
"x-board-profile": name,
|
|
760
|
+
"x-board-avatar": AVATAR
|
|
761
|
+
}), "x-board-avatar");
|
|
762
|
+
same(message.by.profile?.toLowerCase(), name, "the profile its header names");
|
|
763
|
+
same(message.author?.avatar ?? null, null, "the avatar of a profile whose header names none, whatever x-board-avatar says");
|
|
764
|
+
}
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
group: "core",
|
|
768
|
+
name: "ignores x-board-session: who writes is the principal and its profile",
|
|
769
|
+
run: async (ctx) => {
|
|
770
|
+
if (!ctx.withHeaders) return NO_HEADERS;
|
|
771
|
+
const message = await postedWith(ctx, ctx.withHeaders({ "x-board-session": `conformance-${ctx.labels.conformance}` }), "x-board-session");
|
|
772
|
+
same(message.by.actor, ctx.me.actor, "who a post with x-board-session is by: this run, as itself");
|
|
773
|
+
noSession(message.by, "a post with x-board-session");
|
|
774
|
+
}
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
group: "core",
|
|
778
|
+
name: "shows no session on a message, its event, or you",
|
|
779
|
+
run: async (ctx) => {
|
|
780
|
+
const { root } = needRoot(ctx);
|
|
781
|
+
noSession((await ctx.board.thread(root.id)).message.by, "a message");
|
|
782
|
+
const { events } = await ctx.board.poll({
|
|
783
|
+
channel: ctx.channel,
|
|
784
|
+
after: ctx.start,
|
|
785
|
+
label: ctx.labels,
|
|
786
|
+
wait: 0
|
|
787
|
+
});
|
|
788
|
+
const posted = events.find((event) => event.type === "message.posted");
|
|
789
|
+
check(posted !== void 0, `events after the run's start should hold its post, got ${show(events.map((event) => event.type))}`);
|
|
790
|
+
noSession(posted.payload.by, "a message.posted event's payload");
|
|
791
|
+
check(!("session" in ctx.me), `you should carry no session, got ${show(ctx.me)}`);
|
|
792
|
+
}
|
|
793
|
+
},
|
|
618
794
|
{
|
|
619
795
|
group: "schedules",
|
|
620
796
|
name: "schedules a reply, lists it, and cancels it",
|
|
@@ -863,10 +1039,10 @@ const CHECKS = [
|
|
|
863
1039
|
{
|
|
864
1040
|
group: "grants",
|
|
865
1041
|
name: "takes manage at each pattern a grant names to change it, and at * to list them",
|
|
866
|
-
run: (ctx) => withGrants(ctx, async ({ make, deny,
|
|
1042
|
+
run: (ctx) => withGrants(ctx, async ({ make, deny, narrow }) => {
|
|
867
1043
|
const subtree = subtreeOf(ctx);
|
|
868
1044
|
const inner = `${subtree}inner/`;
|
|
869
|
-
const poster =
|
|
1045
|
+
const poster = narrow({ "*": ["read", "post"] });
|
|
870
1046
|
const probe = await make(grantFor(ctx));
|
|
871
1047
|
await deny(poster, grantFor(ctx), "a grant made without manage");
|
|
872
1048
|
await refused(poster.updateGrant(probe.id, { can: { [`${subtree}ci/`]: ["read"] } }), 403, "an update without manage");
|
|
@@ -874,7 +1050,7 @@ const CHECKS = [
|
|
|
874
1050
|
await refused(poster.grants(), 403, "listing grants without manage at *");
|
|
875
1051
|
await refused(poster.explain(`${subtree}thread`, { project: ctx.principals.project }), 403, "explaining a principal's access without manage at *");
|
|
876
1052
|
alike((await poster.explain(`${subtree}thread`)).grants, [], "which grants decide, for a caller that may not list them");
|
|
877
|
-
const manager =
|
|
1053
|
+
const manager = narrow({
|
|
878
1054
|
"*": [
|
|
879
1055
|
"read",
|
|
880
1056
|
"post",
|
|
@@ -899,19 +1075,19 @@ const CHECKS = [
|
|
|
899
1075
|
},
|
|
900
1076
|
{
|
|
901
1077
|
group: "grants",
|
|
902
|
-
name: "lets no
|
|
903
|
-
run: (ctx) => withGrants(ctx, async ({ make, deny,
|
|
1078
|
+
name: "lets no caller narrowed with x-board-can grant past its can, even where everyone's grant closes it",
|
|
1079
|
+
run: (ctx) => withGrants(ctx, async ({ make, deny, narrow, keep }) => {
|
|
904
1080
|
const subtree = subtreeOf(ctx);
|
|
905
1081
|
const secret = `${subtree}secret/`;
|
|
906
1082
|
const run = granteeOf(ctx);
|
|
907
|
-
const narrowed =
|
|
1083
|
+
const narrowed = narrow({
|
|
908
1084
|
"*": "all",
|
|
909
1085
|
[secret]: []
|
|
910
1086
|
});
|
|
911
1087
|
await deny(narrowed, {
|
|
912
1088
|
principals: [run],
|
|
913
1089
|
can: { [subtree]: ["read"] }
|
|
914
|
-
}, `a grant on ${subtree} from a
|
|
1090
|
+
}, `a grant on ${subtree} from a caller narrowed out of ${secret}`);
|
|
915
1091
|
await keep(secret);
|
|
916
1092
|
await make({
|
|
917
1093
|
principals: [{ kind: "everyone" }],
|
|
@@ -920,7 +1096,7 @@ const CHECKS = [
|
|
|
920
1096
|
await deny(narrowed, {
|
|
921
1097
|
principals: [run],
|
|
922
1098
|
can: { [subtree]: ["read"] }
|
|
923
|
-
}, `a grant on ${subtree} from a
|
|
1099
|
+
}, `a grant on ${subtree} from a caller narrowed out of ${secret}, once everyone is too`);
|
|
924
1100
|
await make({
|
|
925
1101
|
principals: [run],
|
|
926
1102
|
can: { [`${subtree}ci/`]: ["post"] }
|
|
@@ -929,11 +1105,11 @@ const CHECKS = [
|
|
|
929
1105
|
},
|
|
930
1106
|
{
|
|
931
1107
|
group: "grants",
|
|
932
|
-
name: "lets no
|
|
933
|
-
run: (ctx) => withGrants(ctx, async ({ make, deny,
|
|
1108
|
+
name: "lets no caller narrowed with x-board-can let anyone in where everyone gets more than it has",
|
|
1109
|
+
run: (ctx) => withGrants(ctx, async ({ make, deny, narrow, keep }) => {
|
|
934
1110
|
const subtree = subtreeOf(ctx);
|
|
935
1111
|
const open = `${subtree}open/`;
|
|
936
|
-
const narrowed =
|
|
1112
|
+
const narrowed = narrow({
|
|
937
1113
|
"*": "all",
|
|
938
1114
|
[open]: []
|
|
939
1115
|
});
|
|
@@ -945,7 +1121,7 @@ const CHECKS = [
|
|
|
945
1121
|
await deny(narrowed, {
|
|
946
1122
|
principals: [granteeOf(ctx)],
|
|
947
1123
|
can: { [`${subtree}ci/`]: ["post"] }
|
|
948
|
-
}, `a grant from a
|
|
1124
|
+
}, `a grant from a caller narrowed out of ${open}, which everyone reads`);
|
|
949
1125
|
})
|
|
950
1126
|
},
|
|
951
1127
|
{
|
|
@@ -959,66 +1135,169 @@ const CHECKS = [
|
|
|
959
1135
|
run: async () => "grants across teams aren't specified yet: what a project on another team needs, and what all-projects means for one, comes later"
|
|
960
1136
|
},
|
|
961
1137
|
{
|
|
962
|
-
group: "
|
|
963
|
-
name: "
|
|
1138
|
+
group: "schemas",
|
|
1139
|
+
name: "lists the built-in schemas first, and reads a schema by its ID",
|
|
964
1140
|
run: async (ctx) => {
|
|
965
|
-
const
|
|
966
|
-
const
|
|
1141
|
+
const schemas = await ctx.board.schemas();
|
|
1142
|
+
const own = schemas.findIndex((schema) => !schema.builtIn);
|
|
1143
|
+
check(own === -1 || schemas.slice(own).every((schema) => !schema.builtIn), `schemas should list the built-ins first, got ${show(schemas.map((schema) => schema.id))}`);
|
|
1144
|
+
const commit = schemas.find((schema) => schema.id === "git-commit@1");
|
|
1145
|
+
check(commit, `schemas should list the built-in git-commit@1, got ${show(schemas.map((schema) => schema.id))}`);
|
|
1146
|
+
alike({
|
|
1147
|
+
name: commit.name,
|
|
1148
|
+
version: commit.version,
|
|
1149
|
+
builtIn: commit.builtIn,
|
|
1150
|
+
by: commit.by,
|
|
1151
|
+
at: commit.at
|
|
1152
|
+
}, {
|
|
1153
|
+
name: "git-commit",
|
|
1154
|
+
version: 1,
|
|
1155
|
+
builtIn: true,
|
|
1156
|
+
by: null,
|
|
1157
|
+
at: null
|
|
1158
|
+
}, "the built-in git-commit@1");
|
|
1159
|
+
check(commit.schema.type === "object", `a schema's definition should describe an object, got ${show(commit.schema)}`);
|
|
1160
|
+
same(canonical(await ctx.board.schema("git-commit@1")), canonical(commit), "git-commit@1, read by its ID");
|
|
1161
|
+
await rejects(ctx.board.schema("conformance-none@1"), 404, "schema_not_found", "reading a version no one registered");
|
|
1162
|
+
await rejects(ctx.board.schema("Not A Schema"), 400, "invalid_schema_id", "reading an ID that names no schema");
|
|
1163
|
+
}
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
group: "schemas",
|
|
1167
|
+
name: "registers a schema version once: the same definition again changes nothing, and another is refused",
|
|
1168
|
+
run: async (ctx) => {
|
|
1169
|
+
const registered = await register(ctx);
|
|
1170
|
+
if ("skip" in registered) return registered.skip;
|
|
1171
|
+
const { schema, created } = registered.made;
|
|
1172
|
+
check(typeof created === "boolean", `created should say whether this made it, got ${show(created)}`);
|
|
1173
|
+
alike({
|
|
1174
|
+
id: schema.id,
|
|
1175
|
+
name: schema.name,
|
|
1176
|
+
version: schema.version,
|
|
1177
|
+
description: schema.description,
|
|
1178
|
+
builtIn: schema.builtIn
|
|
1179
|
+
}, {
|
|
1180
|
+
id: "conformance@1",
|
|
1181
|
+
name: SCHEMA.name,
|
|
1182
|
+
version: SCHEMA.version,
|
|
1183
|
+
description: SCHEMA.description,
|
|
1184
|
+
builtIn: false
|
|
1185
|
+
}, "the schema it registered");
|
|
1186
|
+
same(canonical(schema.schema), canonical(SCHEMA.schema), "the schema's definition, as it was sent");
|
|
1187
|
+
check(typeof schema.by === "string" && schema.by.length > 0, `a registered schema should say who registered it, got ${show(schema.by)}`);
|
|
1188
|
+
check(typeof schema.at === "string" && !Number.isNaN(Date.parse(schema.at)), `a registered schema should say when, got ${show(schema.at)}`);
|
|
1189
|
+
const again = await ctx.board.createSchema({
|
|
1190
|
+
...SCHEMA,
|
|
1191
|
+
schema: reversed(SCHEMA.schema)
|
|
1192
|
+
});
|
|
1193
|
+
same(again.created, false, "whether registering the same definition again made one");
|
|
1194
|
+
same(canonical(again.schema), canonical(schema), "the schema, registered again");
|
|
1195
|
+
await rejects(ctx.board.createSchema({
|
|
1196
|
+
...SCHEMA,
|
|
1197
|
+
schema: {
|
|
1198
|
+
type: "object",
|
|
1199
|
+
required: ["run"],
|
|
1200
|
+
properties: { run: { type: "string" } }
|
|
1201
|
+
}
|
|
1202
|
+
}), 409, "schema_immutable", "another definition for a version that is there");
|
|
1203
|
+
await rejects(ctx.board.createSchema({
|
|
1204
|
+
...SCHEMA,
|
|
1205
|
+
description: "Something else."
|
|
1206
|
+
}), 409, "schema_immutable", "another description for a version that is there");
|
|
1207
|
+
same(canonical(await ctx.board.schema(schema.id)), canonical(schema), "the schema, read by its ID");
|
|
1208
|
+
same((await ctx.board.schemas()).filter((found) => found.id === schema.id).length, 1, `how many times schemas lists ${schema.id}`);
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
group: "schemas",
|
|
1213
|
+
name: "refuses a built-in's name, and a definition it couldn't check a value against",
|
|
1214
|
+
run: async (ctx) => {
|
|
1215
|
+
const attempt = (schema, name = "conformance-refused", version = 1) => ctx.board.createSchema({
|
|
967
1216
|
name,
|
|
968
|
-
|
|
969
|
-
|
|
1217
|
+
version,
|
|
1218
|
+
schema
|
|
970
1219
|
});
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1220
|
+
const reserved = await attempt({ type: "object" }, "git-commit", 2).then(() => null, (error) => error);
|
|
1221
|
+
if (reserved instanceof BoardError && reserved.status === 403) return "this token can't register schemas";
|
|
1222
|
+
if (!(reserved instanceof BoardError && reserved.status === 409 && reserved.code === "reserved_schema")) throw new Mismatch(`a version of the built-in git-commit: expected 409 reserved_schema, ${reserved === null ? "and it registered one" : `got ${reserved instanceof BoardError ? `${reserved.status} ${reserved.code}` : String(reserved)}`}`);
|
|
1223
|
+
await rejects(attempt({ type: "string" }), 400, "invalid_schema", "a schema that describes no object");
|
|
1224
|
+
await rejects(attempt({
|
|
1225
|
+
type: "object",
|
|
1226
|
+
properties: { next: { $ref: "#" } }
|
|
1227
|
+
}), 400, "invalid_schema", "a schema with a $ref");
|
|
1228
|
+
await rejects(attempt({
|
|
1229
|
+
type: "object",
|
|
1230
|
+
properties: { id: {
|
|
1231
|
+
type: "string",
|
|
1232
|
+
pattern: "^(a+)+$"
|
|
1233
|
+
} }
|
|
1234
|
+
}), 400, "invalid_schema", "a schema with a pattern");
|
|
1235
|
+
await rejects(attempt({
|
|
1236
|
+
type: "object",
|
|
1237
|
+
properties: { ids: {
|
|
1238
|
+
type: "array",
|
|
1239
|
+
uniqueItems: true
|
|
1240
|
+
} }
|
|
1241
|
+
}), 400, "invalid_schema", "a schema with uniqueItems");
|
|
988
1242
|
}
|
|
989
1243
|
},
|
|
990
1244
|
{
|
|
991
|
-
group: "
|
|
992
|
-
name: "
|
|
1245
|
+
group: "schemas",
|
|
1246
|
+
name: "carries a block in a message, checked against the schema its fence names",
|
|
993
1247
|
run: async (ctx) => {
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
const
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1248
|
+
const registered = await register(ctx);
|
|
1249
|
+
if ("skip" in registered && !await ctx.board.schema("conformance@1").then(() => true, () => false)) return `${registered.skip}, and none registered conformance@1 before it`;
|
|
1250
|
+
const data = {
|
|
1251
|
+
run: ctx.labels.conformance,
|
|
1252
|
+
outcome: "passed",
|
|
1253
|
+
checks: [{
|
|
1254
|
+
name: "a block",
|
|
1255
|
+
skipped: false
|
|
1256
|
+
}]
|
|
1257
|
+
};
|
|
1258
|
+
const text = `conformance: a block among prose\n\n${block("conformance@1", data)}\n\nand after it`;
|
|
1259
|
+
const message = await post(ctx, text);
|
|
1260
|
+
same(message.text, text, "the post's text, as it was written");
|
|
1261
|
+
same(canonical(message.blocks), canonical([{
|
|
1262
|
+
schema: "conformance",
|
|
1263
|
+
version: 1,
|
|
1264
|
+
data
|
|
1265
|
+
}]), "the post's blocks");
|
|
1266
|
+
same(canonical((await ctx.board.thread(message.id)).message.blocks), canonical(message.blocks), "the post's blocks, read back");
|
|
1267
|
+
const alone = await post(ctx, block("conformance@1", data));
|
|
1268
|
+
same(canonical(alone.blocks), canonical([{
|
|
1269
|
+
schema: "conformance",
|
|
1270
|
+
version: 1,
|
|
1271
|
+
data
|
|
1272
|
+
}]), "the blocks of a message that is only one");
|
|
1273
|
+
const shown = await post(ctx, `conformance: a block shown, not carried\n\n\`\`\`\`\n${block("conformance@1", { outcome: "maybe" })}\n\`\`\`\``);
|
|
1274
|
+
same(canonical(shown.blocks), "[]", "the blocks of a message that shows one inside a longer fence");
|
|
1275
|
+
same(canonical((await post(ctx, "conformance: no block")).blocks), "[]", "the blocks of a message with none");
|
|
1276
|
+
const refusedPost = (body) => ctx.board.post(ctx.channel, {
|
|
1277
|
+
text: body,
|
|
1278
|
+
labels: ctx.labels,
|
|
1279
|
+
noSync: true
|
|
1280
|
+
}).then((wrong) => {
|
|
1281
|
+
ctx.posted.push(wrong.id);
|
|
1282
|
+
return wrong;
|
|
1000
1283
|
});
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
throw error;
|
|
1019
|
-
}
|
|
1020
|
-
same((await ctx.board.revokeToken(token.id)).revoked, true, "revoking it");
|
|
1021
|
-
await refused(holder.me(), 401, "a request with a revoked token");
|
|
1284
|
+
await rejects(refusedPost(block("conformance@1", {
|
|
1285
|
+
run: ctx.labels.conformance,
|
|
1286
|
+
outcome: "maybe"
|
|
1287
|
+
})), 400, "invalid_block", "a post whose block doesn't match its schema");
|
|
1288
|
+
await rejects(refusedPost(block("conformance-none@1", { run: ctx.labels.conformance })), 400, "schema_not_found", "a post whose block names a schema no one registered");
|
|
1289
|
+
await rejects(ctx.board.edit(alone.id, block("conformance@1", { outcome: "passed" })), 400, "invalid_block", "an edit whose block doesn't match its schema");
|
|
1290
|
+
same(canonical((await ctx.board.thread(alone.id)).message.blocks), canonical(alone.blocks), "the blocks of a message after an edit that was refused");
|
|
1291
|
+
}
|
|
1292
|
+
},
|
|
1293
|
+
{
|
|
1294
|
+
group: "schemas",
|
|
1295
|
+
name: "refuses a caller narrowed with x-board-can a schema, and lets it read them",
|
|
1296
|
+
run: async (ctx) => {
|
|
1297
|
+
if (!ctx.withCan) return NO_CAN;
|
|
1298
|
+
const narrowed = ctx.withCan(`${ctx.channel}=read,post`);
|
|
1299
|
+
check((await narrowed.schemas()).some((schema) => schema.id === "git-commit@1"), "a caller narrowed to a channel should read the schemas");
|
|
1300
|
+
await narrowedOut(narrowed.createSchema(SCHEMA), "registering a schema");
|
|
1022
1301
|
}
|
|
1023
1302
|
},
|
|
1024
1303
|
{
|
|
@@ -1112,7 +1391,7 @@ const CHECKS = [
|
|
|
1112
1391
|
},
|
|
1113
1392
|
{
|
|
1114
1393
|
group: "sync",
|
|
1115
|
-
name: "keeps sync's records: an import as a
|
|
1394
|
+
name: "keeps sync's records: an import as a profile of its importer, its lookups by platform ID, a receipt, and where it's synced",
|
|
1116
1395
|
run: async (ctx) => {
|
|
1117
1396
|
const key = SYNC_KEY;
|
|
1118
1397
|
const thread = `${key}:${ctx.labels.conformance}:1`;
|
|
@@ -1161,7 +1440,11 @@ const CHECKS = [
|
|
|
1161
1440
|
isRef(id, "an import's message");
|
|
1162
1441
|
try {
|
|
1163
1442
|
const message = (await ctx.board.thread(id)).message;
|
|
1164
|
-
same(message.by.actor, author.id
|
|
1443
|
+
same(message.by.actor, `${ctx.me.principal}+${author.id}`, "the import's author");
|
|
1444
|
+
same(message.by.principal, ctx.me.principal, "the import's principal");
|
|
1445
|
+
same(message.by.profile, author.id, "the import's profile");
|
|
1446
|
+
same(message.author?.name, author.name, "the import's author's name");
|
|
1447
|
+
check(message.author?.via !== void 0, `the import's author should say who it's via, got ${show(message.author)}`);
|
|
1165
1448
|
same(message.from, key, "the import's from");
|
|
1166
1449
|
same(message.origin?.thread, thread, "the import's origin");
|
|
1167
1450
|
const found = await ctx.board.syncFind({
|
|
@@ -1490,8 +1773,8 @@ async function conformance(board, options = {}) {
|
|
|
1490
1773
|
})).cursor,
|
|
1491
1774
|
me,
|
|
1492
1775
|
posted: [],
|
|
1493
|
-
...options.
|
|
1494
|
-
...options.
|
|
1776
|
+
...options.withCan ? { withCan: options.withCan } : options.withHeaders ? { withCan: (can) => options.withHeaders({ "x-board-can": can }) } : {},
|
|
1777
|
+
...options.withHeaders ? { withHeaders: options.withHeaders } : {},
|
|
1495
1778
|
principals: {
|
|
1496
1779
|
project: options.principals?.project ?? `prj_conformance${label}`,
|
|
1497
1780
|
repository: options.principals?.repository ?? `acme/conformance-${label}`,
|
|
@@ -1532,12 +1815,6 @@ async function conformance(board, options = {}) {
|
|
|
1532
1815
|
status: "skipped",
|
|
1533
1816
|
detail: "this board takes no GitHub or OIDC principals in a grant"
|
|
1534
1817
|
});
|
|
1535
|
-
else if (group === "tokens" && error instanceof BoardError && error.code === "unsupported_principal") checks.push({
|
|
1536
|
-
group,
|
|
1537
|
-
name,
|
|
1538
|
-
status: "skipped",
|
|
1539
|
-
detail: "this board mints tokens only for a deployment: run as one to check them"
|
|
1540
|
-
});
|
|
1541
1818
|
else checks.push({
|
|
1542
1819
|
group,
|
|
1543
1820
|
name,
|