Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/orb/ingest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const MAX_BATCH = 500;
const MAX_INSTANCE_ID_CHARS = 64;
const MAX_HASH_CHARS = 128;
const MAX_BUCKET_CHARS = 64;
const MAX_VERDICT_CHARS = 32;
const VALID_OUTCOMES = new Set(["merged", "closed"]);
const VALID_REVERSALS = new Set(["none", "reopened", "reverted"]);
const MIN_CYCLE_MS = 1_000; // <1s is implausible
Expand Down Expand Up @@ -166,7 +167,7 @@ export async function handleOrbIngest(body: string, db: D1Database): Promise<Orb
instance_id,
event.repo_hash,
event.pr_hash,
typeof event.gate_verdict === "string" ? event.gate_verdict : null,
typeof event.gate_verdict === "string" && event.gate_verdict.length <= MAX_VERDICT_CHARS ? event.gate_verdict : null,
event.outcome,
reversal,
typeof event.gate_reasoncode_bucket === "string" && event.gate_reasoncode_bucket.length <= MAX_BUCKET_CHARS ? event.gate_reasoncode_bucket : null,
Expand Down
5 changes: 3 additions & 2 deletions test/integration/orb-ingest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ describe("handleOrbIngest()", () => {
expect(await ingest(makeDb(), [ev({ outcome: "opened" })])).toEqual({ accepted: 0 });
});

it("stores gate_verdict string vs null", async () => {
it("stores gate_verdict string vs null, coercing an oversized value to null", async () => {
const db = makeDb();
await ingest(db, [ev({ pr_hash: "v1", gate_verdict: "merge" }), ev({ pr_hash: "v2" })]);
await ingest(db, [ev({ pr_hash: "v1", gate_verdict: "merge" }), ev({ pr_hash: "v2" }), ev({ pr_hash: "v3", gate_verdict: "v".repeat(33) })]);
expect(await col(db, "v1", "gate_verdict")).toBe("merge");
expect(await col(db, "v2", "gate_verdict")).toBeNull();
expect(await col(db, "v3", "gate_verdict")).toBeNull();
});

it("whitelists reversal_flag: valid kept, invalid + absent → 'none'", async () => {
Expand Down