mirror of
https://github.com/morluto/rea.git
synced 2026-11-05 06:45:22 +00:00
[GH-ISSUE #8166] [Design] Allow analyst assertions in Kuna decompilation with explicit provenance #4690
Open
opened 2026-10-31 00:52:31 +00:00 by bsakaguchi
·
6 comments
No Branch/Tag specified
main
codex/procedure-reference-stacked
release-please--branches--main--components--rea-agents
release-please--branches--main--components--rea-agents--release-notes
codex/kuna-independent-retry
codex/byte-search-overlay-coverage
codex/open-failure-target-receipt
codex/kuna-xref-evidence
codex/ghidra-ambiguous-procedure-recovery
codex/function-source-bundle
codex/trace-function-integration-prototype
codex/snapshot-source-closure
codex/recorded-evidence-array-pages
codex/evidence-recovery-redesign
codex/trace-feature-address-scope
codex/call-discovery-scope
codex/ghidra-literal-candidate-evidence
codex/decompile-directory-independent-retry
codex/retry-provenance-base
codex/value-flow-capability-experiment
codex/ghidra-containing-instruction
cursor/readme-discord-button-ef9f
dependabot/github_actions/actions/setup-node-7.1.0
dependabot/github_actions/actions/upload-artifact-7.0.2
dependabot/npm_and_yarn/npm-minor-and-patch-d8d97ce6df
codex/kuna-1989
fix/8559-native-ui-fixture-ownership
fix/8555-go-verifier-mcp-ownership
codex/provider-capability-recovery
fix/8642-rizin-target-stdin
codex/ghidra-memory-effect-scope
codex/ghidra-annotation-entry-selector
codex/ghidra-readonly-recovery
codex/ghidra-regex-verifier-recovery
codex/evidence-discovery-view-guidance
fix/8545-bulk-append-overflow
fix/8428-navigation-refusal-alternatives
codex/address-context-recovery
codex/matching-member-limitations
codex/unknown-scope-contract
codex/evidence-view-guidance
feat/8373-native-trace-views
codex/ghidra-snapshot-verifier-binding
codex/elf-export-visibility
codex/evidence-view-recovery
codex/native-reference-cli-help
codex/provider-candidate-observation-scope
codex/kuna-session-verification
codex/ghidra-switch-lifetime-guidance
codex/pseudocode-paging-discovery
codex/clarify-evidence-view-support
codex/kuna-xrefs-selector-recovery
codex/context-capacity-recovery
codex/evidence-closure-large-links
codex/same-function-evidence-identity
codex/ghidra-verifier-inspected-jdk
codex/audit-guided-workflows
codex/crash-prompt-retained-dossiers
codex/analysis-view-error-recovery
codex/kuna-verifier-target-selection
codex/ghidra-selected-project-call-coverage
codex/docs-native-analysis-scope
codex/ghidra-java-socket-boundary
codex/ghidra-retained-snapshot-verifier
codex/ghidra-search-inventory-facts
fix/8284-zero-argument-parameter-bindings
fix/8198-ui-action-handler-offset
fix/8257-elf-entry-label-identity
fix/8304-deferred-output-schema-projection
fix/8277-call-path-computed-target-uncertainty
fix/pr-8089-conflicts
fix/ci-static-duplicate-export
dependabot/npm_and_yarn/lint-staged-17.6.0
dependabot/github_actions/actions/download-artifact-8.0.2
dependabot/npm_and_yarn/write-file-atomic-8.0.0
dependabot/npm_and_yarn/canonicalize-5.1.0
dependabot/github_actions/actions/cache/restore-6.1.0
dependabot/npm_and_yarn/toon-format/toon-4.4.0
dependabot/github_actions/actions/deploy-pages-5.0.1
codex/review-fixes-pr-2403
codex/review-fixes-pr-2400
codex/process-terminal-width
codex/test-brittleness-cleanup
verify/7167-browser-connect-macos
fix/7167-browser-connect
feat/native-matching-allowance-setting
feat/browser-scenario-dry-run
test/managed-caller-parameters-20261024
codex/parser-fortythird-boundaries
fix/6926-pinvoke-platform-decorations-20261023
fix/6889-har-body-encoding-20261023
fix/6888-sqlite-schema-budget-20261023
fix/dependency-security-gates-6708
cursor/evidence-overwrite-rebase-b4ac
feat/4057-verify-native-exports
fix/windows-acl-observer-overhead-20261022
cursor/erlang-beam-restack-4476
cursor/pe-certificate-review-bf32
fix/6116-javascript-application-fs-errors
fix/6061-unmapped-runtime-script-unknown
feat/browser-scenario-summary
fix/pe-certificates
codex/verify-3407
cursor/rebase-5699
cursor/rebase-5352
cursor/rebase-5600
cursor/fix-cli-schema-omission-10a8
codex/audit-hopper-shutdown-reasons-20261021
fix/demangle-swift-omitted-record
fix/nib-boolean-value-types
cursor/cancellation-partial-observation-a5ac
fix/ib-object-limit-reasons
fix/electron-fuse-limit-advice
fix/kuna-doctor-dangling-cache
fix/fixed-budget-refusal-advice
fix/js-ipc-listener-dedup
fix/js-return-member-provenance
fix/dmg-integrity-retry-advice
fix/ida-doctor-readiness
fix/kuna-version-probe-output-drain
fix/legacy-swift-runtime-name-matching
fix/dylib-lazy-load-commands
fix/browser-scenario-startup-cancel
fix/swift-nested-punycode-classification
fix/compare-unselected-scopes
fix/objc-method-budget-coverage
fix/dmg-mounted-root-observations
audit/ci-tests-20261019-round2
release/6.7.0
fix/wabt-cleanup-retry-resolution
fix/electron-fuse-elf-pe-architecture
fix/native-plist-descriptor-ownership
fix/kuna-caller-cleanup-ownership
experiment/atomic-codemode-20261016
review/first-contributor-3776
fix/call-resolution-full-read-cycles
fix/member-mutation-selection-repeat
experiment/atomic-re-tools-20261015
perf/member-mutation-lazy-origins
perf/static-network-mutation-index
fix/hopper-startup-lifecycle
audit/3050-windows-proof-20261015
feat/windows-window-capture-2183
audit/3049-windows-proof-20261015
audit/3735-macos-fixtures-20261015
fix/batch-decompile-null-pseudocode
fix/kuna-inventory-honors-jobs
experiment/browser-codemode-tool-design-20261015
fix/hopper-clean-runtime-argv
codex/review-2049-27f1b367
review-fixes/pr-2787-routing
fix/3360-scoped-this-emitters
fix/3367-replaced-global-effects
fix/3838-compact-any-value-items
test/hopper-download-probe-20261015
codex/windows-runtime-creation-red-green-20261015
codex/windows-readonly-root-red-green-20261015
codex/windows-root-share-red-green-20261015
codex/exp-1685-win-mcp-startup
codex/bug-sweep-20261015
investigate/2190-windows-package-phases
investigate/3543-macos-cli-deadline
perf/3281-reverse-tools-feedback-quality
fix/3406-hopper-doctor-fixture
fix/3341-wrapper-require-test-context
fix/3301-owned-uninstall-fixtures
fix/3164-compiler-input-ownership
fix/pcap-cleanup-stdout-newline-20261014
perf/interface-builder-summary
codex/review-fixes-pr-1977
fix/ghidra-effective-jvm-platform
fix/docs-turkish-rust-link-20261013
fix/main-maintenance-ci-20261010
fix/recover-binary-session-process-effects
codex/review-fixes-pr-2457
codex/ci-required-cancellation-gate
fix/main-format-baseline-20261013
fix/setup-preserve-entry-fields
cursor/restore-main-checks-1ffc
fix/ghidra-bridge-hashmap-import
codex/shared-ci-jadx-json-default-20261013
codex/shared-ci-ghidra-test-groups-20261013
codex/shared-ci-java-fixture-format-20261013
codex/fix-intrinsic-invocation-boundaries
test/release-preflight-reusable-jobs
test/js-parameter-provenance-expectation
fix/linux-hopper-verification-current
test/2419-ghidra-elf-probe-size
followup/pr-1544-native-ida
codex/fold-pr-2230-contribution
docs/readme-responsible-use
fix/issue-2064
fix/issue-2050
fix/issue-2053
fix/issue-1968
fix/issue-1945
experiment/codemode-bridge-20261011
fix/tool-effects-negative-wording-1904-20261012
fix/1842-electron-interop-provenance
feat/recover-javascript-multi-input
refactor/website-i18n-prep
fix/nativeaot-pe-virtual-extent
fix/browser-verifier-ci-hang
fix/pe-resources-input-selection
docs/beginner-friendly-guides
docs/beginner-setup-guide
fix/javascript-analysis-worker-1563
fix/1649-ghidra-duplicate-names
fix/javascript-export-keys-integration-1369
test/maintenance-boundary-contracts-20261011
review/javascript-export-keys-1369
review/process-live-progress-1483
test/javascript-1495-growth-ratio
fix/ci-escape-timing
docs/normalized-terminal-geometry-1450
release/6.3.0
archive/release-6.3.0-pr1381
release/6.2.0
fix/electron-preload-dynamic-override
fix/javascript-self-referential-bundler-edges
release/6.1.0
cursor/grok-client-cherry-pick-0b56
feat/signature-posture
feat/dyld-shared-cache
feat/artifact-integrity-policy
feat/pkg-inventory
release/6.0.0
chore/sync-release-5.0.0
release/5.0.0
cursor/cloud-agent-node-787e
fix/javascript-xhr-open-endpoints
review/pr-711-realpath-fallback-wording
cleanup/replay-confinement
codex/test-suite-performance
codex/issue-foundations
codex/address-open-issues-2026-07-20
agent/javascript-vite-rollup-esbuild-adapters
agent/process-cleanup
agent/triage-integration
agent/unknown-commands-registry
feat/mcp-identity-metadata
morlvps/issue_cleanup
codex/installer-redesign
morl/roadmap-investigation-core
morl/roadmap-investigation-docs
release-please--branches--main--components--rea
rea-agents-6.8.0
rea-agents-6.7.0
rea-agents-6.6.0
experiment/atomic-codemode-wait-runtime-20261016
rea-agents-6.5.0
rea-agents-6.4.0
rea-agents-6.3.0
rea-agents-6.2.0
rea-agents-6.1.0
rea-agents-6.0.0
rea-agents-5.0.0
rea-agents-4.1.0
rea-agents-4.0.1
rea-agents-4.0.0
rea-agents-3.2.1
rea-agents-3.2.0
rea-agents-3.1.0
rea-agents-3.0.0
rea-agents-2.7.0
rea-agents-2.6.0
rea-agents-2.5.1
rea-agents-2.5.0
rea-agents-2.4.0
rea-agents-2.3.0
rea-agents-2.2.0
rea-agents-2.1.0
rea-agents-2.0.0
rea-agents-1.7.0
rea-agents-1.6.0
rea-agents-1.5.0
rea-agents-1.4.0
rea-agents-1.3.0
rea-agents-1.2.0
rea-agents-1.1.0
rea-agents-1.0.0
rea-agents-0.5.0
rea-agents-0.4.0
rea-agents-0.3.0
rea-0.2.1
rea-0.2.0
Labels
Clear labels
area: bridge
area: bridge
area: build
area: build
area: build
area: cli
area: domain
area: evidence
area: mcp
area: native
area: providers
area: runtime
area: server
area: setup
area: tests
bug
design
documentation
enhancement
enhancement
enhancement
experiment
help wanted
i18n
invalid
P0: critical
P1: high
P2: medium
P2: medium
P2: medium
P3: low
performance
provider-request
pull-request
Mirrored from GitHub Pull Request
question
roadmap
triage
No labels
area: bridge
area: bridge
area: build
area: build
area: build
area: cli
area: domain
area: evidence
area: mcp
area: native
area: providers
area: runtime
area: server
area: setup
area: tests
bug
design
documentation
enhancement
enhancement
enhancement
experiment
help wanted
i18n
invalid
P0: critical
P1: high
P2: medium
P2: medium
P2: medium
P3: low
performance
provider-request
pull-request
question
roadmap
triage
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set.
Reference
morluto/rea#4690
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @morluto on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/8166
Before submitting
Decision needed
Should REA offer a narrowly scoped way to supply analyst assertions to Kuna decompilation, and preserve their identity and application results in Evidence?
Context and evidence
REA's Kuna adapter at
47fa6ab3795d547207001ffb01643c0aa39dcad8invokes single-functionkuna decompile ... --addrandkuna decompile-project ... --jobswithout assertions; its provider does not support annotation or type recovery. Kuna 1.833, the version REA has verified, documents--assertfor caller-supplied function prototypes, names, types and other directives, including file input. It reports applied and rejected directives; some failures are nonfatal by default. These are per-run overrides, not a persisted editable Kuna database. See upstream 1.833 CLI documentation and REA'ssrc/kuna/KunaSessionClient.ts,src/kuna/KunaProjectExport.ts, anddocs/kuna-provider.md.The missing REA assertion input is source-derived; the real-provider observations below exercise direct Kuna assertions. No demand measurement has been performed. Upstream also supports directives affecting control flow and image bytes; treating all assertions as harmless comments would be incorrect.
Expected interaction with targets
Read selected local binaries and possibly selected assertion files; launch a caller-supplied Kuna process; apply explicit overrides to analysis state. Not sure yet which assertion categories should be admitted. No executable modification is proposed.
Boundary details (optional)
Caller assertions must remain distinct from observed facts. Bind the exact assertion content and all referenced data to target/provider/profile and cache identity; report applied, rejected and unknown outcomes. Do not silently return an unmodified cached export. Upstream's
--asserthas interactions with parallel and streaming modes and can reference external files; consider a narrower typed subset before any general pass-through.Options and tradeoffs
Compare a typed per-function prototype/name/type input, a reusable explicit assertion document, and use of the native Kuna CLI. Define which reads and workflows honor each input and whether edits should persist across session closure. Avoid conflating Kuna's C export with an editable Ghidra project.
Verification available so far
I can suggest a sample or manual check
Success criteria and open questions
Decide the capability and maintainer scope before substantial integration. On a self-owned fixture, verify a visible changed result, individual rejected and partial assertions, identity mismatch, version capability detection, cache separation, and both CLI/MCP paths. Report unverified upstream versions and effect boundaries.
References
Kuna provider:
github.com/morluto/rea@47fa6ab379/docs/kuna-provider.mdAdditional real-provider observation
On macOS arm64 with the official Kuna 1.833 release and a small self-built Mach-O, direct
kuna decompile ... --jsonproducedint _target(int a0). Adding--assert 'prototype target long target(long input)'producedlong _target(long input)and reported that directive as applied. A deliberately nonexistent local rename was separately reported rejected and nonfatal. In a real REA stdio MCP session,annotate_native_functionreturnedcapability_unavailablefor Kuna. REA pseudocode and assembly succeeded; the first pseudocode came from a single-function run and a later read from the completed export. This is a small fixture and does not verify assertion handling through REA, other directive kinds, or large-target behavior.A further direct Kuna 1.833 check used a self-built function reading a volatile global initialized to 3. The
readonlyassertion for that global was reported applied and changed the decompiled expression froma0 + global_counttoa0 + 3. Separate function-name and instruction-comment assertions were reflected in output, and an invalid local-name assertion was reported rejected without a nonzero exit. This demonstrates that assertions can change analysis interpretation, not merely display labels; it is not proof the asserted readonly assumption is true at runtime. Exact target bytes remained unchanged.A separate direct
bytesassertion replaced the first analyzed instruction with an ARM64retin the in-memory image. Kuna reported it applied and changed the pseudocode to an immediate return; the original fixture's SHA-256 remained unchanged. Such byte overlays are an analysis mutation with a distinct scope decision, not an ordinary naming annotation. No protected or packed code was involved.On the same self-built fixture, a direct call combining
typedef,prototype,type, andnameassertions changed array-likea0[1]/*a0pseudocode intorecord->flags/record->idand named the result variable; Kuna reported all four directives applied. This illustrates a concrete analyst task that changes interpretation and usability, but the asserted type layout remains caller-supplied rather than an independently established source fact.For selection UX, direct Kuna JSON on
_evaluatealso returned variable records with name, kind, type, storage size, stack offset and associated instruction addresses. REA's Kuna pseudocode currently comes from text or cached export, so investigate whether the information needed to select and verify a typed hypothesis can be exposed with stable identities and explicit uncertainty rather than relying on the spelling of a decompiler temporary. No general stability or accuracy of those upstream records is established by this fixture.Cross-provider analyst workflow to consider
The same analyst task can matter across providers even though their mechanisms differ. On a self-built arm64 Mach-O, a native Ghidra 12.1.4 headless script created a structure and applied a pointer parameter and function signature in a new project. Opening that selected project in REA then returned pseudocode using
record->flagsandrecord->id, andinspect_native_data_typereturned the structure fields. This exercises Ghidra project reuse and type inspection, not type editing through REA. A first failed name lookup and a second attempt with an incorrect pointer width illustrate the need to report failures and use target-aware layouts; the corrected eight-byte pointer produced the result. A comparable direct Kuna assertion is described above.Consider whether a common analyst-facing type/signature hypothesis can serve both engines, while preserving provider-specific capabilities, explicit caller provenance, application outcomes, target identity and effects on cached analysis. Do not assume a Ghidra project edit and a Kuna per-run assertion have the same lifecycle. Existing Ghidra project saving/reopening is separately discussed in #8165, and #6405 intentionally excludes types and prototypes. This is a design question, not an implementation or a request to expose arbitrary engine APIs; Windows P0 remains read-only and applicable scope decisions are required.
Kuna 1.989 assertion outcomes differ by invocation
On macOS arm64 with Kuna 1.989 and an unexecuted, source-built Mach-O (SHA-256
b814f3cc4226f9fe3788dedf8a14f869ca45339c5f49fc2a7709eddd2df0bd6b), I passed a prototype changing_evaluatetolong _evaluate(long analyst_input)together with a deliberately nonexistent local rename. Single-function JSON returned the changed body and separate ordered assertion rows: prototypeapplied, renamerejectedwithfatal: falseand a reason. The default run exited 0;--assert-strictexited 1 but still returned the changed body and the same two outcomes.A serial
decompile-project --jobs 1with those assertions wrote the changed C export and emitted the rejected rename on stderr, while exiting 0. The strict project run wrote the export and exited 1. A project run with--jobs 2rejected assertions before export because the worker pool cannot merge their outcomes.functions --jsonaccepted a prototype assertion, but in this control its JSON had no per-assertion outcome array; even a prototype naming a nonexistent function exited 0 without an outcome or warning. That does not establish whether another inventory directive or invocation reports more information.These observations suggest per-workflow outcomes cannot be inferred from exit status, artifact existence, or inventory alone. An REA design would need to preserve partial success and the actual producer's outcome channel, distinguish unobserved from applied, and account for concurrency before cache publication. No assertion was applied through REA, no target was executed, and the target digest was unchanged. Arbitrary analysis mutations remain a separate scope question.
@morluto commented on GitHub (Oct 30, 2026):
Additional isolated upstream Ghidra experiment on macOS arm64/Ghidra 12.1.4: a headless post-script imported the same small, self-owned Mach-O into a temporary project with
-readOnly -deleteProject, cleared one instruction from the listing, changed four bytes in the in-memory Program, and disassembled again. A fresh decompiler interface changed the entry's pseudocode fromreturn 0;toreturn 0x2a;. The script read back the modified Program bytes; the original file SHA-256 remaineda6bd938bf4ae8031a33d270ca7698ee1ced5b78347a9c4fa3750b0e57f6b126c, and the temporary project directory was empty afterward. The target was not executed.This is direct Ghidra API behavior, not an REA capability or a proposal to add arbitrary patching. In this headless experiment
-readOnlyprevented saving the project but did not make the in-memory Program immutable to a script. Together with the direct Kuna byte-overlay observation above, it illustrates that analysis-byte hypotheses alter interpretation and require distinct authority, provenance, cache and lifecycle decisions before any integration; unchanged source bytes alone do not make them equivalent to naming annotations.@morluto commented on GitHub (Oct 30, 2026):
Further direct Kuna 1.986 checks on the owned arm64 Mach-O, not integrated into REA:
--assert 'param 0 x0 unsigned int *record'plus--assert 'return w0 int'reported both directives applied and rendered the corresponding parameter name/type and return type.--assert 'data 0x100004000 int audit_counter'reported applied and rendered the global under that caller-supplied name.--assert 'flow 0x100000458 return'exited 1 and returned an assertion row withstatus: rejected,fatal: true, andDo not currently support complex overrides. Its JSON also contained C that was produced without the requested flow override, and the run-level error said the directive was refused.These checks are one fixture and do not establish general directive support or correctness. They illustrate why any analyst-hypothesis workflow must bind each directive's outcome and distinguish a fatal rejected flow change from an ordinary successful decompile, even if the provider emits text. No target bytes were changed or executed; a control-flow override remains a separate scope decision.
A mixed strict-mode run on 1.986 supplied an applicable parameter directive and a nonexistent local rename. Kuna emitted the applied parameter and rejected name as separate assertion rows, kept the applied parameter in the emitted signature, and exited 1 under
--assert-strict; its JSON run-levelerrorwas null while stderr reported the rejection. Therefore a consumer cannot determine strict-mode success solely from that JSON field; it must preserve process outcome and per-directive facts. This differs from the fatal flow-refusal example above.@morluto commented on GitHub (Oct 30, 2026):
A Ghidra type-discovery control is relevant before designing type hypotheses: in a selected read-only project, the same display name
Recordexisted in two categories.inspect_native_apiexposed a function parameter asRecord *with its user-defined/locked provenance, but not which category it pointed to. Exact type inspection succeeded for both distinct structures; an independently typed data address identified the other structure. A real headless HighFunction control identified the parameter's wire-structure pointee, while its ephemeral pointer path differed from the saved pointer path. #8219 covers this existing read-only handoff separately from whether REA should apply type assertions; it does not propose automatic matching by type name or claim original-source authority.@morluto commented on GitHub (Oct 30, 2026):
A direct Kuna 1.986 assertion-file control adds evidence about identity and export behavior. On the owned Mach-O, an
@filecontained a prototype assertion for_adjustand a deliberately invalid local-name assertion. Single-function JSON withalphain the prototype returnedalphapseudocode and separate applied/rejected directive rows; non-strict exit was 0 and strict exit was 1 while still returning the applied prototype and code. Rewriting the same file path to usebetachanged the file SHA-256 and the pseudocode tobeta. This is why the content, not just the path, must be bound to any future result/cache identity.With the
betafile, directdecompile-project --jobs 1completed with the prototype in.c/.hand the rejected directive warning on stderr.--assert-strictexited 1 but still wrote project artifacts; on this fixture I did not find the rejection in the emitted README, C or header, so process exit, diagnostics and per-directive outcomes must not be conflated with the existence of output files.--jobs 2refused the combination with exit 2 and an explicit per-load assertion-state explanation;--streamlikewise refused it with exit 2. Serial--progresssucceeded and its.c,.hand.asmhashes matched the serial non-progress export on this fixture. These are direct upstream results, not REA support for assertions, nor proof for all versions/directive combinations. The target SHA-256 was unchanged and the target was not executed.@morluto commented on GitHub (Oct 31, 2026):
Looping in @gensokyo-dev @kaoru0822-kitauji @N0zoM1z0 for visibility on the Ghidra, Kuna, and REA tool-design investigation.
@morluto commented on GitHub (Oct 31, 2026):
I extended the selected-project control to a parameter rename and a local rename applied by native Ghidra on an owned project copy. REA's selected-project pseudocode reflected both,
inspect_native_apisurfaced the parameter name and user-defined signature source, andprocedure_infodisplayed the local with its storage. Direct Ghidra inspection separately distinguished the original local'sDEFAULTsource from the renamed local'sUSER_DEFINEDsource, while REA's local projection reported database provenance for both. The source target and both selected projects stayed unchanged during the read-only REA runs.This is a read-side representation question, not authorization for local/type edits or evidence that a caller's label is correct. Filed #8314 to examine structured selection and provenance alongside this broader analyst-hypothesis discussion. Direct headless changes were made only to the disposable project copy; no target ran.