Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
03d2eaf
feat(flutter): identify Dart snapshot builds by pure APK parsing
Oct 10, 2026
2945f50
feat(flutter): inspect Dart AOT snapshots through the ELF symbol table
Oct 10, 2026
ddf1269
fix(flutter): own snapshots, bound image reads, and preserve cancella…
Oct 10, 2026
349b212
docs(flutter): cover the Italian README with the Flutter row
Oct 10, 2026
b8cbea9
fix(flutter): make the ABI pattern portable for v-mode validators
Oct 10, 2026
e12bfbf
refactor(flutter): reuse shared harnesses and deduplicate the vertical
Oct 10, 2026
2207cc6
fix(flutter): address review findings from real-app verification
Oct 11, 2026
93db928
fix(flutter): address the Codex review findings
Oct 11, 2026
eeb56f9
fix(flutter): address the second Codex review round
Oct 11, 2026
87ac338
fix(flutter): address the third Codex review round
Oct 11, 2026
24d61ec
fix(flutter): address rounds three and four of the Codex review
Oct 11, 2026
802bb9b
fix(flutter): address the fifth Codex review round
Oct 11, 2026
9603ecb
fix(flutter): address the sixth Codex review round
Oct 11, 2026
ef79672
fix(flutter): address the seventh Codex review round
Oct 11, 2026
8d9fd5b
fix(flutter): address the eighth Codex review round
Oct 11, 2026
dbdd7fc
fix(flutter): harden streaming, sizes, and cancellation after self-re…
Oct 11, 2026
c6e7325
fix(flutter): require structurally parseable ELF headers for complete…
Oct 11, 2026
cf18c8c
fix(flutter): validate ELF and snapshot coverage
Oct 11, 2026
61394b6
fix(flutter): resolve review findings and CI effect checks
Oct 11, 2026
248ce4c
chore(flutter): resolve upstream effects-audit conflict
Oct 11, 2026
8b88190
chore: merge main into Flutter analysis branch
morluto Oct 12, 2026
34e764d
fix(flutter): unify artifact ownership and bound ELF evidence
morluto Oct 12, 2026
98707b4
chore: merge latest main into Flutter analysis branch
morluto Oct 12, 2026
9089b98
fix(flutter): preserve ELF provenance and partial coverage
morluto Oct 12, 2026
ccfaec0
chore: merge latest main after documentation updates
morluto Oct 12, 2026
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
Prev Previous commit
Next Next commit
refactor(flutter): reuse shared harnesses and deduplicate the vertical
The duplicate-detection gate (jscpd, 2.5% threshold) tipped to 2.51% with
the flutter files added. Reuse the existing machinery instead of repeating
it:

- FlutterBuildAnalysisService delegates to executeProviderOperation, the
  shared admission/Evidence composition, instead of restating its body.
- The CLI registers both commands from one table-driven spec.
- Boundary tests use the shared serveCli and assertAdvertisedMcpContracts
  harnesses rather than hand-rolled equivalents.
- The provider test consolidates the four payload-shape cases into one
  table-driven case; the service test uses one admission table and
  distinct phrasings.

Duplicate lines fall from 2.51% to 2.48%, back under the gate.
  • Loading branch information
REA Contributor me
REA Contributor authored and me committed Oct 11, 2026
commit e12bfbf5d44f73d9113dc4f038552f1cd053fe90
60 changes: 36 additions & 24 deletions src/application/flutter/FlutterBuildAnalysisService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const execution = createAnalysisExecution(
identity,
);

