Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
117 changes: 117 additions & 0 deletions .agents/skills/project-redirects/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
name: project-redirects
description: "Mandatory workflow when adding, changing or removing Netlify redirect rules for learn.netdata.cloud (static.toml, the static section of netlify.toml, config/redirect-policy.json, scripts/verify-redirect-graph.js). Use before choosing redirect targets, adding a wildcard, or claiming a redirect batch is validated."
---
# Learn Redirects

## Purpose

Keeps redirect batches correct: every same-site rule lands on a rendered page in one hop (rules to
other hosts are only checked as valid URLs), wildcards stay
bounded to relocated sections whose whole historical inventory is pinned and verified, and the two
redirect files stay in sync. Beyond the pinned inventory, a section wildcard also aliases every
page added later under the new prefix, and forwards unknown children to the new prefix, where they
still answer 404.

## Scope

Use this skill when:

- adding redirects for dead URLs (backlinks, crawler or assistant requests, moved sections);
- relocating a docs section whose old paths must keep working;
- editing `config/redirect-policy.json` or `scripts/verify-redirect-graph.js`.

Do not use this skill for:

- the generated dynamic section of `netlify.toml` (written by `ingest/autogenerateRedirects.py`
during ingest; fix its producer, not the output);
- redirects on www.netdata.cloud (the website repository).

## Mandatory Knowledge

- Hand-maintained rules live in `static.toml`. The static section of `netlify.toml` (between
`# section: static << START` and `# section: static << END`) must be identical to it; edit both.
- Netlify applies the first matching rule. A wildcard placed before an exact rule it matches makes
that rule dead, and the verifier fails with "shadowed by wildcard".
- When a static wildcard whose destination ends in `:splat` covers a generated rule and the
wildcard's expanded target equals the generated target, the ingest generator drops the generated
rule; if the targets differ it raises an error (`ingest/autogenerateRedirects.py`,
`write_netlify_config`). When the targets match, remove the covered generated rule from
`netlify.toml` yourself until the next ingest (or regenerate with the script's `--refresh-current`
path), or the verifier reports the shadowing (SOW-0002). When they differ, decide the intended
destination first and change the wildcard or add an exact exception ahead of it; removing the
generated rule alone silently changes where that page goes.
- The verifier rejects exact-rule chains, targets that do not render, sources that shadow rendered routes, and
returned retired wildcards (`retired_wildcard_sources`). Relocated sections (`network_flows`,
`snmp_traps`) pin their full pre-move inventory in the policy. For `:splat` wildcards it probes the
pinned routes and one synthetic suffix only, so it can miss another child that lands on another
rule's source (a two-hop chain); check those overlaps by hand (SOW-0004). A wildcard with a fixed
destination is checked like an exact rule.
- The live sitemap writes `&` as `&amp;`; decode it before comparing routes. Paths with a literal
`&amp;` are real requests from sites that publish escaped links.
- The repository builds with Node.js 22 and Yarn 1; newer Node versions refuse the gate package.

## Best Practices

- Prefer exact rules. A wildcard is right for a whole relocated section where every old child has a
new counterpart (the Network Flows and SNMP Traps moves), or for decoding a literal `&amp;`
segment across a section (the notifications and authentication wildcards).
- Before adding a wildcard, measure what it would catch: in SOW-0002 a `/docs/agent/*` rule would
have turned about 1,550 requested dead paths into 301s ending on a 404.
- Use the history of this repository to decide whether a path was a real page (`git log` on
`docs/`, slug and `learn_link` frontmatter, earlier rules). Real former pages and URLs with live
backlinks get rules; guessed URLs need an explicit user decision.
- Target the page that covers the same subject today; when none does, the closest parent section.
A 301 followed by a 200 does not prove the subject matches: read the old page (from git history)
and the target before choosing. A removed collector whose module no longer exists goes to
`/docs/collecting-metrics`, never to a sibling collector of the same plugin (SOW-0002: Zabbix).
- Add a batch under a dated comment that says what the batch is and how targets were chosen. Netlify
uses the first match, so any rule whose source an earlier wildcard also matches must go above that
wildcard (as SOW-0002 did for the `&amp;` exceptions); the rest can go at the end of the static
section.

## Bad Practices

- Catch-all wildcards over legacy prefixes: they hide 404s behind redirects that still end on a 404.
- Editing only one of `static.toml` / `netlify.toml`.
- Rewriting `config/redirect-policy.json` with a JSON dumper: it reformats unrelated arrays; insert
text instead.

## Workflow Checklist

1. Collect the dead URLs and their evidence (backlinks, request counts, repository history).
2. Check each URL live (`curl -s -o /dev/null -w '%{http_code} %{redirect_url}'`) and against the
existing rules; drop those already handled.
3. Choose each target; confirm it is a rendered route and not itself a redirect source.
4. Write the rules to `static.toml` and mirror the static section into `netlify.toml`.
5. For a relocated section, add its inventory to the policy and its tests.

## Validation Checklist

Before claiming done:

- `npm run build:netlify` with Node.js 22: the redirect graph, rendered-link and site gates pass.
- The required same-site job follows redirects to their final page (SOW-0003): run
`node scripts/link-integrity/check.mjs inventory --build-dir build --redirects netlify.toml
--policy config/link-integrity.json --output <file>` and then `... same-site --inventory <file>`
on the build; `node --test tests/link_integrity.test.mjs` covers the checker.
- `npx vitest run src/seo` and the ingest redirect tests (`pytest` in `ingest/`) pass; update the
pinned wildcard list in `src/seo/renderedLinks.test.js` when adding a wildcard.
- On the pull request's deploy preview, every new source answers 301 to its target and ends on 200
after one hop.
- `src/seo/redirectGraph.test.js` reads `build/`, so keep it until the tests have run. Removing it
afterwards is optional disk cleanup, not part of validation.

