This file provides persistent context for AI coding agents (Antigravity, Jules, OpenHands,
Claude Code) working in the catnet-io/engine repository.
catnet-io/engine is the shared Go scanning engine for the CatNet ecosystem.
It is a pure Go library — no binary, no main package, no UI code.
All network scanning logic lives exclusively here.
Consumer repositories (catnet-io/catnet, catnet-io/app, catnet-io/tui) are
pure frontends that import this module via go.mod.
Module path: github.com/catnet-io/engine
Go version: 1.26.4
Current stable tag: v0.7.0
| Package | Responsibility | Stability |
|---|---|---|
pkg/engine |
Callback-based scan API (StartScan, EventCallback, ScanConfig) |
Stable |
pkg/scan |
Channel-based scan API (Engine, ScanStream, Stop) — canonical for GUI/TUI consumers |
Stable |
pkg/events |
Event types for the channel API (Event, EventType, HostDiscoveredData, ProgressData) |
Stable |
pkg/profile |
Scan configuration for channel API (ScanProfile, DefaultProfile, Sanitize) |
Stable |
pkg/results |
Domain types (ScanReport, DeviceInfo, HostResult) |
Stable |
pkg/discovery |
ICMP ping, ARP MAC lookup, reverse DNS | Stable |
pkg/ports |
TCP port scanner, returns <-chan int |
Stable |
pkg/fingerprint |
OS/device fingerprinting via TTL, banner, OUI | Stable |
pkg/targets |
IP range parsing (CIDR, dash range) | Stable |
pkg/topology |
Network graph builder, gateway identification | Stable |
pkg/export |
JSON/CSV export for []results.HostResult |
Stable |
pkg/exporter |
JSON/CSV/XML export for *results.ScanReport |
Stable |
pkg/oui |
Offline IEEE OUI database lookup (Lookup, LookupWithPrefix) |
Stable |
pkg/coreerr |
Typed error taxonomy (ErrTimeout, ErrCancelled) |
Stable |
internal/netutil |
Internal network utilities — not part of public API | Internal |
There are currently two scan APIs in this repository. This is known architectural drift being resolved in Milestone 5:
-
pkg/engine.StartScan— synchronous callback API. Used bycatnet-io/catnet(CLI). EachEventCallbackis called synchronously by the scan worker goroutine. Milestone 5 will add an internal async dispatcher to decouple callback latency from worker throughput. -
pkg/scan.Engine.ScanStream— asynchronous channel API. Used bycatnet-io/app(GUI).ScanStreamdelegates topkg/engineinternally and translates events to the channel. This is the preferred API for new consumers.
Do not merge or remove either API without explicit instruction. Do not add a third scan API.
- Zero CGO. No CGO in any file in this repository. Pure Go only.
- Zero UI code. No Wails bindings, no Bubble Tea imports, no terminal output.
This is a library — it has no
mainpackage. - No scanning logic in consumers. If you find yourself adding discovery, port scanning, or fingerprinting logic outside this repository, stop and add it here instead.
- English only everywhere. All code, comments, godoc, log messages, error strings, PR descriptions, PR review comments, commit messages, and documentation across the entire repository must be in English. Portuguese and non-English text are strictly forbidden.
- No local
replacedirectives committed tomain. Usescripts/dev-replace.sh on/offto toggle during local development. pkg/storeandpkg/diffwere removed in v0.5.1. Do not re-add database persistence or diffing logic to this repository (moved to consumers).- Immutable GitHub Action Pinning. All GitHub Actions in workflow files must be pinned to full 40-character commit SHAs. Never use unpinned tags (e.g.
@v4). - No
squash and merge. Never use squash merges (gh pr merge --squashor GitHub UI squash) for PRs in this repository. All PR merges must preserve atomic commit history via merge commits (gh pr merge --merge) or rebase merges (gh pr merge --rebase) to maintain DevSecOps traceability, commit provenance, and auditability.
feat(engine): add async event dispatcher
fix(fingerprint): guard against nil BannerGrabConfig
chore(deps): update golang.org/x/sys to v0.45.0
test(ports): add race detector test for ScanPorts cancellation
docs(contracts): document EventCallback deprecation timeline
refactor(scan): extract asyncDispatcher to internal package
perf(topology): reduce allocations in edge key generation
Scope must match the package or area modified: engine, scan, events, profile,
results, discovery, ports, fingerprint, targets, topology, export,
exporter, store, diff, coreerr, netutil, deps, ci, contracts.
Every PR that changes behavior must update CHANGELOG.md under [Unreleased].
Sections: Added, Changed, Fixed, Security, Deprecated, Removed.
Breaking changes must start with **BREAKING CHANGE**:.
- All new public functions must have unit tests.
- Concurrency-sensitive code must be tested with
-race. - New parsing functions must have fuzz tests in
_test.gofiles withFuzzprefix. - Integration tests live in
tests/integration_test.go. - Do not use
t.Parallel()in tests that touch shared network state.
gofmtandgoimportson all files.golangci-lintmust pass (see.golangci.ymlfor enabled linters).- Zero allocation patterns for hot paths — see existing benchmarks in
pkg/fingerprint/oui_bench_test.goandpkg/topology/builder_bench_test.go. - Prefer
context.Contextas first parameter in all public functions that do I/O. ScanConfig.Sanitize()must be called before any scan — the engine calls it defensively inStartScan, but document this if exposing new entry points.
Milestone 5 tasks (next):
- Implement internal async dispatcher in
pkg/engine(buffered channel, separate goroutine) - Add
TestSlowCallbackDoesNotStallWorkers— slow callback must not delay scan > 5% - Add
TestNoGoroutineLeakOnPrematureCancel— zero goroutine leak after context cancel - Deprecate
pkg/engine.StartScanin godoc (preferpkg/scan.Engine.ScanStream) - Remove
pkg/storeandpkg/diff(coordinate withcatnet-io/appSprint 3)
See docs/milestones/milestone5_plan.md for full specification.
Read docs/contracts/api-stability.md before modifying any public API.
Read docs/contracts/events.md before modifying pkg/events.
Read docs/contracts/compatibility.md before introducing breaking changes.
Stable packages require a BREAKING CHANGE entry in CHANGELOG and a major version bump if the change removes or renames exported symbols.
go build ./...go test -race ./...go vet ./...golangci-lint run(viagolangci-lint.ymlworkflow)govulncheck ./...(viagovulncheck.ymlworkflow)
The following settings were migrated from .continue/agents/lmstudio.yaml and serve as reference for configuring local developer assistants:
- Name: Fabio LM Studio
- Schema: v1
- Supported Models (via LM Studio):
- LM Studio Auto (Provider:
lmstudio, Model:AUTODETECT, API Base:http://localhost:1234/v1) - Qwen 2.5 Coder 7B (Provider:
lmstudio, Model:qwen2.5-coder-7b-instruct, API Base:http://localhost:1234/v1) - Qwen 2.5 Coder 14B (Provider:
lmstudio, Model:qwen2.5-coder-14b-instruct, API Base:http://localhost:1234/v1) - Qwen 3.6 27B (Provider:
lmstudio, Model:qwen3.6-27b, API Base:http://localhost:1234/v1)
- LM Studio Auto (Provider:
- Default Context Providers:
codedocsdiffterminalproblemsfolder