Files
rea/src/domain/nativeFunctionAnnotations.ts
T
N0zoM1z0 9bab55337a feat(ghidra): add atomic function annotation edits (#709)
* feat(ghidra): edit function annotations atomically

Return annotation readback and refreshed function analysis through CLI and MCP. Own each database transaction, invalidate caches and immutable snapshots, preserve executable bytes, and retain the Windows mutation boundary.

Assisted-by: Nitori (gensokyo-skills:nitori-reverse-engineering)

* fix(ghidra): preserve qualified function annotation identity

Preserve namespaces during local name writes and match qualified readback to the refreshed dossier. Add a producer-shaped regression and verify a real namespaced C++ function through the CLI.

Assisted-by: Nitori (gensokyo-skills:nitori-reverse-engineering)

* test(ghidra): align verification with annotation authority

Keep strict capability and profile checks while admitting the explicit session metadata operation. Verify packaged transport authority and atomic transaction commitments and preserve a read-only Windows expectation.

Assisted-by: Nitori (gensokyo-skills:nitori-reverse-engineering)
2026-10-06 17:24:33 +08:00

53 lines
1.6 KiB
TypeScript

import { z } from "zod";
import { functionDossierSchema } from "./hopperValues.js";
/** One explicit function's analyst-authored metadata changes. */
export const nativeFunctionAnnotationsInputSchema = z
.strictObject({
procedure: z.string().min(1),
name: z.string().min(1).optional(),
comment: z
.string()
.optional()
.describe("Regular entry comment; empty text clears it"),
inline_comment: z
.string()
.optional()
.describe("Inline entry comment; empty text clears it"),
})
.refine(
(value) =>
value.name !== undefined ||
value.comment !== undefined ||
value.inline_comment !== undefined,
"Supply at least one annotation change",
);
/** Readback and refreshed analysis after one atomic metadata edit. */
export const nativeFunctionAnnotationsSchema = z
.strictObject({
annotations: z.strictObject({
address: z.string().min(1),
name: z.string().min(1),
comment: z.string().nullable(),
inline_comment: z.string().nullable(),
}),
dossier: functionDossierSchema,
effects: z.strictObject({
scope: z.literal("session-analysis-database"),
source_bytes_modified: z.literal(false),
persists_after_close: z.literal(false),
}),
})
.superRefine((value, context) => {
if (
value.annotations.address !== value.dossier.procedure.address ||
value.annotations.name !== value.dossier.procedure.name
)
context.addIssue({
code: "custom",
message:
"Annotation readback disagrees with refreshed function identity",
});
});