feat(report): drop the report sky cover; docs, checklist and progress for M1–M5 (M5+M3)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
60b5542b7d
commit
447a19b561
@@ -1,34 +0,0 @@
|
||||
import type { BirthSkyOk } from "./contract.ts";
|
||||
import { fetchBirthSky } from "./cover.ts";
|
||||
import type { BirthSkyPaletteName } from "./draw.ts";
|
||||
import { birthSkyFactLine, birthSkyHeadline } from "./sentence.ts";
|
||||
|
||||
/** Screen (`night`) and print (`paper`) pictures of one report cover, painted by the same `drawBirthSky`. */
|
||||
export type ReportSkyCoverPngs = Readonly<{ screen: Blob; print: Blob; description: string }>;
|
||||
|
||||
export type ReportSkyCoverDeps = Readonly<{
|
||||
fetchSky: (subjectId: string, signal?: AbortSignal) => Promise<BirthSkyOk | null>;
|
||||
render: (sky: BirthSkyOk, palette: BirthSkyPaletteName) => Promise<Blob>;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Report cover loader (TASK-birth-sky-followup-20260928 F3). Resolves null on
|
||||
* any failure or abort; the report shows no cover and nothing else changes.
|
||||
*/
|
||||
export async function loadReportSkyCover(
|
||||
subjectId: string,
|
||||
signal: AbortSignal,
|
||||
deps?: ReportSkyCoverDeps,
|
||||
): Promise<ReportSkyCoverPngs | null> {
|
||||
try {
|
||||
const fetchSky = deps?.fetchSky ?? fetchBirthSky;
|
||||
const render = deps?.render ?? (await import("./render.ts")).renderBirthSkyPng;
|
||||
const sky = await fetchSky(subjectId, signal);
|
||||
if (!sky || signal.aborted) return null;
|
||||
const [screen, print] = await Promise.all([render(sky, "night"), render(sky, "paper")]);
|
||||
if (signal.aborted) return null;
|
||||
return { screen, print, description: `${birthSkyHeadline(sky)}${birthSkyFactLine(sky)}。` };
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -27,12 +27,7 @@ import {
|
||||
type SkillSnapshot,
|
||||
} from "./personal-report-generation";
|
||||
import { REPORT_STABLE_CODES } from "./personal-report-codes";
|
||||
import {
|
||||
readReportBirthFingerprint,
|
||||
reportCoverSubject,
|
||||
reportDocumentBirthFingerprint,
|
||||
reportSubjectId,
|
||||
} from "./report-birth-binding";
|
||||
import { readReportBirthFingerprint } from "./report-birth-binding";
|
||||
import { summarizePersonalReportFailure } from "./personal-report-failure-summary";
|
||||
import {
|
||||
deriveSectionProgressState,
|
||||
@@ -155,7 +150,6 @@ export function reportView(
|
||||
job?: PersonalReportJobRecord | null,
|
||||
failure?: ReturnType<typeof summarizePersonalReportFailure> | null,
|
||||
sections?: readonly ReportSectionProgress[] | null,
|
||||
coverSubject?: string | null,
|
||||
) {
|
||||
return {
|
||||
id: row.id,
|
||||
@@ -173,8 +167,6 @@ export function reportView(
|
||||
...(failure?.innerReason ? { innerReason: failure.innerReason } : {}),
|
||||
...(failure && failure.lastErrorCodes.length > 0 ? { sectionErrorCodes: failure.lastErrorCodes } : {}),
|
||||
...(failure?.appendixLastErrorCode ? { appendixLastErrorCode: failure.appendixLastErrorCode } : {}),
|
||||
// Report cover binding: a subject id or null, never the fingerprint itself.
|
||||
...(coverSubject !== undefined ? { coverSubject } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -688,30 +680,8 @@ export type ReportReadCoreDeps = Readonly<{
|
||||
lastErrorCode: string | null;
|
||||
markdown: string | null;
|
||||
} | null>;
|
||||
/**
|
||||
* Current birth fingerprint of one of the reader's own subjects (`"self"` or
|
||||
* a chart profile id), read on the server. Null or a throw means no cover.
|
||||
*/
|
||||
loadCurrentBirthFingerprint?: (userId: string, subjectId: string) => Promise<string | null>;
|
||||
}>;
|
||||
|
||||
/** Server-side comparison for the report cover; only its verdict leaves the server. */
|
||||
async function readyReportCoverSubject(
|
||||
deps: ReportReadCoreDeps,
|
||||
userId: string,
|
||||
row: PersonalReportRecord,
|
||||
): Promise<string | null> {
|
||||
const storedFingerprint = reportDocumentBirthFingerprint(row.reportDocument);
|
||||
if (!storedFingerprint || !deps.loadCurrentBirthFingerprint) return null;
|
||||
let currentFingerprint: string | null = null;
|
||||
try {
|
||||
currentFingerprint = await deps.loadCurrentBirthFingerprint(userId, reportSubjectId(row.chartProfileId));
|
||||
} catch {
|
||||
currentFingerprint = null;
|
||||
}
|
||||
return reportCoverSubject({ chartProfileId: row.chartProfileId, storedFingerprint, currentFingerprint });
|
||||
}
|
||||
|
||||
export async function resolveReportRead(deps: ReportReadCoreDeps): Promise<ReportRouteResponse> {
|
||||
const originDecision = checkSameOrigin(deps.requestUrl, deps.origin, deps.allowedOrigins, deps.requestHeaders);
|
||||
if (!originDecision.ok) {
|
||||
@@ -759,7 +729,6 @@ export async function resolveReportRead(deps: ReportReadCoreDeps): Promise<Repor
|
||||
))
|
||||
: null;
|
||||
if (row.status === "ready") {
|
||||
const coverSubject = await readyReportCoverSubject(deps, deps.userId, row);
|
||||
const markdownFromAppendix = appendix?.status === "ready" && appendix.markdown?.trim()
|
||||
? appendix.markdown
|
||||
: null;
|
||||
@@ -772,7 +741,7 @@ export async function resolveReportRead(deps: ReportReadCoreDeps): Promise<Repor
|
||||
return {
|
||||
status: 200,
|
||||
body: {
|
||||
report: reportView(row, job, null, null, coverSubject),
|
||||
report: reportView(row, job),
|
||||
longformMarkdown: projectOrdinaryReportMarkdown(markdown),
|
||||
...(validated.ok && validated.document && typeof validated.document === "object" && "charts" in validated.document
|
||||
? { calculationCharts: validated.document.charts } : {}),
|
||||
@@ -792,7 +761,7 @@ export async function resolveReportRead(deps: ReportReadCoreDeps): Promise<Repor
|
||||
if (deps.loadLongformMarkdown || deps.loadLongformAppendix) {
|
||||
return {
|
||||
status: 200,
|
||||
body: { report: reportView(row, job, null, null, coverSubject), longformMarkdown: null },
|
||||
body: { report: reportView(row, job), longformMarkdown: null },
|
||||
};
|
||||
}
|
||||
if (!validated.ok) {
|
||||
@@ -801,13 +770,13 @@ export async function resolveReportRead(deps: ReportReadCoreDeps): Promise<Repor
|
||||
body: {
|
||||
error: "报告内容未通过合同校验",
|
||||
code: REPORT_STABLE_CODES.schemaInvalid,
|
||||
report: reportView(row, job, null, null, coverSubject),
|
||||
report: reportView(row, job),
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
status: 200,
|
||||
body: { report: reportView(row, job, null, null, coverSubject), reportDocument: projectOrdinaryReportDocument(validated.document) },
|
||||
body: { report: reportView(row, job), reportDocument: projectOrdinaryReportDocument(validated.document) },
|
||||
};
|
||||
}
|
||||
return { status: 200, body: { report: reportView(row, job, failure, sectionProgress) } };
|
||||
|
||||
@@ -8,8 +8,10 @@ import { resolveServerOwnedChartBirth } from "./chart-birth-truth.ts";
|
||||
* `subject.birthFingerprint`. The fingerprint is the chart page's
|
||||
* `profileFingerprint`: `resolveServerOwnedChartBirth` over the **stored** row,
|
||||
* before any in-memory timezone fill. Reports generated before this field
|
||||
* existed never get one and never show a cover. Neither the fingerprint nor
|
||||
* any birth field leaves the server; the reader only receives `coverSubject`.
|
||||
* existed never get one. Nothing reads it back yet: the report sky cover that
|
||||
* compared it was removed (TASK-mobile-chart-and-confirmed-edit-20260929 M5,
|
||||
* product 2026-09-29); the field is kept so a later binding can use it. It is
|
||||
* never sent to a client or to the model.
|
||||
*/
|
||||
|
||||
/** Server-only key stamped on the loaded profile row; never persisted, never serialized to a client. */
|
||||
@@ -51,27 +53,3 @@ export function withReportBirthFingerprint<T>(document: T, fingerprint: string |
|
||||
if (!source || !subject || !fingerprint) return document;
|
||||
return { ...source, subject: { ...subject, birthFingerprint: fingerprint } } as T;
|
||||
}
|
||||
|
||||
export function reportDocumentBirthFingerprint(document: unknown): string | null {
|
||||
const value = record(record(document)?.subject)?.birthFingerprint;
|
||||
return typeof value === "string" && FINGERPRINT_PATTERN.test(value) ? value : null;
|
||||
}
|
||||
|
||||
/** The subject id the reader may ask `/api/birth-sky` for; `"self"` when the report has no chart profile. */
|
||||
export function reportSubjectId(chartProfileId: string | null): string {
|
||||
return chartProfileId && chartProfileId.trim() ? chartProfileId.trim() : "self";
|
||||
}
|
||||
|
||||
/**
|
||||
* `coverSubject` for `reportView`: the subject id only when the stored
|
||||
* fingerprint equals the subject's current one; null otherwise (mismatch,
|
||||
* legacy report without the field, foreign or deleted person, lookup failure).
|
||||
*/
|
||||
export function reportCoverSubject(input: Readonly<{
|
||||
chartProfileId: string | null;
|
||||
storedFingerprint: string | null;
|
||||
currentFingerprint: string | null;
|
||||
}>): string | null {
|
||||
if (!input.storedFingerprint || !input.currentFingerprint) return null;
|
||||
return input.storedFingerprint === input.currentFingerprint ? reportSubjectId(input.chartProfileId) : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user