feat(schema): commit summary fields

This commit is contained in:
Dave 2026-09-16 16:15:18 +02:00
parent 2401dbd68f
commit bce71a666a
2 changed files with 50 additions and 0 deletions

View file

@ -182,6 +182,47 @@ async function ensureProjectIngestFields(pb: PocketBase): Promise<void> {
}
}
/**
* Add the `summary`, `summary_version`, `summary_attempts` fields to commits.
*
* Stored alongside each generated one-liner:
* - summary_version — which PROMPT_VERSION produced it, so a stale summary
* can be detected and re-generated rather than served to a client as if it
* were current.
* - summary_attempts — consecutive failures. A message that trips the
* provider every time must not be retried forever on every ingest, so
* summarise.ts caps it.
*
* Re-runs are safe: fields are not duplicated.
*/
async function ensureCommitSummaryFields(pb: PocketBase): Promise<void> {
const commits = await pb.collections.getOne("commits");
const have = new Set(commits.fields.map((f: { name: string }) => f.name));
const additions = [
{ name: "summary", type: "text", required: false, max: 500 },
{ name: "summary_version", type: "number", required: false, onlyInt: true },
{ name: "summary_attempts", type: "number", required: false, onlyInt: true },
];
const fields = [...(commits.fields as unknown[])];
let changed = false;
for (const field of additions) {
if (!have.has(field.name)) {
fields.push({ ...field, presentable: false, hidden: false, system: false });
changed = true;
}
}
if (changed) {
await pb.collections.update(commits.id, { fields });
console.log(" + commits fields: summary, summary_version, summary_attempts");
} else {
console.log(" = commit summary fields already present");
}
}
async function ensureCardNumbers(pb: PocketBase): Promise<void> {
const cards = await pb.collections.getOne("cards");
const have = new Set(cards.fields.map((f: { name: string }) => f.name));
@ -772,6 +813,9 @@ async function main(): Promise<void> {
// collection already exists from earlier migrations).
await ensureProjectIngestFields(pb);
// Add the per-commit summary fields used by Phase 3b's AI one-liner job.
await ensureCommitSummaryFields(pb);
// Add the card number field and backfill existing cards.
await ensureCardNumbers(pb);

View file

@ -124,6 +124,12 @@ export interface CommitRecord extends BaseRecord {
card: string;
link_source: CommitLinkSource;
url: string;
/** Plain-English one-liner. Empty when not yet generated or generation failed. */
summary: string;
/** PROMPT_VERSION this summary was written under. */
summary_version: number;
/** Consecutive failed attempts. Capped so a poison message stops retrying. */
summary_attempts: number;
}
export interface ActivityRecord extends Omit<BaseRecord, "updated"> {