Skip to content
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .claude/skills/starry-syscall-harness/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
name: starry-syscall-harness
description: Audit and fix StarryOS syscall Linux-compatibility and qperf performance issues using the project harness. Use when comparing StarryOS syscall behavior with Linux, profiling StarryOS with qperf, running or extending tools/starry-syscall-harness, invoking its MCP tools, or validating syscall/performance fixes before opening a PR.
---

# Starry Syscall Harness

Use this skill for StarryOS syscall semantic audits, qperf hotspot analysis, and fixes.

## Core Rules

- Run all StarryOS build, rootfs, QEMU, syscall probe, and qperf profile execution through Docker.
- Use the configured image by default: `ghcr.io/rcore-os/tgoskits-container:latest`.
- Prefer the harness entrypoint over hand-built commands:
`python3 tools/starry-syscall-harness/harness.py discover --arch riscv64`
- Prefer the qperf harness entrypoint for performance work:
`python3 tools/starry-syscall-harness/harness.py perf-profile --arch riscv64 --timeout 20`
- Treat host Linux probe output as the reference unless a case is explicitly documented as architecture-specific.
- Treat qperf top functions, folded stacks, and generated fix candidates as triage inputs; confirm suspected bottlenecks in code before patching.
- Keep fixes in the relevant syscall implementation; do not weaken probes to hide mismatches.
- After changing StarryOS logic, run `cargo fmt` and targeted clippy in Docker:
`docker run --rm -v "$PWD":/work -w /work ghcr.io/rcore-os/tgoskits-container:latest bash -lc 'cargo xtask clippy --package starry-kernel'`

## Workflow

1. Run `python3 tools/starry-syscall-harness/harness.py doctor` to verify Docker and required tools.
2. Run `python3 tools/starry-syscall-harness/harness.py discover --arch riscv64`.
3. Read the JSON report under `target/starry-syscall-harness/<arch>/latest/report.json`.
4. Fix only mismatches with clear Linux semantics.
5. Rerun the harness for the affected arch, then run Docker clippy for changed crates.
6. Before PR work, fetch upstream and create a clean branch from the target upstream branch.

## Performance Workflow

1. Run `python3 tools/starry-syscall-harness/harness.py perf-profile --arch riscv64 --timeout 20`.
2. Read `target/starry-syscall-harness/perf/<arch>/latest/report.json` and `report.md`.
3. Inspect `hotspots.top_functions`, `fix_candidates`, and `qperf/stack.folded`.
4. If comparing optimization attempts, run `perf-diff --baseline <old-dir> --compare <new-dir>`.
5. Use the default release profile for performance comparisons; pass `--debug` only when symbol detail is more important than optimized runtime behavior.
6. Keep the default broad qperf sampling unless the report is dominated by non-kernel addresses; use `--kernel-filter` only after confirming the detected `.text` range matches QEMU callback addresses.
7. Fix only bottlenecks supported by samples and code inspection.
8. Rerun `perf-profile`, then run Docker clippy for changed crates.

## MCP

The MCP server is `tools/starry-syscall-harness/mcp_server.py`.

Register it locally with:

```bash
codex mcp add starry-syscall-harness -- python3 /path/to/tgoskits/tools/starry-syscall-harness/mcp_server.py --repo /path/to/tgoskits
```

Available tools:

- `starry_syscall_doctor`: checks Docker, image, and required toolchain availability.
- `starry_syscall_discover`: runs Linux-vs-StarryOS syscall probes and returns the report.
- `starry_perf_profile`: runs qperf in Docker, emits JSON/Markdown/CSV hotspot reports, and lists fix candidates.
- `starry_perf_diff`: compares two qperf folded-stack outputs or profile directories.

## Probe Changes

When adding a probe:

- Put deterministic C cases in `tools/starry-syscall-harness/probes/syscall_probe.c`.
- Print one `CASE <name> key=value ...` line per syscall behavior.
- Avoid fd numbers, timestamps, paths, pointer values, and scheduler-sensitive output in comparisons.
- Prefer small syscall-focused probes that can run under BusyBox init without extra packages.
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- Use `board-uboot-fsck-repair` when a physical board Linux rootfs needs ext4 recovery through U-Boot, initramfs fsck reports unrepaired corruption, OrangePi-5-Plus needs `extraboardargs=fsckfix`, or Starry board write tests must be bracketed by Linux fsck/boot checks.
- `crates-io-owner`: project-local skill at `.claude/skills/crates-io-owner/SKILL.md`
- Use `crates-io-owner` when the user wants to add or verify `github:rcore-os:crates-io` for branch-added crates, asks which new crates still need the crates.io team owner, or explicitly wants `cargo owner` used instead of `Cargo.toml` metadata.
- `starry-syscall-harness`: project-local skill at `.claude/skills/starry-syscall-harness/SKILL.md`
- Use `starry-syscall-harness` when auditing StarryOS syscall Linux-compatibility semantics, running syscall differential tests, running qperf-based StarryOS performance profiling, using its MCP tools, or preparing fixes from harness output.

## Other Requirements

Expand Down
45 changes: 45 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added ai-harness-ppt/ai-harness-defense.pptx
Binary file not shown.
Binary file added ai-harness-ppt/assets/ai-harness-cover-16x9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ai-harness-ppt/assets/ai-harness-cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ai-harness-ppt/assets/flamegraph-panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ai-harness-ppt/assets/flamegraph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading