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
27 changes: 6 additions & 21 deletions scripts/create-live-run-evidence-template.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,6 @@ try {
if (!supportsFiledReturnsArtifactType(returnType, artifactType)) {
throw new Error("--artifact-type is not supported for --return-type.");
}
if (artifactType === "JSON" && outcome === "pass") {
// Refuse rather than emit evidence nothing can back. A standalone JSON
// selection is acquired by a direct authenticated same-origin fetch whose
// success flow step attaches no download diagnostic, for GSTR-3B and
// GSTR-2B alike. Only JSON captured as part of an all-formats selection is
// staged and retains one. An earlier revision of this guard covered GSTR-3B
// only, on the reasoning that the canonical endpoint-class rule rejects that
// pairing while admitting GSTR-2B — but the schema admitting a class is not
// the runtime producing it, and it is the runtime that has to back a claim.
throw new Error(
"Passing standalone JSON evidence is not supported: the direct JSON fetch path retains no download diagnostic, so nothing can back it. Record this run as blocked, or capture JSON as part of an all-formats selection.",
);
}
if (scenario === "full-year" && period !== "FULL_FISCAL_YEAR") {
throw new Error("Full-year evidence must use --period FULL_FISCAL_YEAR.");
}
Expand Down Expand Up @@ -334,19 +321,17 @@ function collectLimitations(input, { checks, outcome, profile, scenario }) {
}

function defaultEndpointClass(returnType, artifactType) {
// GSTR-3B portal data (JSON) has no endpoint class the runtime can back: its
// direct same-origin fetch path attaches no download diagnostic, and the
// canonical `isFiledReturnsEndpointClassForArtifact` admits no GSTR-3B/JSON
// pairing. `unknown` is the only truthful default; naming a blob-captured
// class let the generator emit passing evidence nothing could support.
// GSTR-2B JSON is different and is left alone — the canonical rule does admit
// it with the GSTR-2B blob-captured class.
if (returnType === "GSTR-3B" && artifactType === "JSON") return "unknown";
if (returnType === "GSTR-3B" && artifactType === "JSON") {
return "gstr3b-main-world-json-captured-download";
}
if (returnType === "GSTR-3B") return "gstr3b-portal-blob-captured-download";
if (returnType === "GSTR-1" && artifactType === "EXCEL") {
return "gstr1-excel-portal-blob-captured-download";
}
if (returnType === "GSTR-1") return "gstr1-pdf-portal-blob-captured-download";
if (returnType === "GSTR-2B" && artifactType === "JSON") {
return "gstr2b-main-world-json-captured-download";
}
if (returnType === "GSTR-2B") return "gstr2b-portal-blob-captured-download";
return "unknown";
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/lib/live-run-evidence-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ export type LiveRunDownloadPathClass =
export type LiveRunEndpointClass =
| "gstr3b-portal-rendered-download"
| "gstr3b-portal-blob-captured-download"
| "gstr3b-main-world-json-captured-download"
| "gstr1-pdf-portal-rendered-download"
| "gstr1-excel-portal-rendered-download"
| "gstr1-pdf-portal-blob-captured-download"
| "gstr1-excel-portal-blob-captured-download"
| "gstr2b-portal-blob-captured-download"
| "gstr2b-main-world-json-captured-download"
| "filed-return-portal-rendered-download"
| "unknown";
export type LiveRunEvidenceLimitation =
Expand Down
23 changes: 4 additions & 19 deletions scripts/lib/live-run-evidence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ const DOWNLOAD_EVIDENCE_KEYS = [
const DOWNLOAD_ENDPOINT_CLASSES = [
"gstr3b-portal-rendered-download",
"gstr3b-portal-blob-captured-download",
"gstr3b-main-world-json-captured-download",
"gstr1-pdf-portal-rendered-download",
"gstr1-excel-portal-rendered-download",
"gstr1-pdf-portal-blob-captured-download",
"gstr1-excel-portal-blob-captured-download",
"gstr2b-portal-blob-captured-download",
"gstr2b-main-world-json-captured-download",
"filed-return-portal-rendered-download",
"unknown",
] as const;
Expand Down Expand Up @@ -208,18 +210,6 @@ export function validateLiveRunEvidence(input: unknown): LiveRunEvidenceValidati
"artifactType",
errors,
);
// A standalone JSON selection is acquired by the direct same-origin fetch in
// filed-returns-download-trigger.ts, whose success flow step carries no
// downloadDiagnostic at all — for either return type. Nothing the runtime
// retains can back a passing claim about it, so refuse rather than certify.
// JSON acquired as part of an all-formats selection is staged and does retain
// a diagnostic, so those rows stay valid; only the standalone selection is
// unbackable.
if (input.artifactType === "JSON" && input.outcome === "pass") {
errors.push(
"artifactType JSON cannot record a pass outcome: the standalone JSON path retains no download diagnostic, so no evidence can back it. Record the run as blocked, or capture JSON as part of an all-formats selection.",
);
}
requirePattern(input.financialYear, FINANCIAL_YEAR, "financialYear", errors);
requireOneOf(input.period, PERIODS, "period", errors);
requireOneOf(input.scenario, ["single-period", "full-year"], "scenario", errors);
Expand Down Expand Up @@ -442,13 +432,8 @@ function validateDownloadEndpointPathConsistency(
}

function isSupportedLiveRunEvidenceEndpoint(entry: LiveRunDownloadEvidence): boolean {
// Defer entirely to the canonical predicate. The exception that used to sit
// here accepted `gstr3b-portal-blob-captured-download` for GSTR-3B JSON, a
// pairing the canonical rule rejects and the runtime never produces: the
// direct JSON fetch path attaches no diagnostic at all. Evidence for a JSON
// artifact therefore carries `unknown`, which the canonical predicate already
// admits. A local exception here could only ever certify something the
// runtime cannot back.
// Defer entirely to the canonical predicate so evidence can only describe a
// return/artifact acquisition path the runtime itself produces.
return isFiledReturnsEndpointClassForArtifact(
entry.endpointClass,
entry.returnType,
Expand Down
2 changes: 2 additions & 0 deletions src/background/filed-returns-download-diagnostic-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ const DOWNLOAD_DIAGNOSTIC_KEYS = [
const VALID_ENDPOINT_CLASSES = new Set([
"gstr3b-portal-rendered-download",
"gstr3b-portal-blob-captured-download",
"gstr3b-main-world-json-captured-download",
"gstr3b-browser-managed-direct-download",
"gstr1-pdf-portal-rendered-download",
"gstr1-excel-portal-rendered-download",
"gstr1-pdf-portal-blob-captured-download",
"gstr1-excel-portal-blob-captured-download",
"gstr2b-portal-blob-captured-download",
"gstr2b-main-world-json-captured-download",
"filed-return-portal-rendered-download",
"unknown",
]);
Expand Down
4 changes: 3 additions & 1 deletion src/background/filed-returns-download-diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ function endpointClassForTarget(
attemptClass: DownloadAttemptClass,
): FiledReturnsDownloadEndpointClass {
if (target.returnType === "GSTR-3B" && attemptClass === "captured-portal-request") {
return "gstr3b-portal-blob-captured-download";
return target.artifactType === "JSON"
? "gstr3b-main-world-json-captured-download"
: "gstr3b-portal-blob-captured-download";
}
if (target.returnType === "GSTR-3B" && attemptClass === "extension-direct") {
return "gstr3b-browser-managed-direct-download";
Expand Down
Loading
Loading