fix(report): use the upstream reader edition for new longform bodies

New reports request reader_main from upstream origin/main 23b9609e.
KP and transit no longer copy an empty vars() dict, solar returns keep
birth_asc_sign_idx, and ordinary projection deletes internal lines whole.
This commit is contained in:
jesse-ux
2026-09-25 02:21:46 +08:00
parent 59c2301838
commit 3c2f7bd559
22 changed files with 3126 additions and 65 deletions
@@ -148,7 +148,7 @@ async function fetchLongformMarkdown(input: Readonly<{
const upstream = await input.fetchImpl(`${input.apiBase.replace(/\/$/, "")}/api/professional_report_reference`, {
method: "POST",
headers: { "Content-Type": "application/json", Accept: "application/json" },
body: JSON.stringify({ ...input.payload, include_fact_tables: true }),
body: JSON.stringify({ ...input.payload, include_fact_tables: true, edition: "reader_main" }),
cache: "no-store",
signal,
});
+44 -9
View File
@@ -184,6 +184,20 @@ export const ORDINARY_OUTPUT_LEAK_PATTERNS: readonly RegExp[] = [
/<\s*object\b/i,
/<\s*embed\b/i,
/<\s*img\b/i,
/\bblocked\b/i,
/\bexecuted\b/i,
/\bpartial_verified\b/i,
/\bmissing_in_local\b/i,
/\bproducer\b/i,
/\bparity\b/i,
/PL9\s*第\s*\d+\s*页/,
/full-report:\/\//,
/\bpl9_[A-Za-z0-9_]+\b/i,
/\b[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+)*_unavailable\b/,
/\b[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+)*_(?:pack|packet)\b/i,
/object has no attribute/,
/\bTraceback\b/,
/(?:\b[A-Za-z]{2,}(?:'[A-Za-z]+)?\b\s+){11}\b[A-Za-z]{2,}(?:'[A-Za-z]+)?\b/,
];
export function ordinaryOutputLeaks(text: string): string[] {
@@ -319,15 +333,40 @@ function limitationsFromSignals(input: ChatExportInput): string[] {
return notes;
}
function adjacentInternalTableIndexes(blocks: Block[]): Set<number> {
const drop = new Set<number>();
blocks.forEach((block, index) => {
if (block.type !== "table" || !tableIsInternal(block.text)) return;
drop.add(index);
let cursor = index - 1;
while (cursor >= 0 && blocks[cursor]?.type === "blank") cursor -= 1;
if (cursor >= 0 && (blocks[cursor]?.type === "paragraph" || blocks[cursor]?.type === "list")) {
drop.add(cursor);
cursor -= 1;
while (cursor >= 0 && blocks[cursor]?.type === "blank") cursor -= 1;
}
if (cursor >= 0 && blocks[cursor]?.type === "heading") drop.add(cursor);
});
return drop;
}
function analyzeOrdinaryReportMarkdown(markdown: string): Analysis {
if (!markdown) return { prose: markdown, limitations: [], changed: false };
const blocks = parseBlocks(markdown);
const dropWithTable = adjacentInternalTableIndexes(blocks);
const limitations = new Set<string>();
const kept: string[] = [];
let changed = false;
let skipUntilLevel: number | null = null;
for (const block of blocks) {
for (let index = 0; index < blocks.length; index += 1) {
const block = blocks[index];
if (!block) continue;
if (dropWithTable.has(index)) {
changed = true;
collectLimitations(block.raw, limitations);
continue;
}
if (block.type === "heading") {
const level = block.level ?? 1;
if (skipUntilLevel !== null && level <= skipUntilLevel) skipUntilLevel = null;
@@ -419,15 +458,11 @@ function projectProseLine(line: string): { keep: boolean; text: string; limitati
if (field && isInternalKey(field[1])) {
return { keep: false, text: "", limitations: notesForField(field[1], field[2] ?? "") };
}
const tokenAt = line.search(INTERNAL_KEY_TOKEN);
const limitations = tokenAt >= 0 ? notesFromText(line.slice(tokenAt)) : [];
const visible = tokenAt >= 0 ? line.slice(0, tokenAt) : line;
const cleaned = projectInline(visible);
if (!cleaned.trim()) return { keep: false, text: "", limitations };
if (containsInternalToken(cleaned) || ordinaryOutputLeaks(cleaned).length > 0) {
return { keep: false, text: "", limitations };
const cleaned = projectInline(line);
if (!cleaned.trim() || containsInternalToken(cleaned) || ordinaryOutputLeaks(cleaned).length > 0) {
return { keep: false, text: "", limitations: notesFromText(line) };
}
return { keep: true, text: cleaned, limitations };
return { keep: true, text: cleaned, limitations: [] };
}
/** Safety-only boundary for the separately authorized raw attachment, not prose projection. */