## Evidence

- `scripts/verify-redirect-graph.js`: the redirect gates.
- `ingest/autogenerateRedirects.py` (`write_netlify_config`): static wildcard subsumption.
- `SOW-0002`: the fifth redirect batch, the wildcard measurement and the preview check.

## Update Rules

Update this skill when:

- a gate, generator or test changes how redirects are validated;
- a batch finds a new failure mode (encoding, ordering, shadowing);
- the user changes which URL classes get redirects.
199 changes: 199 additions & 0 deletions .agents/sow/SOW.template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
# SOW-NNNN - <Title>

## Status

Status: open | in-progress | paused | completed | closed

`completed` is the successful terminal status. `done` is a directory name, not a status value. Do not use `Status: done` or `Status: complete`.

Sub-state: <short current truth>

## Requirements

### Purpose

<User-stated purpose. All recommendations must align with this.>

### User Request

<Concise quote or faithful summary. Do not lose constraints.>

### Assistant Understanding

Facts:

- <Established from user/project/code/specs.>

Inferences:

- <Reasoned but not directly stated.>

Unknowns:

- <Only real unknowns that cannot be resolved by investigation.>

### Acceptance Criteria

- <Outcome with verification method.>
- <Outcome with verification method.>

## Analysis

Sources checked:

- <file/source>

Current state:

- <evidence>

Risks:

- <risk and implication>

## Pre-Implementation Gate

Status: blocked | ready | needs-user-decision

Problem / root-cause model:

- <What is happening, why it is happening, and evidence supporting that model.>

Evidence reviewed:

- <Specs, code, docs, tests, logs, traces, prior SOWs, issues, external references.>
- <For mirrored or cloned open-source repositories: cite `owner/repo @ commit` and repository-relative paths; never paste workstation absolute paths.>

Affected contracts and surfaces:

- <APIs, schemas, files, commands, UI, docs, specs, skills, tests, integrations, operators, users.>

Existing patterns to reuse:

- <Local modules, helpers, conventions, tests, and docs that shape the implementation.>

Risk and blast radius:

- <Regression, compatibility, performance, security, data loss, migration, rollout, and operational risks.>

Sensitive data handling plan:

- <Whether the work may expose secrets, credentials, bearer tokens, SNMP communities, community/customer data, personal data, non-private customer-identifying IPs, private endpoints, or proprietary incident details; how evidence will be redacted in SOWs, specs, docs, skills, instructions, and code comments.>

Implementation plan:

1. <Ordered chunk with scope, dependencies, and likely files/modules.>
2. <Ordered chunk with scope, dependencies, and likely files/modules.>

Validation plan:

- <Tests, fixtures, manual checks, real-use evidence, review passes, same-failure searches.>

Artifact impact plan:

- AGENTS.md: <expected update or reason likely unaffected>
- Runtime project skills: <expected update or reason likely unaffected>
- Specs: <expected update or reason likely unaffected>
- End-user/operator docs: <expected update or reason likely unaffected>
- End-user/operator skills: <expected update or reason likely unaffected>
- SOW lifecycle: <split/merge/status/follow-up/regression handling>

Open-source reference evidence:

- <If local mirrored or cloned open-source repositories were checked, list each as `owner/repo @ commit` plus repository-relative paths. If none were checked, record why external OSS references were not relevant.>

Open decisions:

- <Resolved decision, or numbered options that block implementation until the user decides.>

## Implications And Decisions

<Numbered user decisions, options, selection, and reasoning. User decisions must be recorded before implementation.>

## Plan

1. <chunk, scope, risk, dependencies>
2. <chunk, scope, risk, dependencies>

## Execution Log

### YYYY-MM-DD

- <files touched, decisions, deviations, reviewers>

## Validation

Acceptance criteria evidence:

- <evidence>

Tests or equivalent validation:

- <command/output summary>

Real-use evidence:

- <manual/API/CLI/UI path>

Reviewer findings:

- <reviewer and findings>

Same-failure scan:

- <search and result>

Sensitive data gate:

- <Confirm durable artifacts contain no raw secrets, credentials, bearer tokens, SNMP communities, community member names, customer names, personal data, non-private customer-identifying IPs, private endpoints, or proprietary incident details; note redactions used.>

Artifact maintenance gate:

- AGENTS.md: <updated path or evidence-backed reason no update was needed>
- Runtime project skills: <updated .agents/skills/project-*/ path or evidence-backed reason no update was needed>
- Specs: <updated .agents/sow/specs/ path or evidence-backed reason no update was needed>
- End-user/operator docs: <updated docs/runbooks/help paths or evidence-backed reason none were affected>
- End-user/operator skills: <updated output/reference skill paths or evidence-backed reason none were affected>
- SOW lifecycle: <status/directory checked; if successful close, `Status: completed` and move to `.agents/sow/done/` are committed together with the work in one commit unless user explicitly requested a different split; split/merge/follow-up/regression handling recorded>

Specs update:

- <updated spec or specific reason no update was needed>

Project skills update:

- <updated runtime project skill or specific reason no update was needed>

End-user/operator docs update:

- <updated docs or evidence-backed reason none were affected>

End-user/operator skills update:

- <updated output/reference skills affected by docs/spec changes, or evidence-backed reason none were affected>

Lessons:

- <lesson or specific reason none>

Follow-up mapping:

- <implemented/rejected/tracked>

## Outcome

Pending.

## Lessons Extracted

Pending.

## Followup

None yet.

## Regression Log

None yet.

Append regression entries here only after this SOW was completed or closed and later testing or use found broken behavior. Use a dated `## Regression - YYYY-MM-DD` heading at the end of the file. Never prepend regression content above the original SOW narrative.
Loading