[Feature Request] Add optional tag or comment field to routing rules
Use Case
Currently, route.rule_set objects support a tag field, which is highly useful for identifying and managing them. However, individual routing rules inside route.rules do not have a tag, description, or comment field.
When managing large and complex configuration files with dozens of routing rules, it becomes difficult to debug, maintain, or quickly identify the exact purpose of a specific rule without external documentation.
Proposed Solution
Add an optional tag (or comment) string field to the routing rule object schema.
Example:
{
"route": {
"rules": [
{
"tag": "bypass-local-traffic",
"geoip": ["private"],
"outbound": "direct"
},
{
"tag": "restrict-work-ads",
"domain_suffix": ["doubleclick.net"],
"outbound": "block"
}
]
}
}
This field should be ignored during core routing logic operations but could be printed in logs (e.g., when a rule matches a packet under v or vv log levels) to drastically improve troubleshooting.
alternatives considered
Using external JSON/JSONC comments (like //), but this is not native to standard JSON parsing and gets stripped out if the configuration is managed or regenerated via API/web frontends.
Additional Context
I would love to see this feature implemented. I am also willing to contribute and help with the implementation (PR) if guided in the right direction regarding which parts of the router/config parser codebase need to be modified.
I have already implemented an example of how to implement this. Kindly pay attention @nekohasekai
https://github.com/SagerNet/sing-box/pull/4158