Files
reverse-engineering-anything/src/domain/analysisErrorRefusal.ts
T
Adolanium 7e01f1df85 fix(browser): bound armed timeline rows by the retained-event allowance (#14799)
* fix(browser): bound armed timeline rows by the retained-event allowance

Armed timeline rows were appended with no byte budget. Pre-arm
messages and document request identities already stop at the
retained-event allowance.

Count each armed row before keeping it. A row that does not fit fails
the observation with payload_limit and does not return a shorter
timeline. Event count has no separate ceiling.

* chore(browser): format the timeline allowance check

oxfmt --check rejects the wrapped comparison in TimelineCapture.#add.

* fix(browser): give timeline retention a caller control

Armed timeline rows use browser.timeline_retained_bytes. A call can pass
timeline_retained_bytes. Request identities keep a separate counter.
A row that does not fit returns payload_limit with details.limit, including
a row admitted during terminal progress.

* fix(browser): refresh advertised schemas for the timeline allowance

The new setting and per-call field change the compact input hashes for
observe_web_session, inspect_analysis_settings, and update_analysis_settings.

* fix(browser): report measured timeline bytes without required_value

Admission stops at the first row that does not fit, so later rows are
unknown. measured_timeline_bytes records the rows already measured.
The budget test waits until all four lifecycle events are delivered.
2026-11-27 08:28:44 +08:00

88 lines
2.7 KiB
TypeScript

import {
AnalysisInputError,
AnalysisResourceConstraintError,
} from "./analysisErrorCore.js";
import type { AnalysisError } from "./analysisErrorBase.js";
import type { AnalysisRefusal } from "./analysisRefusal.js";
import { ArtifactOperationError } from "./artifactOperationError.js";
import { BrowserObservationError } from "./browserObservationError.js";
/**
* The typed refusal an error carries, attributed to the error's operation so
* a re-attributed error names the request that was refused. A registered
* setting and a per-call parameter are adjustable budgets; an environment
* control is not. Occupied capacity keeps its wait-and-retry recovery even
* when a setting bounds it.
*/
export const analysisErrorRefusal = (
error: AnalysisError,
): AnalysisRefusal | undefined => {
if (error instanceof AnalysisResourceConstraintError) {
if (error.fixedAllowance !== undefined)
return {
kind: "fixed_ceiling",
operation: error.operation,
ceiling: error.fixedAllowance,
};
const { limit } = error;
if (
limit !== undefined &&
(!("control_kind" in limit) || limit.control_kind === "parameter") &&
!(
"measuredExhaustion" in error.recovery &&
error.recovery.measuredExhaustion === true
)
)
return {
kind: "adjustable_budget",
operation: error.operation,
budget: limit,
};
return undefined;
}
if (
error instanceof ArtifactOperationError &&
error.fixedAllowance !== undefined
)
return {
kind: "fixed_ceiling",
operation: error.operation,
ceiling: error.fixedAllowance,
};
// A reader admission backed by a registered setting (artifact.member_count)
// is the same adjustable budget, with the per-call field as `parameter`.
if (
error instanceof ArtifactOperationError &&
error.readerLimit !== undefined &&
error.limit !== undefined &&
!("control_kind" in error.limit)
)
return {
kind: "adjustable_budget",
operation: error.operation,
budget: error.limit,
};
// Armed timeline retention is a browser observation failure, not a
// resource-constraint error. A bound setting is still an adjustable budget.
if (
error instanceof BrowserObservationError &&
error.limit !== undefined &&
!("control_kind" in error.limit)
)
return {
kind: "adjustable_budget",
operation: error.operation,
budget: error.limit,
};
if (
error instanceof AnalysisInputError &&
error.ambiguousSelector !== undefined
)
return {
kind: "ambiguous_selector",
operation: error.operation,
selector: error.ambiguousSelector,
};
return undefined;
};