DDD Filter Management Skill
The Decentralized Diagnostics Daemon (DDD) uses "Filters" to parse raw build output strings into structured JSON diagnostics. These diagnostics are used by the "Mechanic" (Autofix) system to repair code.
As an Agent, you are responsible for maintaining these filters to ensuring the Mechanic can "see" errors correctly.
📍 Locations
- •Project Filters:
<project_root>/.ddd/filters/- •Place custom filters here. They are loaded automatically by
dd-daemon.pyif the project root is configured correctly. - •Best Practice: Always create new filters here unless instructed to patch the core.
- •Place custom filters here. They are loaded automatically by
- •Core Filters:
mission/internal/scripts/ddd/src/filters/- •Built-in filters (e.g.
gcc_json.py). Modify only if patching the Mission Pack itself.
- •Built-in filters (e.g.
🛠️ How to Create a Filter
- •Read the Template: Use
view_fileon.ddd/filters/templates/filter.template.py(or see the template below). - •Implementation:
- •Inherit from
BaseFilter. - •Implement
process(self, text) -> str. - •Input: Raw
text(stdout/stderr) from the build command. - •Output: A JSON string representing a list of diagnostic objects.
- •Decorator: Use
@register_filter("my_filter_name").
- •Inherit from
- •Deploy: Write the file to
<project_root>/.ddd/filters/<name>.py.
Diagnostic Object Format
Your JSON output must be a list of objects with these keys:
json
[
{
"file": "src/main.c",
"line": 10,
"col": 5, // Optional
"type": "error", // "error", "warning", "note"
"message": "expected ';'"
}
]
🔍 Debugging Filters
If the Mechanic isn't fixing an error, the filter might be failing to parse the log.
- •Check Raw Log:
tail -n 50 .ddd/run/build.log- •Ensure the error text actually appears there.
- •Check Report:
cat .ddd/run/build_report.json- •If this is empty
[]ornull, your regex is likely wrong.
- •If this is empty
- •Test Locally:
- •Create a test script that imports your filter and runs
process()against a sample string. - •Do NOT rely on waiting for the daemon loop for tight iteration.
- •Create a test script that imports your filter and runs
📝 Template
python
import re
import json
from . import register_filter
from .base import BaseFilter
@register_filter("custom_parser")
class CustomParserFilter(BaseFilter):
def process(self, text):
results = []
# Regex Example: "Error at line 10 in file.c: Bad syntax"
regex = re.compile(r"Error at line (\d+) in (.+): (.+)")
for match in regex.finditer(text):
results.append({
"line": int(match.group(1)),
"file": match.group(2),
"type": "error",
"message": match.group(3)
})
return json.dumps(results)