Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7e7eefe
feat(apple): inspect IPS crash reports
mvanhorn Oct 23, 2026
c3554c6
fix(apple): keep IPS register literals exact
mvanhorn Oct 23, 2026
80ad2a0
fix(apple): budget IPS parsing and keep typed presence
mvanhorn Oct 23, 2026
a81b693
fix(apple): bound integer text expansion and reconcile coverage
gensokyo-dev Oct 24, 2026
130e457
chore: integrate main and shared IPS artifact ownership
gensokyo-dev Oct 24, 2026
c608dea
refactor(apple): retain image metadata at its owning row
gensokyo-dev Oct 24, 2026
54ebac6
refactor(apple): validate row capacity through reconciled coverage
gensokyo-dev Oct 24, 2026
135cab1
test(apple): verify resource recovery at the public error boundary
gensokyo-dev Oct 24, 2026
5898e4f
docs(apple): record complete IPS task and corpus measurements
gensokyo-dev Oct 24, 2026
02bacf7
chore: integrate current main for IPS final verification
gensokyo-dev Oct 24, 2026
2b92578
docs(apple): record integrated checks and stdio corpus evidence
gensokyo-dev Oct 24, 2026
7e931e2
chore: integrate PE imports and current native lifecycle fixes
gensokyo-dev Oct 24, 2026
45a5706
docs(apple): record PE integration and baseline cleanup controls
gensokyo-dev Oct 24, 2026
ab590a6
fix(native): bound IPS string decoding and preserve invalid identities
gensokyo-dev Oct 24, 2026
6fa8083
refactor(native): use exact optional IPS source evidence
gensokyo-dev Oct 24, 2026
93e5c43
docs(native): verify IPS escape capacity and complete-task costs
gensokyo-dev Oct 24, 2026
6d77f26
chore(native): integrate current main for IPS verification
gensokyo-dev Oct 24, 2026
c838cae
test(native): verify IPS through production stdio MCP
gensokyo-dev Oct 24, 2026
f6c270d
style(tests): format IPS advertised schema bindings
gensokyo-dev Oct 24, 2026
174c749
fix(native): preserve unresolved IPS references and recorded frame se…
gensokyo-dev Oct 24, 2026
a5cdb34
docs(native): record IPS reference review evidence
gensokyo-dev Oct 24, 2026
0a3dbf2
fix(apple-ips): enforce JSON and report consistency
gensokyo-dev Oct 24, 2026
38b5a3c
Merge commit '98ec00f4068bab894639d0d1d83ac0bfc428bcbf' into maintena…
gensokyo-dev Oct 24, 2026
98e1a61
docs(apple-ips): record final consistency verification
gensokyo-dev Oct 24, 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(apple): retain image metadata at its owning row
  • Loading branch information
gensokyo-dev committed Oct 24, 2026
commit c608dea863b6f71aa77cf9b86ae63f189d50547f
5 changes: 5 additions & 0 deletions docs/apple-ips.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ documented meaning (`P` process, `S` shared cache, `C` shared cache library,
`K` kernel, `U` kernel cache, `T` kernel text exec, `A` absolute). Keys the
documentation does not list remain in `unlisted_keys` or `unlisted_body_keys`.

Each frame's `image_index` refers to its entry in `images`. Image architecture,
UUID and `uuid_unknown` are retained once on that image. Resolve the reference
when using those facts; an absent or out-of-range index leaves the image
unknown. This avoids repeating image text for every stack frame.

A present value whose JSON type differs from the documented one is never read
as absent: it is listed in `coverage.type_mismatches` with its path, the
expected type, and the observed type, and `coverage.status` becomes
Expand Down
64 changes: 64 additions & 0 deletions docs/verification/apple-ips-2026-10-24.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Apple IPS static inspection verification — 2026-10-24

## Scope

PR #6511 adds portable `inspect_apple_ips` / `inspect-apple-ips` over one
caller-selected local file. The metadata must identify string `bug_type`
`"309"`; stackshots and other report kinds remain unsupported. No target is
executed, no deep engine starts, and no atos/dSYM lookup is performed. These
checks do not qualify live macOS state, symbolication or Mach-O UUID joins.

