stage-ordering

stage-ordering is an agent for coding agents from NickZaitsev/ru-normalizr. It costs 0 tokens per session (648 once invoked), scanned A, original, MIT.

A design note describing how text-processing stages claim matching pieces of text, including examples where a broad pattern matches before a more specific one.

In plain words
What is it for?
Use it when maintaining or debugging the ordering of text-processing rules and their handling of decimals, years, dates, and versions.
Why use it?
It documents why certain numbers, dates, and versions can be interpreted incorrectly when stages run in the wrong order.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/nickzaitsev/ru-normalizr/stage-ordering
Clone the repo
git clone --depth 1 https://github.com/NickZaitsev/ru-normalizr

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for stage-ordering

README.md
[![agentmods](https://agentmods.dev/badge/agents/nickzaitsev/ru-normalizr/stage-ordering.svg)](https://agentmods.dev/agents/nickzaitsev/ru-normalizr/stage-ordering)
Your own site
<a href="https://agentmods.dev/agents/nickzaitsev/ru-normalizr/stage-ordering"><img src="https://agentmods.dev/badge/agents/nickzaitsev/ru-normalizr/stage-ordering.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 648 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00648
Opus 5 $0.00000 $0.00324
Sonnet 5 $0.00000 $0.00130
Haiku 4.5 $0.00000 $0.00065

Measured 5d ago against content hash ea8a98a4278d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

stage-ordering scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/agents/stage-ordering.md · 49 lines

How it starts

The opening of the file, as written. The whole thing — 49 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Stage ordering: the specific pattern runs first

Every stage is a set of greedy regexes over the whole text. There is no arbitration: whichever stage reaches a span of characters first claims it, and the stage that would have matched a longer, more specific span gets whatever debris is left. Debris is worse than no match at all, because it is usually still numeric and the numerals stage will happily read it as something.

Three bugs of exactly this shape have been fixed so far:

Winner took Loser got Symptom
decimals took 3.12 .1 Python 3.12.1три целых двенадцать сотых. Одного
years took 2021 года 15.03. 15.03.2021 годапятнадцать целых три сотых. Две тысячи…
decimals took 5.2 10- 10-5.2десять пять целых две десятых (separator gone)

In each case the orphan's trailing dot became a sentence boundary in detokenize, and because NUMERAL_CONTEXT_BARRIERS does not include ., get_numeral_case scanned straight across it and inflected the stranded number to agree with words from the previous "sentence".

The rule

A full date is a special case of a year; a version is a special case of a decimal; a range is a special case of two numbers. The special case must run first. normalize_text therefore runs dates_time before years, and normalize_versions before normalize_decimals.

The same rule applies to authority, not just to span length: an explicit instruction outranks a guess. dictionary therefore runs before latinization — while it ran second it could not match any Latin token in TTS mode, because latinization had already rewritten the token into Cyrillic, so user rules were silently ignored in the pipeline's main mode.

Reordering is usually right, but never free

Putting the specific stage first is the correct fix, not a workaround. But a stage that has spent its whole life running second can carry latent defects that only the first position exposes. Reordering dates_time before years unmasked two of them at once: the shared year fragment consumed the whitespace before an optional era word (…двадцатого годаг.), and the dotted date pattern had no era tail at all.

Read the full file on GitHub · 49 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 49 lines · 0 tokens per session scan A ea8a98a4278d

Subscribe to this mod's changes

stage-ordering is an agent published in the GitHub repository NickZaitsev/ru-normalizr (22 stars, last pushed 28d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 648 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.