experiments/filterlang: enforce Request immutability via inferred const types #1702
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.39) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 269 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.335
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1702"
general
weight: 0.35
justinsb
Enforces immutability of
Request(and other read-only host objects and nested collections) throughexperiments/filterlang's type system using purely inferredconstqualifiers, without adding a surface-syntaxconstkeyword or complicating the common case.Summary of Changes
consttype qualifier (types.go,unify.go): AddedConstand internal inferred qualifier variables with canonical flattening (idempotentconst,Nullableoutermost, scalar value typesbool/int/str/Nonecollapsing automatically), transitiveMakeConst, covariantT -> const Tassignability without strippingconst, andconst-preservingJoin/JoinConst.builtins.go,eval_builtins.go,value.go,eval.go): AddedBuiltinMethod.Mutates(defaultfalse= read-only),HostField(Writabledefaultfalse) with defensive nil-type guards,Builtins.RegisterField/FieldsandRegisterType/Type, and an opt-inMutableHostObjectruntime interface alongside read-onlyHostObject.ast.go,parser.go,scc.go,program.go): AddedAttributeAssignStatementandIndexAssignStatementnodes so mutation attempts parse cleanly and reach the type checker, without adding any surface-syntaxconstkeyword.checker.go,narrowing.go,host.go): Bothdef handle(request):anddef handle(request: Request) -> Action:(as well as annotated and unannotated helpers) infer mutability from usage across calls, return types, control flow, and nested loops. Mutating a value implies it must be mutable; passing read-onlyRequest(or nested fields/collections) to mutating operations is rejected at compile time with plain-English caret-formatted diagnostics and hints.const_test.go, updated test suites): Added unit tests coveringConstunification/subtyping, parser support, inferred mutability across annotated and unannotatedhandle/helpers, nested host fields/collections, nested-loop widening, defensive nil-field guards, plain-English diagnostics, and runtime defense in depth.Fixes #1693