skills/ohos-dev-distributed-cpp-callgraph-analysis/SKILL.md
Use when an OpenHarmony C++ change must be checked for call-chain completeness, especially for data propagation, IPC/proxy/stub paths, virtual overrides, callbacks, or dlopen/dlsym boundaries. Produces evidence tables and modification coverage matrices; the helper script only discovers candidate edges.
npx skillsauth add openharmonyinsight/openharmony-skills ohos-dev-distributed-cpp-callgraph-analysisInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill has one decision layer plus optional tool support:
ohos_callgraph.py discovers candidate direct call edges and best-effort vtable/dlopen hints from build artifacts when LSP/source evidence leaves gaps or LSP is unavailable.Do not claim a call chain is complete from script output alone.
Before analysis, check whether a working LSP/MCP tool is already backed by the correct OpenHarmony product compile context. Use it when available.
If LSP is missing or resolves the repository incorrectly, read
references/lsp-bootstrap.md and follow it before analysis. The
bootstrap is optional support, not a prerequisite: if setup or smoke testing fails, record LSP as
unavailable/incomplete and continue with source, build, symbol, helper, and runtime evidence.
If clangd is extremely slow on a specific file (minutes of 100% CPU), the file is likely missing from
the filtered compile_commands.json. For Claude clients, pass --install-hook during setup to
install a Claude PreToolUse auto-fix hook. For Codex or other clients, use the manual fix in the
"File Not in compile_commands.json" section in
references/lsp-bootstrap.md.
Before using tools, state:
OnRemoteRequest, HandleEvent, or a subsystem-specific entry function.If any of these are unknown, inspect code first and make a bounded assumption. Do not skip this step.
Use evidence sources in this order:
rg to find framework patterns that LSP does not model well, such as transaction codes, listener registration, LoadLibrary<>, dlsym, and generated-file names.llvm-nm, llvm-readelf, llvm-objdump, and llvm-cxxfilt for libraries, exports, link edges, and generated artifacts.ohos_callgraph.py to discover IR-level candidate direct edges and best-effort vtable/dlopen hints when LSP/source/build evidence still has unexplained edges, when artifact-level confirmation is useful, or when LSP is unavailable/incomplete.LSP is the first choice for language-level C++ facts, but it is not enough for runtime binding or OpenHarmony framework protocols.
When LSP/clangd is available, use it as the primary path for:
definition / declarationreferencescall hierarchy incoming/outgoing callsDo not run the helper script just to duplicate LSP direct-call results. Run it only when it can answer a different question, such as "does this compiled artifact contain a candidate edge?" or "what candidates exist when LSP cannot resolve this path?".
When LSP is unavailable or incomplete, say so in the evidence table and fall back to source search plus build/symbol evidence.
Resource check: before running the helper, estimate the bitcode file count with find <obj_dir> -name '*.o' | grep <repo-filter> | wc -l. If the count exceeds ~200 files, narrow the --repo filter or use LSP/source evidence instead. Each file requires two LLVM tool invocations (~1-2s each), so 200 files can take 5-10 minutes.
Required helper invocation shape. The agent must resolve the source tree and repository filter before calling the script, then pass them explicitly:
SCRIPT=/path/to/skills/ohos-dev-distributed-cpp-callgraph-analysis/ohos_callgraph.py
python3 "$SCRIPT" <entry-function> \
--oh-root <openharmony-source-root> \
--product <product-name> \
--repo <repo-filter> \
--depth 4 \
--skip-prefix "Subsystem::LogHelper" --skip-prefix "Subsystem::TimeUtil"
Omit --skip-prefix to use the built-in defaults (HiLog, std::__h::, etc.). Pass one or more --skip-prefix to override them entirely with subsystem-specific prefixes.
Reverse direct callers:
python3 "$SCRIPT" <target-function> \
--oh-root <openharmony-source-root> \
--product <product-name> \
--repo <repo-filter> \
--reverse \
--depth 3
The helper script output is a candidate list. Every important edge still needs source evidence. In reverse mode, the helper script only reverses direct call edges. It does not reverse vtable or dlopen/dlsym hint edges.
Each call-chain edge must be classified:
| Type | Evidence Required |
|------|-------------------|
| direct | Prefer LSP call hierarchy/references; include caller line and callee definition or declaration |
| virtual | Prefer LSP override candidates; include interface call site, candidate overrides, and dispatch reason if known |
| callback | Registration site and invocation site; LSP can locate symbols but usually cannot prove registration-to-invocation flow |
| ipc | Proxy write, stub read, transaction code, and service handler |
| dlopen/dlsym | Load site, library/symbol name, factory or function pointer use; confirm with symbols or trace when needed |
| macro/generated | Prefer LSP macro-aware locations; include generated source or expanded target that proves the edge |
| unknown | Evidence gap; cannot support a completeness claim |
For virtual, callback, IPC, and dlopen/dlsym edges, list all relevant candidates or explicitly justify why only one candidate applies.
Output a table with these columns:
| Caller | Callee / Candidate | Edge Type | Evidence Source | Evidence | Confidence | Needs Change | Change Status | |--------|--------------------|-----------|-----------------|----------|------------|--------------|---------------|
Rules:
Evidence Source is one or more of lsp, source, build, symbol, script, runtime, or manual.Evidence must include file paths and line numbers.Confidence is confirmed, candidate, or unknown.Needs Change explains why the target data or behavior must pass through this edge.Change Status is done, missing, not needed, or unknown.script evidence alone cannot make a non-direct edge confirmed.Do not collapse multiple edge types into one row.
For data propagation changes (e.g. a field that must be carried through multiple layers), check each applicable surface:
| Surface | What to Check | Static Evidence | Runtime Evidence | Status | |---------|---------------|-----------------|------------------|--------| | Function signature | Parameter or object carries the target data | LSP definition/declaration or source line | Optional | | | Call arguments | Caller passes the correct value, not a default or stale value | LSP call hierarchy/references or source line | Optional | | | Event/object fields | Field is set, copied, cloned, and reset correctly | Source/LSP field references | Optional | | | IPC proxy/stub | Parcel write/read order and transaction compatibility | Source transaction and Parcel evidence | Trace/log if ambiguous | | | Service dispatch | Server side receives and uses the value | Source/LSP handler path | Trace/log if ambiguous | | | Virtual overrides | All reachable overrides accept or derive the value | LSP override candidates and source evidence | Required if static dispatch is not unique | | | Callback flow | Registration and invocation both preserve the value | Source registration/invocation evidence | Required if registration-to-call flow is ambiguous | | | dlopen/dlsym implementation | Loaded implementation handles the value | Source + symbol/build evidence | Required if loaded target is runtime-dependent | | | Generated code | Generated wrappers and ABI layers preserve the value | Generated source or build artifact evidence | Optional | | | Tests | Unit/system tests exercise at least one representative path and boundary | Test source evidence | Test execution result when available | |
The final answer must say which rows are complete, missing, or unknown.
Use these labels:
done or not needed, and unknowns are either resolved or explicitly out of scope.missing.unknown, or static-only evidence cannot resolve a runtime-bound edge that affects the conclusion.ohos_callgraph.py is an optional artifact fallback after LSP/source inspection:
opt --print-callgraphLoadLibrary<> / CreateInstance patternsLimitations:
std::function targets.--name-keyword only checks demangled function names and direct child function names as a rough hint; it does not inspect C++ parameter names, call arguments, member access, local variables, or IPC serialization.Use the helper script only as a candidate discovery aid for the evidence workflow. Skip it when LSP/source evidence already covers the relevant direct calls and no artifact-level confirmation is needed.
Use LSP/clangd as evidence when it is backed by the correct compile context for the OpenHarmony product under review. If the repository lacks compile_commands.json or clangd cannot resolve includes/macros, mark LSP evidence as incomplete and rely on source/build evidence instead.
When LSP is unavailable and the environment permits setup, follow Bootstrap Repository-Scoped LSP before falling back. Do not use a product-wide compilation database directly when a repository-scoped database can be generated; the product database can be several gigabytes and causes unnecessary indexing cost.
Recommended LSP-backed checks:
candidate unless construction/registration/source rules or runtime trace proves the actual target.Do not use LSP alone to confirm callback flow, IPC dispatch, or dlopen/dlsym targets.
When using this skill, end with:
Complete, Incomplete, or Not provable, with the exact missing or unknown items.If you cannot inspect a required boundary, say so and mark it unknown.
When analyzing the multimodal input (MMI) subsystem, common analysis targets include:
HandleMouseEvent, UpdateMouseTarget, OnRemoteRequestgroupId, displayId, pointer target routing, device bindingOHOS::MMI::FormatLog, OHOS::MMI::GetSysClockTime, OHOS::MMI::InnerFunction (pass via --skip-prefix)MultimodalInputConnectStub, EventDispatchHandler callback chains, InputDeviceManager dlopen loadingtesting
--- name: ohos-req-value-decision description: Use after review meeting to record decision and route to next step. Triggers: 评审决策纪要, 评审结论回流, value decision, 评审接纳, 评审不接纳, 评审退回, 下次重新上会. Do NOT use for feature baseline (ohos-req-feature-baseline), review gate checks (ohos-req-review-gate), or IR generation (ohos-req-feature-to-ir). metadata: author: openharmony scope: common stage: requirements capability: value-decision version: 0.3.0 status: draft tags: - sdd - requirements
development
Use when converting an OpenHarmony requirement document, spec, or design proposal into an OpenHarmony review slide deck (需求评审 / 需求变更评审 / 设计评审 PPTX) — produces the fixed OpenHarmony-branded review-deck structure (OH logo on every page) with architecture/flow diagrams and field tables. Triggers on "需求评审PPT", "需求变更评审", "把需求文档转成评审PPT", "spec转评审PPT", "requirement/spec to review deck". NOT for arbitrary or generic slide decks unrelated to OpenHarmony requirement/design review.
testing
Use when performing the Phase 0 Step 0.5 Review Ready Gate on a 04-feature.md, especially when the user says "evaluate gate", "review readiness", "feature ready?", "should we generate IR", or when the ohos-req-intake-orchestration main session needs a structured Ready / Conditional Ready / Not Ready judgment instead of doing the check inline. Reads 01-04, runs seven fixed checks plus a conditional-items check, and returns a machine-readable JSON summary plus a human-readable table that the main session can route on. Do NOT use for feature baseline generation (ohos-req-feature-baseline), value decision recording (ohos-req-value-decision), or IR generation (ohos-req-feature-to-ir).
testing
--- name: ohos-req-requirement-intake description: Use when importing an OHOS requirement into Phase 0.1, especially for 01-requirement.md, requirement intake, background, user value, scenarios, scope, FR/NFR, affected modules, or priority. Triggers: 需求导入, 01-requirement, 需求基线, RR单号. Do NOT use for feasibility analysis (ohos-req-feasibility-analysis), architecture decision (ohos-req-arch-decision), or feature baseline (ohos-req-feature-baseline). metadata: author: openharmony scope: common