const refusedPort: FlutterBuildAnalysisPort = {
const refusing: FlutterBuildAnalysisPort = {
async inspectAvailability() {
throw new Error("must not probe");
},
Expand All @@ -33,50 +33,62 @@ const refusedPort: FlutterBuildAnalysisPort = {
},
};

it.each([[{ path: "/targets/app.apk", extra: true }], [{ path: 7 }], [{}]])(
"rejects invalid identification input before any effect: %j",
async (input) => {
const service = new FlutterBuildAnalysisService(refusedPort);
expect(
await service.execute("identify_flutter_build", input),
).toMatchObject({ ok: false, error: { _tag: "AnalysisInputError" } });
},
);
it.each([
[{ path: "/targets/app.apk", extra: true }],
[{ path: 7 }],
[{}],
[{ path: "/targets/app.apk", abi: "not a locale" }],
])("admits only well-formed requests before any effect: %j", async (input) => {
await expect(
new FlutterBuildAnalysisService(refusing).execute(
"identify_flutter_build",
input,
),
).resolves.toMatchObject({
ok: false,
error: { _tag: "AnalysisInputError" },
});
});

it("composes observed Evidence with the caller parameters inline", async () => {
const port: FlutterBuildAnalysisPort = {
it("passes the validated request to the provider and seals Evidence", async () => {
const seen: unknown[] = [];
const recording: FlutterBuildAnalysisPort = {
async inspectAvailability() {
return { status: "available", code: null, reason: null, diagnostics: {} };
},
async close() {},
async execute(request) {
expect(request).toEqual({
operation: "identify_flutter_build",
input: { path: "/targets/app.apk" },
});
seen.push(request);
return ok(execution);
},
};
const result = await new FlutterBuildAnalysisService(port).execute(
const result = await new FlutterBuildAnalysisService(recording).execute(
"identify_flutter_build",
{ path: "/targets/app.apk" },
);
expect(seen).toEqual([
{
operation: "identify_flutter_build",
input: { path: "/targets/app.apk" },
},
]);
if (!result.ok) throw new Error(result.error.message);
const evidence = parseEvidence(result.value);
expect(evidence.provider).toEqual(identity);
expect(evidence.operation).toBe("identify_flutter_build");
expect(evidence.confidence).toBe("observed");
});

it("preserves cancellation before execution", async () => {
it("settles an already-aborted call as cancellation before execution", async () => {
const controller = new AbortController();
controller.abort();
const result = await new FlutterBuildAnalysisService(refusedPort).execute(
const settled = await new FlutterBuildAnalysisService(refusing).execute(
"identify_flutter_build",
{ path: "/targets/app.apk" },
{ signal: controller.signal },
{
signal: controller.signal,
},
);
expect(result.ok).toBe(false);
if (result.ok) return;
expect(result.error).toBeInstanceOf(AnalysisCancelledError);
expect(settled.ok).toBe(false);
if (settled.ok) return;
expect(settled.error).toBeInstanceOf(AnalysisCancelledError);
});
37 changes: 11 additions & 26 deletions src/application/flutter/FlutterBuildAnalysisService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,28 @@ import {
flutterRequestSchema,
type FlutterOperation,
} from "../../domain/flutter/flutterBuildAnalysis.js";
import {
AnalysisCancelledError,
AnalysisInputError,
} from "../../domain/analysisErrorCore.js";
import type { AnalysisError } from "../../domain/analysisErrorBase.js";
import { createEvidence, type Evidence } from "../../domain/evidence.js";
import { jsonObjectSchema } from "../../domain/jsonValue.js";
import { err, ok, type Result } from "../../domain/result.js";
import type { Evidence } from "../../domain/evidence.js";
import { executeProviderOperation } from "../ProviderOperationExecution.js";
import type { Result } from "../../domain/result.js";

/** Shared CLI/MCP admission, execution, and Evidence composition for Flutter. */
export class FlutterBuildAnalysisService {
constructor(readonly provider: FlutterBuildAnalysisPort) {}

/** Run one caller-selected Flutter request and retain target identity inline. */
async execute(
execute(
operation: FlutterOperation,
input: unknown,
options?: ExecutionOptions,
): Promise<Result<Evidence, AnalysisError>> {
if (options?.signal?.aborted === true)
return err(new AnalysisCancelledError(operation));
const request = flutterRequestSchema.safeParse({ operation, input });
if (!request.success)
return err(new AnalysisInputError(operation, { cause: request.error }));
const executed = await this.provider.execute(request.data, options);
if (!executed.ok) return executed;
const execution = executed.value;
return ok(
createEvidence(execution.subject ?? undefined, execution.provider, {
operation,
parameters: jsonObjectSchema.parse(request.data.input),
result: execution.result,
rawResult: execution.rawResult,
limitations: execution.limitations,
locations: execution.locations,
confidence: "observed",
}),
return executeProviderOperation(
operation,
input,
options,
flutterRequestSchema,
this.provider,
"observed",
);
}
}
116 changes: 73 additions & 43 deletions src/cli/flutterCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ import type { Logger } from "pino";
import type { CliInstance } from "./types.js";
import { withCommandCancellation } from "./commandCancellation.js";

/** One flutter command: CLI shape and the request it produces. */
interface FlutterCommandSpec {
readonly command: string;
readonly description: string;
readonly argumentSchema: z.ZodObject<z.ZodRawShape>;
readonly optionSchema?: z.ZodObject<z.ZodRawShape>;
readonly operation: FlutterOperation;
readonly toInput: (
arguments_: Record<string, unknown>,
options: Record<string, unknown>,
) => unknown;
}

/** Expose the same explicit Flutter requests through one-shot CLI commands. */
export const registerFlutterCommands = (
cli: CliInstance,
Expand All @@ -20,51 +33,68 @@ export const registerFlutterCommands = (
environment,
),
): void => {
const service = new FlutterBuildAnalysisService(provider);
const execute = (name: string, operation: FlutterOperation, input: unknown) =>
withCommandCancellation((signal) =>
logCliCommand(logger, name, async () => {
const result = await service.execute(operation, input, { signal });
try {
await provider.close();
} catch (cause) {
if (cause instanceof AnalysisError)
return projectAnalysisError(cause);
throw cause;
}
return result.ok ? result.value : projectAnalysisError(result.error);
const specs: readonly FlutterCommandSpec[] = [
{
command: CLI_COMMANDS.identifyFlutterBuild,
description:
"Identify a Flutter build's Dart snapshot hash and engine facts by pure APK parsing",
argumentSchema: z.object({
path: z.string().min(1).describe("Local APK file to inspect"),
}),
);

cli.command(CLI_COMMANDS.identifyFlutterBuild, {
description:
"Identify a Flutter build's Dart snapshot hash and engine facts by pure APK parsing",
args: z.object({
path: z.string().min(1).describe("Local APK file to inspect"),
}),
run: ({ args }) =>
execute(CLI_COMMANDS.identifyFlutterBuild, "identify_flutter_build", {
path: args.path,
operation: "identify_flutter_build",
toInput: (arguments_) => arguments_,
},
{
command: CLI_COMMANDS.inspectDartAot,
description:
"Inspect one ABI's Dart AOT snapshot: sections, headers, and the string pool",
argumentSchema: z.object({
path: z
.string()
.min(1)
.describe("Local APK carrying a Flutter payload"),
}),
optionSchema: z.object({
abi: z
.string()
.min(2)
.max(16)
.optional()
.describe("ABI under lib/ to inspect; defaults to the preferred one"),
}),
});
cli.command(CLI_COMMANDS.inspectDartAot, {
description:
"Inspect one ABI's Dart AOT snapshot: sections, headers, and the string pool",
args: z.object({
path: z.string().min(1).describe("Local APK carrying a Flutter payload"),
}),
options: z.object({
abi: z
.string()
.min(2)
.max(16)
.optional()
.describe("ABI under lib/ to inspect; defaults to the preferred one"),
}),
run: ({ args, options }) =>
execute(CLI_COMMANDS.inspectDartAot, "inspect_dart_aot", {
path: args.path,
operation: "inspect_dart_aot",
toInput: (arguments_, options) => ({
path: arguments_.path,
...(options.abi === undefined ? {} : { abi: options.abi }),
}),
});
},
];
for (const spec of specs) {
cli.command(spec.command, {
description: spec.description,
...(spec.optionSchema === undefined
? { args: spec.argumentSchema }
: { args: spec.argumentSchema, options: spec.optionSchema }),
run: ({ args, options }) =>
withCommandCancellation((signal) =>
logCliCommand(logger, spec.command, async () => {
const settled = await new FlutterBuildAnalysisService(
provider,
).execute(spec.operation, spec.toInput(args, options ?? {}), {
signal,
});
try {
await provider.close();
} catch (cause) {
if (cause instanceof AnalysisError)
return projectAnalysisError(cause);
throw cause;
}
return settled.ok
? settled.value
: projectAnalysisError(settled.error);
}),
),
});
}
};
Loading