

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# Go Area Instructions23This file routes Go-specific work under `src/go/`. Repository-wide rules in4the repo-root `AGENTS.md` still apply. More specific `AGENTS.md` files under5subdirectories override this file for that subtree. Paths below are6repo-relative unless stated otherwise.78## Sensitive Data910The repo-root `AGENTS.md` sensitive-data policy applies in full to all durable11Go artifacts, including code comments, docs, specs, skills, and SOWs.1213## Mandatory Development Principles1415The repo-root clean-end-state and scope-discipline principles are mandatory and16apply in full. For Go work, enforce them explicitly when changing collectors,17framework code, runtime behavior, `metrix`, chart templates, Functions,18topology, tests, specs, or skills.1920- You MUST prefer the clean framework or collector shape over preserving a21 smaller diff.22- You MUST re-check scope after each coherent batch. If a separate framework fix,23 collector cleanup, or docs rewrite becomes necessary, split it into its own24 step or submit it independently before continuing.25- You SHOULD use RFC-style requirement language (`MUST`, `SHOULD`, `MAY`) in26 Go-area specs, skills, and instructions when documenting enforceable rules.2728## Task Routing2930| Work area | Start here | Notes |31|---|---|---|32| New go.d collector | `src/go/plugin/go.d/docs/how-to-write-a-collector.md` | New go.d collectors use framework V2. |33| Migrating go.d V1 collector to V2 | `src/go/plugin/go.d/docs/migrate-v1-to-v2.md` | Preserve public contracts unless a breaking change is explicitly approved. |34| go.d V2 implementation details | `.agents/skills/project-writing-go-modules-framework-v2/SKILL.md`, `src/go/pkg/metrix/README.md`, `src/go/plugin/framework/charttpl/README.md`, `src/go/plugin/framework/chartengine/README.md` | Use the skill for maintainer style and the READMEs for framework API contracts. Editing `metrix` or framework packages is framework-gated work. |35| go.d helper packages | `src/go/plugin/go.d/docs/helper-packages.md` | Check existing HTTP, config-option, matcher, logger, socket, command, SQL, ping, log-file, and cloud-auth helpers before adding custom plumbing. |36| Collector design across plugins | `.agents/skills/project-writing-collectors/SKILL.md` | Use for NIDL, cardinality, obsoletion, missing data, logging, and config discipline. |37| Integration metadata, taxonomy, generated docs | `.agents/skills/integrations-lifecycle/SKILL.md`, `.agents/skills/integrations-lifecycle/consistency.md` | Source artifacts and generated artifacts MUST stay synchronized. |38| IBM.d work | `src/go/plugin/ibm.d/AGENTS.md` | IBM.d has a generator-driven workflow; go.d V2 layout rules MUST NOT be applied there. |39| Function handlers | `src/go/plugin/framework/functions/README.md`, `src/go/tools/functions-validation/README.md` | Collector Functions SHOULD be isolated behind narrow dependencies. |40| Topology payloads | `.agents/skills/project-create-topology/SKILL.md`, `.agents/skills/project-create-topology/topology-function-schema.md`, `src/go/pkg/topology/v1` | New topology producers MUST use the production `netdata.topology.v1` schema. |41| Host scopes / vnodes | `.agents/skills/project-writing-go-modules-framework-v2/go-v2-host-scope.md`, `src/go/plugin/go.d/collector/azure_monitor/` | Use host scopes when one job emits metrics for resources that SHOULD appear as separate Netdata nodes. |42| Matchers/selectors | `src/go/pkg/matcher/README.md` | Prefer existing matcher APIs over custom selector grammars. |43| Core framework changes | `src/go/plugin/framework/docs/changing-framework-code.md` and `Core Framework Change Gate` below | The applicable approval tier MUST be satisfied before implementation. |4445## New go.d Collector Rules4647- New go.d collectors MUST implement `collectorapi.CollectorV2` from48 `src/go/plugin/framework/collectorapi/collector.go` and register via49 `CreateV2`. This includes writing metrics through `metrix.CollectorStore` and50 providing `ChartTemplateYAML()`.51- New go.d collector guidance MUST NOT teach or copy the V152 `Collect() map[string]int64` pattern for new53 collectors.54- Collector runtime, metric, chart, config, alert, taxonomy, and documentation55 changes MUST follow the repository collector consistency policy. The detailed56 checklist lives in `.agents/skills/integrations-lifecycle/consistency.md`.57- Public config options SHOULD be added only when they represent a real58 operator decision. Implementation tuning such as page sizes, scan windows,59 retry limits, and cadence SHOULD use internal constants unless user control is60 clearly justified.61- New collectors MUST NOT inherit unsupported config knobs from adjacent62 collectors or generic templates.63- Collector-local globals, singletons, adapters, caches, or glue layers that64 substitute for missing shared framework/helper capabilities are65 framework-scope work and MUST follow66 `src/go/plugin/framework/docs/changing-framework-code.md` before67 implementation.68- If the collector exposes Functions, put Function code in a dedicated69 `<name>func/` package behind a narrow `Deps` interface declared in that70 package. The Function package MUST NOT import the collector package or hold71 `*Collector`.72- If the collector emits topology, it MUST use `netdata.topology.v1`, the Go73 producer model in `src/go/pkg/topology/v1`, and validate payloads against74 `src/plugins.d/FUNCTION_TOPOLOGY_SCHEMA.json`. New producers MUST NOT use75 legacy topology payloads.76- If one job emits metrics for multiple remote resources that SHOULD appear as77 separate Netdata nodes, it MUST use V2 host scopes/vnodes.7879## go.d V1-to-V2 Migration Rules8081- V1-to-V2 migrations MUST start with82 `src/go/plugin/go.d/docs/migrate-v1-to-v2.md`.83- Migrations MUST preserve chart IDs, contexts, dimensions, config keys,84 defaults, health lookups, metadata, taxonomy, stock config, and service85 discovery behavior unless the user explicitly approves a breaking change.86- Compatibility migration SHOULD be separate from enrichment such as new labels,87 host scopes, topology, Functions, or config expansion.88- Completed migrations MUST NOT keep a runtime V1-to-V2 bridge. Temporary V189 logic can be used during development for parity checks, but it MUST be90 removed from the final migrated collector.9192## Core Framework Change Gate9394Changes to shared Go framework code (`metrix`, `chartengine`, `charttpl`, the job95runtime, `collectorapi`) are high-blast-radius: this code runs in EVERY collector,96most of it on the per-cycle hot path. Before changing these areas, read97`src/go/plugin/framework/docs/changing-framework-code.md` — the canonical owner of98the framework-change scope list, required design note, validation expectations, and99artifact checks. Implementation MUST NOT begin until that guide's applicable100approval tier is satisfied.101102- Clean extension over glue: prefer a clean framework extension over103 collector-local globals, singletons, adapters, or private-package coupling when104 the problem is general.105- Behavior preservation: when a framework change also touches shipped collectors,106 preserve their observable behavior (chart IDs, contexts, dimensions, config keys,107 defaults) and validate representative consumers, not only the framework package108 (see "Validation For Go Changes").109- metrix contract: `metrix` keeps one descriptor per metric NAME, resolved110 atomically at commit and bounded — a name idle past `expireAfterSuccessCycles +111 descriptorGraceCycles` is evicted, and re-registers cleanly afterward. A consumer112 that caches per-name state across cycles MUST couple its lifetime to the optional113 `metrix.DescriptorRetention` accessor. See `src/go/pkg/metrix/README.md`114 ("Descriptor Lifecycle and Retention").115116## Evidence Before Complexity117118Readability and maintainability are the default for Go control-plane and119framework code. Complexity needs evidence; a plausible future problem is not a120requirement.121122- Code MUST NOT introduce population, byte, concurrency, queue, retry, or123 backpressure limits, nor add accounting, scheduling, pooling, caching, custom124 data structures, or lifecycle machinery, unless the design follows from a125 concrete correctness, liveness, protocol, compatibility, or security contract,126 a documented scale requirement, or a measured production workload.127- The justification MUST identify the input or producer, the failure being128 prevented, the expected scale, and why simpler slices, maps, channels, or129 direct ownership are insufficient. A round number, hypothetical abuse case,130 or benchmark in isolation is not evidence of a product requirement.131- Protocol- and security-derived bounds MUST remain tied to their source with a132 concise rationale and boundary tests. Do not generalize one per-item bound133 into an aggregate process policy without separate evidence.134- When a limit has no valid requirement, remove the policy and its coupled135 machinery. Raising it to an effectively unreachable value is not the clean136 end state.137- Do not add allocation- or latency-oriented complexity until the path is shown138 to be hot by its production frequency, a profile, or representative benchmark.139 Once a path is established as hot, follow "Hot-Path And Benchmark Discipline."140141## Hot-Path And Benchmark Discipline142143metrix commit/collect, per-sample/per-write, and per-cycle code are hot paths that144run for every collector on every cycle.145146- Before/after REQUIRED: a hot-path change MUST include before/after147 `go test -bench` numbers (use `git stash` for the "before" baseline), not just148 "tests pass".149- Allocation count is the gate: assert allocs stay within the intended envelope150 (e.g. a sparse commit stays ~O(touched), never O(retained)). `ns/op` is a151 dev-machine trend indicator, NOT a CI gate — label it as such inline, and never152 record a personal name in the file.153- State the complexity envelope explicitly (e.g. "commit is O(live-series +154 touched + distinct-names)") and prove the change did not introduce an155 O(samples)/O(retained)/O(n^2) regression.156- Keep bench comments in sync with the code they measure, in the same change, with157 self-contained wording (no round/session references).158159## Go Formatting160161`gofmt` and `goimports` are the baseline. This repository additionally162RECOMMENDS (not CI-enforced) a fuller formatting pipeline that keeps line163wrapping tight and keyed struct literals readable:1641651. `golines -m 120 -t 4 -w <paths>` — join over-wrapped signatures/calls and166 split lines past ~120 columns. SKIP this step if `golines` is not installed167 (`go install github.com/segmentio/golines@latest`).1682. `go run ./tools/expandstructs <paths>` — put each keyed struct-literal field169 on its own line. Formats source in-process with `go/format`.1703. `goimports -w <paths>` — order imports.171172Conventions this encodes:173174- Keep a signature / call / return / composite literal on ONE line when it fits175 within ~120 columns; wrap only when it does not.176- Keyed struct literals of a named type go ONE field per line.177178`gofmt`/`goimports` cannot express these two rules, so they are not CI-enforced;179re-run the pipeline if code drifts. See `tools/expandstructs/README.md`.180181## Validation For Go Changes182183Run the narrowest command that actually exercises the change; do not claim184full-project validation from a narrow one.185186- Always: formatted per "Go Formatting" above (at minimum `gofmt` clean) and187 `go vet ./<pkg>/` clean.188- Unit: `go test -count=1 ./<pkg>/...` for every package you touched.189- Concurrency: add `-race` for concurrency-sensitive packages (`metrix`, the job190 runtime, `plugin/agent/jobmgr`).191- Shared framework code: ALSO build and test representative consumers (a couple of192 real collectors) plus `-race ./plugin/agent/jobmgr/`, so a framework change is193 proven against real users, not just its own package.194- Reproduce a reviewer-reported bug as a FAILING test first, then fix to green195 (repo-wide working-style rule).196- Prefer `testify/require` for test prerequisites and `testify/assert` for197 comparisons when applicable. Use `t.Fatal` or `t.Fatalf` directly when it198 represents genuine test control flow or has no clearer assertion equivalent.199200## Go Review And Reachability201202- Start review at the declared interface and the shipped production adapter.203 Inspect implementation internals behind that boundary only when the contract204 leaves relevant behavior unspecified or concrete evidence points across it.205 Do not make a caller responsible for arbitrary private behavior of every206 implementation.207- Before deleting Go code as unused, check all relevant reference forms:208 selector reads and writes, struct literals, constructor arguments, method209 values, interface satisfaction, reflection, build-tagged and platform files,210 generated code, and test-only injection. A call-site-only search is not proof211 of unreachability.212213## Batching And Review214215- Changes SHOULD stay atomic. If a collector or framework task grows, split it216 into coherent batches before review becomes difficult.217- At every batch boundary, you MUST re-evaluate clean end state and scope. If218 the branch now contains independent work, pause and submit that work219 separately or defer it before continuing.220- Changes MUST NOT mix framework changes, collector migrations, and221 integration-doc regeneration unless they are required for one coherent222 behavior change.223- Multi-round review: checkpoint-commit each validated change before its review and224 squash at PR time; if findings keep clustering in one subsystem (~2-3 rounds),225 stop patching and fix the class (repo-wide review rules).226- For Go test style, follow the repo-root `AGENTS.md` "Go test style" section.227
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| netdata/netdatasrc/go/plugin/ibm.d/AGENTS.md · 80k | AGENTS.md | buildtestlint-formatarch+3 | 99/100 | 14 days ago | |
| netdata/netdataAGENTS.md · 80k | AGENTS.md | testlint-formatstylearch+6 | 64/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| aaif-goose/gooseAGENTS.md · 53k | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 8 days ago | |
| wpscanteam/wpscanAGENTS.md · 9.7k | AGENTS.md | setupbuildteststyle+6 | 100/100 | 13 days ago | |
| bagisto/bagistoAGENTS.md · 28k | AGENTS.md | setupbuildteststyle+7 | 100/100 | 7 days ago | |
| ethereum/go-ethereumAGENTS.md · 51k | AGENTS.md | buildtestlint-formatgit+1 | 100/100 | 14 days ago | |
| unoplat/unoplat-code-confluenceunoplat-code-confluence-frontend/AGENTS.md · 95 | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 13 days ago | |
| caddyserver/caddyAGENTS.md · 75k | AGENTS.md | buildtestlint-formatstyle+3 | 99/100 | 14 days ago | |
| netdata/netdatasrc/go/plugin/ibm.d/AGENTS.md · 80k | AGENTS.md | buildtestlint-formatarch+3 | 99/100 | 14 days ago | |
| unoplat/unoplat-code-confluenceunoplat-code-confluence-query-engine/AGENTS.md · 95 | AGENTS.md | setupbuildtestlint-format+5 | 98/100 | 13 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/netdata-netdata-src-go-agents)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.
Directory