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
743 changes: 743 additions & 0 deletions apps/hub/src/artifacts/approval-rounds.test.ts

Large diffs are not rendered by default.

1,323 changes: 1,323 additions & 0 deletions apps/hub/src/artifacts/approval-rounds.ts

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions apps/hub/src/artifacts/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { actorOf } from "../projects/authorization.ts";
import { ProjectError } from "../projects/errors.ts";
import { readJson } from "../lib/json.ts";
import { mailRunAsCaller } from "../mail/caller-mail.ts";
import { mountApprovalRoundRoutes } from "./approval-rounds.ts";
import type { createArtifactService } from "./service.ts";

const security = [
Expand Down Expand Up @@ -755,4 +756,5 @@ export function mountArtifactRoutes(
);
},
);
mountApprovalRoundRoutes(app, service.approvalRounds);
}
8 changes: 8 additions & 0 deletions apps/hub/src/artifacts/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ import {
readProjectPackageSource,
validateApprovalPackage,
} from "./approval-package.ts";
import {
createApprovalRoundService,
createPgApprovalRoundStore,
} from "./approval-rounds.ts";
import { requestErrorMetadata } from "../request-error.ts";

const log = getLogger(["corbits-builder", "hub", "artifacts"]);
Expand Down Expand Up @@ -2181,5 +2185,9 @@ export function createArtifactService(
);
return { design, concept: stored.title };
},

approvalRounds: createApprovalRoundService(
createPgApprovalRoundStore(rawDB),
),
};
}
87 changes: 87 additions & 0 deletions apps/hub/src/config/approval-rounds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
export type PackageManifestSource = {
kind: string;
version: number;
sha256: string;
title?: string;
};

export const DEFAULT_WORKSPACE_REVIEWERS = [
{
id: "ws-rev-dana-chen",
name: "Dana Chen",
persona: "CEO",
email: "dana.chen@example.com",
},
{
id: "ws-rev-marcus-vance",
name: "Marcus Vance",
persona: "CTO",
email: "marcus.vance@example.com",
},
{
id: "ws-rev-priya-patel",
name: "Priya Patel",
persona: "VP Product",
email: "priya.patel@example.com",
},
] as const;

export function packageReadme(input: {
projectTitle: string;
packageTitle: string;
version: number;
reviewer?: { name: string; persona: string };
audience?: string;
decision?: string;
note?: string;
sources: readonly PackageManifestSource[];
documents: readonly string[];
}): string {
const lines = [
`# ${input.projectTitle} — ${input.packageTitle} (v${String(input.version)})`,
"",
];
if (input.reviewer !== undefined && input.reviewer.name.trim() !== "") {
const personaSuffix =
input.reviewer.persona.trim() === ""
? ""
: ` (${input.reviewer.persona.trim()})`;
lines.push(
`Prepared for: ${input.reviewer.name.trim()}${personaSuffix}`,
"",
);
}
if (input.audience !== undefined && input.audience.trim() !== "") {
lines.push(`**Audience:** ${input.audience.trim()}`, "");
}
if (input.decision !== undefined && input.decision.trim() !== "") {
lines.push(`**Decision needed:** ${input.decision.trim()}`, "");
}
if (input.note !== undefined && input.note.trim() !== "") {
lines.push(input.note.trim(), "");
}
lines.push(
"## Package Contents",
"",
"- `deck.pptx` — Editable presentation deck",
"- `deck.pdf` — Printable presentation PDF",
"- `manifest.json` — Pinned source document versions and SHA-256 digests",
);
for (const path of input.documents) {
lines.push(`- \`${path}\` — Supporting project document`);
}
if (input.sources.length > 0) {
lines.push("", "## Grounded Source Manifest", "");
for (const source of input.sources) {
const label =
source.title === undefined
? source.kind
: `${source.title} (${source.kind})`;
lines.push(
`- ${label}: v${String(source.version)} (\`${source.sha256}\`)`,
);
}
}
lines.push("");
return lines.join("\n");
}
21 changes: 21 additions & 0 deletions apps/hub/src/db/migrations/0037_approval_round.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE "sb_approval_round" (
"id" text PRIMARY KEY NOT NULL,
"tenant_id" text NOT NULL,
"project_id" text NOT NULL,
"artifact_id" text NOT NULL,
"package_version" integer NOT NULL,
"package_sha256" text NOT NULL,
"started_by" text NOT NULL,
"expiry_preset" text NOT NULL,
"expires_at" timestamp with time zone NOT NULL,
"settled_at" timestamp with time zone,
"reviewers" jsonb NOT NULL,
"triage" jsonb DEFAULT '[]'::jsonb NOT NULL,
"triggered_run_id" text,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "sb_approval_round" ADD CONSTRAINT "sb_approval_round_tenant_id_tenant_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenant"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "sb_approval_round" ADD CONSTRAINT "sb_approval_round_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "sb_approval_round" ADD CONSTRAINT "sb_approval_round_started_by_principal_id_fk" FOREIGN KEY ("started_by") REFERENCES "public"."principal"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "sb_approval_round_project_idx" ON "sb_approval_round" USING btree ("tenant_id","project_id","created_at");
Loading