feat(extract): make cgo visible — //export contracts, C. veto, preamble coverage - #1947
feat(extract): make cgo visible — //export contracts, C. veto, preamble coverage#1947ilyabrykau-orca wants to merge 1 commit into
Conversation
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
…le coverage A cgo file is one file in two languages; cbm reads it with the Go grammar only. Three bounded pieces of DeusData#1929 (the design-sized fourth - parsing the preamble with the C grammar - stays open for maintainers): 1. //export linkage. The directive declares the func's C ABI symbol (cgo requires the name to match), yet C-side callers bound it by short-name luck - unique_name at 0.38-0.75, or died in a weak-match guard on a name collision. The Go extractor now records the directive (CBMDefinition.is_cgo_export, node property cgo_export:true), and both CALLS resolvers upgrade an exact-name C/C++ caller to strategy export_linkage at contract confidence. 22 luck-based edges on the measured repo become declared contracts. 2. C. pseudo-namespace veto. 'C' is reserved by go/build - no project symbol can be behind C.<ident>, so any binding is fabricated (the standing DeusData#1906-shaped hijack surface). New pure predicate cbm_go_suppress_cgo_callee vetoes such callees in both resolvers before any strategy can bind them. 3. Preamble coverage honesty. A cgo file parses CLEAN - the preamble is a comment to the Go grammar - so parse coverage claimed full indexing while every preamble definition (12 C functions in one measured file) was missing. The comment run directly above import "C" is now flagged as an unparsed region (parse_incomplete + error_ranges), the same best-effort detection signal as DeusData#963. Reproduce-first (RED with the wiring stashed, GREEN restored): extract_go_cgo_export_flag (exact-name gate, mismatch and plain negatives, preamble range 3-5 flagged, cgo-without-preamble and plain Go stay clean), pipeline_go_cgo_export_binds_by_contract (edge carries export_linkage, was unique_name), pipeline_go_cgo_callee_never_binds_ project_symbol (C.helper + project decoy -> zero edges), and go_cgo_callee_veto predicate units. 784 tests green across extraction/ pipeline/registry/lsp probes/go_lsp. Part of DeusData#1929 Signed-off-by: Ilya Brykau <ilya.brykau@orca.security>
|
CI retrigger (no-op amend): |
5dbcd53 to
4a34a1d
Compare
Part of #1929 — draft implementation-proposal: implements the three bounded pieces sketched in the issue body; the design-sized fourth (parsing the C preamble with a second grammar) deliberately stays open for maintainer design. Will mark ready on ack.
1.
//exportlinkage — a declared contract, not short-name luckcgo requires the exported name to equal the func name, yet C-side callers bound Go
//exportfunctions viaunique_nameat 0.38–0.75 — right by accident, and one name collision away from moving silently or dying in a weak-match guard. Now: the Go extractor records the directive (CBMDefinition.is_cgo_export, node property"cgo_export":true), and both CALLS resolvers upgrade an exact-name C/C++ caller toexport_linkage@ 0.95. 22 luck-based edges on the measured repo become declared contracts.2.
C.pseudo-namespace veto"C"is reserved bygo/build— no project symbol can be behindC.<ident>, so any binding the general resolver produces is fabricated (a standing #1906-shaped hijack surface; pairs with #1931'simport "C"drop). New pure predicatecbm_go_suppress_cgo_calleevetoes such callees in both resolvers before any strategy can bind them.3. Preamble coverage honesty
A cgo file parses CLEAN — the preamble is a comment to the Go grammar — so
parse_partialclaimed full indexing while every preamble definition (12 C functions in one measured file) was missing. The comment run directly aboveimport "C"is now flagged as an unparsed region (parse_incomplete+error_ranges), the same best-effort detection signal as #963. This intentionally makes every cgo file report a partial-parse range — that is the point; if maintainers prefer a distinct marker key for "foreign-language region" vs "parse error", happy to split it.Tests (reproduce-first — RED with the wiring stashed, GREEN restored)
extract_go_cgo_export_flag: exact-name gate (mismatched directive and plain funcs stay false), preamble range3-5flagged, cgo-without-preamble and plain Go stay clean.pipeline_go_cgo_export_binds_by_contract: RED — edge exists asunique_name; GREEN — carriesexport_linkage.pipeline_go_cgo_callee_never_binds_project_symbol:C.helper()+ a projecthelperdecoy → zero edges (RED bound the decoy).go_cgo_callee_vetopredicate units. 784 green across extraction/pipeline/registry/lsp probes/go_lsp; fullscripts/test.shvenue leg green; clang-format clean.Field census
Pending (live-daemon rendezvous conflict blocks isolated-HOME one-shots on this machine); expected per the issue: 22
//exportinbound edges move fromunique_name@0.38–0.75 toexport_linkage,C.*CALLS stay 0, 27 cgo files gain a flagged preamble range. Will follow up as a PR comment.#1932 tracks the family.