The source contract preserves integer literals beyond IEEE-754 precision,
observed type mismatches and partial coverage. The frame address is derived
from its image's base plus its recorded offset, as described in
[Apple's crash JSON documentation](https://developer.apple.com/documentation/xcode/interpreting-the-json-format-of-a-crash-report).
That documentation does not provide a 64-bit bound for every numeric field;
the parser therefore bounds representation cost without truncating values.

## Review corrections and ownership

The contributor's `80ad2a02e9c6cbe248d58d78a7a79753bcc09f79` already projects
documented JSON members and checks thread/frame/image/register allowances
before materializing each row. Unknown members are syntax-checked without
retaining their values. Producer controls include a budget error before an
invalid next item, wrong-type collections, physical frame depth with inline
rows, and the DEAD10CC decimal near miss. Source inspection alone does not
establish the runtime checks below.

Further negative controls expose three remaining boundaries:

- Two contradictory thread/image coverage reports were accepted by the
service. Coverage now agrees with the retained arrays before Evidence is
issued. Already cancelled requests also preserve the exact caller reason.
- A 20,001-digit image base expanded into 512 derived frame addresses despite
a small input file. The field reader now owns an 8 MiB default / 64 MiB
maximum UTF-16 allowance for recorded decimal/hex fields. Conservative
reservations precede conversion and arithmetic. Source BigInts are reused;
derived sums are not retained in a cache. Repeated appearances count
separately, including a service control using the same object twice.
- A 20,013-character image architecture appeared 513 times in a 512-frame
report. Frames now retain their recorded `image_index`; architecture, UUID
and `uuid_unknown` belong to the image once. The old per-frame copies and
superseded field-access helpers are removed.

Each defect has a failing control before its correction. Raising the integer
allowance to 64 MiB preserves the 512-frame decimal facts exactly. The
allowance is per call, requires no restart, and is separate from file-size,
row, wire and client-buffer limits. Refusal is a typed capacity error without
partial success. A refused task is not treated as a completed-task speedup.

## Public corpus provenance

Two pinned upstream reports are valid two-object JSON and are used without
editing their bytes. Their original generation history has not been verified;
these are public repository corpus files, not a claim of fresh OS capture.

| Report | Repository revision | Bytes | SHA-256 |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------ | -----: | ------------------------------------------------------------------ |
| [LLDB multithread-test.ips](https://github.com/llvm/llvm-project/blob/16dde0db3ce0b9c5eae14178780cc6db1eec7ac8/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.ips) | `16dde0db3ce0b9c5eae14178780cc6db1eec7ac8` | 16,093 | `567cadb22af19be798390ab2021ed929fb782c69b2d3b18ff5bb3f39a3741d8c` |
| [pycrashreport Monterey report](https://github.com/doronz88/pycrashreport/blob/634dff127fa6d4d3df948a64a3e254fe208a99dc/tests/user_mode_crash_report_monterey_non_symbolicated.ips) | `634dff127fa6d4d3df948a64a3e254fe208a99dc` | 7,047 | `7de3d3c3515e2ac1bb6ed4c00b70cb12c1ff6ad4317617d258d58346e00264b7` |

Three other LLDB inputs (`a.out.ips`, `a.out.inline.ips`, `no_threadState.ips`)
contain invalid JSON at their pinned revision. They were not repaired or
counted as successful report qualifications. Files remain temporary local
verification inputs and are not committed to this repository.
8 changes: 5 additions & 3 deletions src/domain/native/appleIps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ const registerSchema = z.strictObject({
const frameSchema = z.strictObject({
thread_index: uint,
frame_index: uint,
image_index: uint.nullable(),
image_uuid: uuidSchema.nullable(),
arch: z.string().min(1).nullable(),
image_index: uint
.nullable()
.describe(
"Recorded index into images; image metadata and its uncertainty belong to that row.",
),
image_offset: recordedIntegerSchema.nullable(),
runtime_address: recordedIntegerSchema.nullable(),
role: z.enum([
Expand Down
6 changes: 2 additions & 4 deletions src/native/apple/AppleIpsJsonShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
AppleIpsFormatFailure,
AppleIpsResourceFailure,
type AppleIpsFixedBoundary,
type AppleIpsSelectedBoundary,
} from "./AppleIps.errors.js";
import {
parseLosslessJson,
Expand Down Expand Up @@ -43,12 +42,11 @@ const unlistedKeys = fixedAllowance(
"unlisted keys in one object",
);

/** One running count per caller-selected budget, checked before each row. */
/** One running count per selected row collection, checked before each row. */
const selectedAllowances = (input: InspectAppleIpsInput) => {
const counts = { threads: 0, frames: 0, images: 0, registers: 0 };
const take =
(boundary: AppleIpsSelectedBoundary, maximum: number, noun: string) =>
() => {
(boundary: keyof typeof counts, maximum: number, noun: string) => () => {
counts[boundary] += 1;
if (counts[boundary] > maximum)
throw new AppleIpsResourceFailure(
Expand Down
19 changes: 19 additions & 0 deletions src/native/apple/AppleIpsParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ const integerAmplificationBytes = (): Buffer => {
);
};

it("retains image metadata once while frames refer to its owner", () => {
const arch = "unknown_arch_" + "x".repeat(20000);
const uuid = "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA";
const frames = Array.from(
{ length: 512 },
() => '{"imageIndex":0,"imageOffset":1}',
).join(",");
const bytes = Buffer.from(
`${appleIpsMetadataLine()}\n{"faultingThread":0,"threads":[{"frames":[${frames}]}],"usedImages":[{"base":4294967296,"size":4096,"arch":${JSON.stringify(arch)},"uuid":${JSON.stringify(uuid)}}]}`,
);
const report = parseAppleIps(bytes, artifact(bytes), input);
expect(report.images[0]).toMatchObject({ arch, uuid });
expect(report.threads[0]?.frames).toHaveLength(512);
expect(report.threads[0]?.frames[0]?.image_index).toBe(0);
const serialized = JSON.stringify(report);
expect(serialized.split(arch)).toHaveLength(2);
expect(serialized.split(uuid)).toHaveLength(2);
});

it("refuses integer text amplification before retaining every derived address", () => {
const bytes = integerAmplificationBytes();
expect(bytes.length).toBeLessThan(input.max_file_bytes);
Expand Down
2 changes: 0 additions & 2 deletions src/native/apple/AppleIpsParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ const threadsOf = (
thread_index: threadIndex,
frame_index: frameIndex,
image_index: imageIndex,
image_uuid: image?.uuid ?? null,
arch: image?.arch ?? null,
image_offset: imageOffset,
runtime_address: read.add(image?.base ?? null, imageOffset),
Comment thread
gensokyo-dev marked this conversation as resolved.
Resolved
role,
Expand Down
19 changes: 0 additions & 19 deletions src/native/apple/losslessJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,6 @@ export const parseLosslessJson = (
return { value, end: parser.position };
};

export const asString = (value: LosslessJson | undefined): string | null =>
value?.kind === "string" ? value.value : null;

export const asBoolean = (value: LosslessJson | undefined): boolean | null =>
value?.kind === "boolean" ? value.value : null;

export const asInteger = (value: LosslessJson | undefined): string | null =>
value?.kind === "integer" ? value.decimal : null;

export const asObject = (
value: LosslessJson | undefined,
): Readonly<Record<string, LosslessJson>> | null =>
value?.kind === "object" ? value.members : null;

export const asArray = (
value: LosslessJson | undefined,
): readonly LosslessJson[] | null =>
value?.kind === "array" ? value.items : null;

class Parser {
position: number;

Expand Down
19 changes: 19 additions & 0 deletions tests/acceptance/appleIpsCli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ cliTest(
const root = await createTestTempDirectory("rea-apple-ips-cli-");
const path = join(root, "report.ips");
await writeFile(path, appleIpsBytes());
const constrained = await cli.run({
arguments: [
"inspect-apple-ips",
path,
"--max-integer-text-bytes",
"1",
"--json",
],
});
expect(constrained.exitCode, constrained.stderr).toBe(1);
expect(constrained.json).toMatchObject({
code: "resource_constraint",
details: {
reported_limits: { boundary: "integer_text", maximum: 1 },
remediation: {
action: expect.stringContaining("max_integer_text_bytes"),
},
},
});
const result = await cli.run({
arguments: ["inspect-apple-ips", path, "--json"],
});
Expand Down
33 changes: 30 additions & 3 deletions tests/boundary/mcp/appleIpsMcp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { toolContract } from "../../../src/contracts/toolContracts.js";
import { createServer } from "../../../src/server/createServer.js";
import { createTestBinarySession } from "../../fixtures/binarySession.js";
import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
import { advertisedMcpToolSchemas } from "../../fixtures/advertisedMcpTool.js";
import { appleIpsBytes } from "../../fixtures/binaryDiagnostics/appleIps.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { mcpTest, type TestMcp } from "../../support/mcp/mcpFixture.js";
Expand All @@ -22,21 +23,47 @@ mcpTest(
async ({ mcp }) => {
const { client, session } = await connect(mcp);
try {
const advertised = (await client.listTools()).tools.find(
(tool) => tool.name === "inspect_apple_ips",
);
const {
toolDefinition: advertised,
ajv,
inputSchema,
outputSchema,
} = await advertisedMcpToolSchemas(client, "inspect_apple_ips");
expect(advertised?.annotations).toMatchObject({
readOnlyHint: false,
idempotentHint: true,
});
const root = await createTestTempDirectory("rea-apple-ips-mcp-");
const path = join(root, "report.ips");
await writeFile(path, appleIpsBytes());
expect(
ajv.validate(inputSchema, { path, max_integer_text_bytes: 1 }),
).toBe(true);
const constrained = await client.callTool({
name: "inspect_apple_ips",
arguments: { path, max_integer_text_bytes: 1 },
});
expect(constrained.isError).toBe(true);
expect(parseMcpToolError(constrained).error).toMatchObject({
code: "resource_constraint",
details: {
reported_limits: { boundary: "integer_text", maximum: 1 },
remediation: {
action: expect.stringContaining(
"Raise max_integer_text_bytes on the next call",
),
},
},
});
const response = await client.callTool({
name: "inspect_apple_ips",
arguments: { path },
});
expect(response.isError, JSON.stringify(response.content)).not.toBe(true);
expect(
ajv.validate(outputSchema, response.structuredContent),
JSON.stringify(ajv.errors),
).toBe(true);
const evidence = toolContract("inspect_apple_ips").outputSchema.parse(
response.structuredContent,
);
Expand Down