Files
rea/src/domain/native/nativeFunctionAnnotations.ts
T
morlutoandCursor Agent 4bb53000a3 fix(ghidra): clarify function annotation selectors (#8584)
* fix(ghidra): clarify function annotation selectors

* test(ghidra): compare catalog guidance with its contract

---------

Co-authored-by: Cursor Agent <[email protected]>
2026-11-08 01:10:17 +08:00

58 lines
1.7 KiB
TypeScript

import { z } from "zod";
import { functionDossierSchema } from "../native/functionDossier.js";
/** One explicit function's analyst-authored metadata changes. */
export const nativeFunctionAnnotationsInputSchema = z
.strictObject({
procedure: z
.string()
.min(1)
.describe(
"Function name or address selecting a function; edits apply at its entry.",
),
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",
});
});