mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
* fix(native): keep unreported value-flow truncation and archive decode coverage unknown * test(verify): count multiline optional-fact defaults and pin the guard's exclusions * fix(domain): keep unknown counts and costs unknown in comparison and coverage summaries (#11325) * fix(domain): keep unknown counts and costs unknown in comparison and coverage summaries * refactor(verify): exempt legitimate optional-fact defaults with a reasoned marker (#11355) * refactor(verify): exempt legitimate optional-fact defaults with a reasoned marker The optional-fact-default guard counted request defaults and absence that is modelled elsewhere as hidden unknowns. A comment `// optional-fact-default: <reason>` on the default's line or the line before now exempts it; the guard reads unstripped source for the marker and ignores matches inside comment lines. Marked: the two evidence paging offsets and four Swift literal reads whose absence swiftLiteralCoverage reports. Removed instead of marked: jsdiff 9 types Change.count as required, so its two `?? 0` defaults were dead; the evidence link traversal now carries retained records, so it no longer re-looks them up behind `?? []`. Baseline 31 -> 22. * fix(verify): blank comment spans instead of skipping comment-led lines in the optional-fact guard Skipping a match whose line starts like a comment hid live code after a leading block comment and counted defaults inside a block comment without leading stars. The counter now blanks comment text (keeping offsets and line breaks, skipping string literals) and matches the blanked code, while exemption markers are still read from the original lines. * refactor(domain): mark optional-fact defaults whose absence is not an observation (#11389) * refactor(domain): mark optional-fact defaults whose absence is not an observation Per-site review of the remaining optional-fact-default entries. Each marked default is a caller option (trace ignore_fields, environment rules), a list whose producer omits the empty case (unknown_size_frames, the schema's min-1 representation_node_ids), caveat text whose completeness another field carries (call diagnostics, unresolved calls, semantic resource limits), or absence that already turns the result unknown (Wasm interface inventory, WebMCP discovery, managed ExportedType rows, legacy integrity mismatch IDs). Left counted: webCaptureDiff redirects (2; the CDP producer always records them, so absence is a legacy record that should compare as unknown, not as no redirects) and HopperCallerReconciliation (2; index-miss semantics not yet verified). Baseline 22 -> 4. * fix(browser): compare redirects as unknown when a capture predates redirect recording (#11402) * fix(browser): compare redirects as unknown when a capture predates redirect recording The CDP producer records every request's redirect chain, empty when there was none; a record without one predates redirect recording (#986). Comparing it against a current capture reported the network dimension as unchanged, treating the missing chain as "no redirects". Redirects are now compared only when both captures recorded them, and the network dimension is otherwise unknown with a reason; proven membership changes are still reported. * refactor(hopper): interpret a caller-index miss once at the lookup (#11403) The forward index holds observations from the examined procedures only, and relationship coverage stays unknown with the scan facts as its reason. A miss therefore adds no callers without showing there are none; the lookup now says so once instead of four optional reads defaulting at each site. The optional-fact-default baseline is now empty. * docs(javascript): state why an omitted representation list adds no nodes * fix(verify): count optional-fact defaults from parsed TypeScript, not comment-blanked text The guard blanked comments with a hand-written scanner and matched a regular expression on the rest, so a default quoted in a string counted and a regular expression holding /* hid the code after it. It now walks the TypeScript syntax tree for property reads defaulted with ?? 0, ?? [] or ?? false, and reads exemption markers only from comment trivia. * fix(verify): tokenize optional-fact defaults without a compiler and count chained defaults * fix(verify): match whole optional-fact default expressions across calls and operators * fix(verify): count optional-fact defaults in template substitutions and after postfix updates, and tie markers to their own expression * refactor(verify): exempt generation and sample caps from the constant-maximum-slice guard by reason marker (#11454) * refactor(verify): exempt generation and sample caps from the constant-maximum-slice guard by reason marker * fix(verify): read reason markers only from real line comments * fix(verify): read reason markers from the shared source tokenizer * fix(verify): read a regular expression after a control head as a statement start The shared tokenizer treated every closing parenthesis as the end of an operand, so in `if (ready) /[/*]/.test(v)` it read `/[` as division and `/*` inside the regex as a block comment, hiding the rest of the file from the marker-aware guards. Parentheses are now tracked: the `)` closing an if/while/for/with head allows a regular expression, while a call's `)` still means division. * fix(verify): keep a keyword-named member call out of control-head detection `policy.if(ready) / (…)` was read as an if-statement head, so the division was taken for a regular expression and the denominator's optional-fact default was not counted. A control keyword after `.` or `?.` is a member call. * refactor(verify): exempt budget-arithmetic cursors and tallies by a not-an-allowance marker (#11493) * refactor(verify): exempt budget-arithmetic cursors and tallies by a not-an-allowance marker The budget-arithmetic guard cannot tell a scan cursor, an observed total, a string being assembled or a tail buffer's retained length from an allowance when each is compared with a limit. A field declaration marked `// not-an-allowance: <reason>` (read through the shared reason-marker scan) is no longer counted. The four remaining sites carry a marker, so the baseline is empty and removed. * refactor(verify): exempt detail levels, lifecycle states and domain vocabularies from the completeness-enum guard by reason marker (#11510) A zod enum containing "complete" is counted as a local coverage vocabulary. Eleven are not coverage: a caller-chosen detail level, how far a command or session ran, and format states (GPU decode depth, WASM name section, SQLite column details). They now carry `// detail-level:`, `// lifecycle-state:` or `// domain-vocabulary:` with a reason, read through the shared reason-marker scan (which gains an optional predicate for the matches a guard counts). local-completeness-enum: 22 -> 11 on this branch. * fix(verify): bind a not-an-allowance marker to its own class field Exemptions were a file-wide set of names, so a marked tally in one class hid an unmarked allowance with the same name in another, and a marked object property could exempt a class field. Markers now exempt only a member declaration (at class member depth) of the top-level class that contains it, and the named- allowance count is taken per class so the same scoping applies to it. * fix(artifacts): keep main's resources import in the Deno standalone reader after merging main * fix(verify): start an expression after a template substitution and a non-member keyword, and accept any marker reason The shared tokenizer read the `/` after `${` as division, so a regular expression holding `/*` in a substitution hid the rest of the file from every tokenizer-based guard, and it treated property names such as `row.return` as keywords. Tokens now record whether template text opens a substitution and whether a name is an expression keyword (not after `.` or `?.`), and the regular-expression rule and the optional-fact-default operand rule read those facts. The optional-fact-default guard reads markers through reason-marker's isReasonMarker, so any non-empty reason exempts, as for the other reason markers. * fix(verify): blank comments with the shared tokenizer before matching architecture guards (#11573) * fix(verify): blank comments with the shared tokenizer before matching architecture guards The guards stripped comments with a regular expression that took a `/*` inside a string, template or regular expression for a comment opener and deleted code up to the next `*/`. src/flutter/FlutterBuildProvider.ts's "lib/*/libapp.so" text hid four --pool-policy remediation strings from cli-option-text-outside-cli. blankComments in source-tokens.mjs now owns comment removal for the architecture guards and the reason-marker scan: it blanks comment tokens in place (newlines kept) and keeps strings, templates and regular expressions. The scan behind it retains only the last tokens it reads, and whitespace runs are skipped at once. The cli-option-text-outside-cli baseline records FlutterBuildProvider.ts at its true count of 4; no other baseline changed. Fixes #11477 * fix(verify): read a regular expression after a statement block and keep comment offsets for wide characters The tokenizer now records whether each `{` opens a statement block or an object literal (from the token before it) and marks the `}` that closes a block, after which a statement, and so a regular expression, can start; an object literal's `}` still ends an operand. blankComments replaces each run of comment text with one space per UTF-16 unit, so a surrogate pair no longer shifts later offsets. * chore(verify): drop the Flutter CLI-text baseline entry now that main names no option there
179 lines
7.1 KiB
TypeScript
179 lines
7.1 KiB
TypeScript
import { isWellFormedXml, opensLikeXml } from "../xmlDocument.js";
|
|
import type { NamedFacts } from "./appTaskDraftNamed.js";
|
|
import { doctypeHasInternalSubset, XML_POLICY } from "./stateFormats.js";
|
|
|
|
/** Why a file in a draft has few or no suggested checks, one code per reason. */
|
|
export const FILE_NOTE_CODES = [
|
|
"by_position",
|
|
"view_state_only",
|
|
"long_text",
|
|
"cut_view",
|
|
"unreadable_view",
|
|
"volatile_lines",
|
|
"generated_reference",
|
|
"read_as_text",
|
|
] as const;
|
|
|
|
/** One reason a drafted file's suggestions are thin, with the facts it rests on. */
|
|
export interface FileNote {
|
|
readonly code: (typeof FILE_NOTE_CODES)[number];
|
|
readonly file: string;
|
|
readonly message: string;
|
|
/** `by_position`: the tags of elements no attribute names alone, up to five. */
|
|
readonly elements?: readonly string[];
|
|
/** `long_text`: the elements whose text is too long; `view_state_only`: the noise checks kept. Up to five. */
|
|
readonly pointers?: readonly string[];
|
|
}
|
|
|
|
const MAX_LISTED = 5;
|
|
|
|
/** Explain a relationship whose generated ID cannot be compared across runs. */
|
|
export const generatedReferenceNotes = (
|
|
file: string,
|
|
pointers: readonly string[],
|
|
): FileNote[] =>
|
|
pointers.length === 0
|
|
? []
|
|
: [
|
|
{
|
|
code: "generated_reference",
|
|
file,
|
|
message:
|
|
"Some array values refer to newly generated record IDs and cannot be checked exactly across runs; review the relationship manually.",
|
|
// sample-cap: example pointers; the file's change lists every pointer
|
|
pointers: pointers.slice(0, MAX_LISTED),
|
|
},
|
|
];
|
|
|
|
/** What a file's change says about whether its views can show it. */
|
|
export interface ChangeShape {
|
|
readonly kind: string;
|
|
readonly complete: boolean | undefined;
|
|
readonly format: string | null;
|
|
}
|
|
|
|
/** Notes on what a file's views could not show: one cut short, or one no check can read. */
|
|
const viewNotes = (file: string, change: ChangeShape): FileNote[] => {
|
|
const home = `~/${file}`;
|
|
if (
|
|
change.kind === "unreadable" ||
|
|
change.kind === "format" ||
|
|
(change.kind === "content" && change.format === "binary")
|
|
)
|
|
return [
|
|
{
|
|
code: "unreadable_view",
|
|
file,
|
|
message:
|
|
change.format === "binary"
|
|
? `REA reads ${home} as binary, so no check can look inside it on its own: give the task one of its readers, the app's own headless command printing what the file holds, and check that reader's view; or save it in a format the app offers that REA reads, such as XML, JSON or text, plain or gzip-compressed, or a zip document, and capture again.`
|
|
: `REA could not read ${home} at one end the same way as at the other, so no check can look inside it; its versions' view_error says why.`,
|
|
},
|
|
];
|
|
return change.kind === "content" || change.complete === false
|
|
? [
|
|
{
|
|
code: "cut_view",
|
|
file,
|
|
message: `REA's view of ${home} holds only part of it, so the change may lie outside what a check can see; check what the views do show, or keep the document smaller.`,
|
|
},
|
|
]
|
|
: [];
|
|
};
|
|
|
|
/** Notes on why a file's suggested checks are thin, from the facts its draft gathered. */
|
|
const factNotes = (file: string, facts: NamedFacts): FileNote[] => {
|
|
const home = `~/${file}`;
|
|
const notes: FileNote[] = [];
|
|
if (facts.positional > 0 || facts.changes === 0) {
|
|
// sample-cap: example elements; the file's change lists every pointer
|
|
const elements = facts.positionalTags.slice(0, MAX_LISTED);
|
|
notes.push({
|
|
code: "by_position",
|
|
file,
|
|
message:
|
|
facts.changes === 0
|
|
? `${home} changed only in where its elements sit, which no check names; check a value an attribute names instead.`
|
|
: `${String(facts.positional)} change(s) in ${home} reach their element only by position, so no check names them${elements.length === 0 ? "" : `: ${elements.join(", ")} has no attribute naming it alone among its siblings`}. Their values carry note by_position; check an ancestor's text or a value an attribute names, or give the element a name in the app.`,
|
|
...(elements.length === 0 ? {} : { elements }),
|
|
});
|
|
}
|
|
if (facts.changes > 0 && facts.noise === facts.changes)
|
|
notes.push({
|
|
code: "view_state_only",
|
|
file,
|
|
message: `Every change in ${home} is view state, a renumbered id, a volatile value or a time the app stamps, not an edit: ${facts.flagged.length === 0 ? "no check is suggested" : "the suggested checks are those, kept so the draft is not empty"}. Save the edit the task is about, then capture again.`,
|
|
...(facts.flagged.length === 0
|
|
? {}
|
|
: { pointers: facts.flagged.slice(0, MAX_LISTED) }), // sample-cap: example pointers; the file's change lists every pointer
|
|
});
|
|
if (facts.long.length > 0)
|
|
notes.push({
|
|
code: "long_text",
|
|
file,
|
|
message: `${String(facts.long.length)} value(s) in ${home} exceed the 2,000-character check limit, so whole-value checks were omitted; use a smaller check where supported.`,
|
|
// sample-cap: example pointers; the note states the full count
|
|
pointers: facts.long.slice(0, MAX_LISTED),
|
|
});
|
|
return notes;
|
|
};
|
|
|
|
/** Why a drafted file's suggestions are thin: its views could not show the change, or its draft's facts. */
|
|
export const fileNotes = (
|
|
file: string,
|
|
change: ChangeShape,
|
|
facts: NamedFacts | undefined,
|
|
): FileNote[] => [
|
|
...viewNotes(file, change),
|
|
...(facts === undefined ? [] : factNotes(file, facts)),
|
|
];
|
|
|
|
/** The text a check of whether a file opens like XML reads, enough for a declaration and a DOCTYPE. */
|
|
const OPENING_CHARS = 2048;
|
|
|
|
/** The bounded opening used to recognize a text view of an XML document. */
|
|
const textOpening = (lines: readonly string[]): string => {
|
|
let opening = "";
|
|
for (const line of lines) {
|
|
opening += `${line}\n`;
|
|
if (opening.length > OPENING_CHARS) break;
|
|
}
|
|
return opening.trimStart();
|
|
};
|
|
|
|
/** Text views can preserve XML that the structured reader cannot admit. */
|
|
export const textOpensXml = (lines: readonly string[]): boolean =>
|
|
opensLikeXml(textOpening(lines));
|
|
|
|
/**
|
|
* A note on a text file that opens like XML, with a declaration, a DOCTYPE
|
|
* or an element, and so reads as text only because it is not XML REA reads:
|
|
* its DOCTYPE has an internal subset, which can declare entities, or it is
|
|
* not well formed. Its checks compare lines, which hold attributes in the
|
|
* order the app wrote them.
|
|
*/
|
|
export const readAsTextNotes = (
|
|
file: string,
|
|
lines: readonly string[],
|
|
): FileNote[] => {
|
|
const opening = textOpening(lines);
|
|
if (!opensLikeXml(opening)) return [];
|
|
if (
|
|
!doctypeHasInternalSubset(opening) &&
|
|
isWellFormedXml(opening, XML_POLICY)
|
|
)
|
|
return [];
|
|
const why = doctypeHasInternalSubset(opening)
|
|
? "its DOCTYPE has an internal subset, which can declare entities"
|
|
: isWellFormedXml(opening, { doctype: "external" })
|
|
? "its XML names are not supported by the exported reader"
|
|
: "it is not well-formed XML";
|
|
return [
|
|
{
|
|
code: "read_as_text",
|
|
file,
|
|
message: `~/${file} opens like XML but reads as text, since ${why}, so its checks compare lines, each holding its attributes in the order the app wrote them.`,
|
|
},
|
|
];
|
|
};
|