feat(engine): add export_traffic to dump observations as savings-report JSONL#27
Closed
AZERDSQ131 wants to merge 1 commit into
Closed
feat(engine): add export_traffic to dump observations as savings-report JSONL#27AZERDSQ131 wants to merge 1 commit into
AZERDSQ131 wants to merge 1 commit into
Conversation
…rt JSONL
Observation mode (start_observing / add_observation) already captures
exactly the data rulechef-savings needs, but nothing wrote it to disk
in the traffic format -- users had to write their own dump loop.
Add RuleChef.export_traffic(path): exports LLM-sourced observations
as {text, llm_label} for classification output or {text, llm_entities}
for NER/extraction output. Human-sourced examples and observations
missing a usable text/output shape are skipped.
Closes KRLabsOrg#20
Contributor
|
Thanks for picking this up — unfortunately it crossed with #21, which was opened for the same issue (#20) a few days earlier and just merged. Same design, so closing this one. The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The savings report (
rulechef-savings) needs a traffic JSONL file, but there's no helper to produce one. Observation mode (start_observing/add_observation) already captures exactly this data, it just never lands on disk in the traffic format — users had to write their own dump loop.Fix
Added
RuleChef.export_traffic(path). It exports LLM-sourced observations from the buffer as:{"text": ..., "llm_label": ...}for classification output{"text": ..., "llm_entities": [...]}for NER/extraction output (entitiesorspanskey)Human-sourced examples (
add_example, corrections) are skipped — they aren't traffic. Observations missing atextinput or a recognized output shape are also skipped rather than raising.Documented the
observe -> export_traffic -> rulechef-savingsloop inbenchmarks/INSPECTING_RULES.md, including a note thatrulechef-savingsitself currently only scores the classification (llm_label) shape (NER traffic export is ready for when #19 lands).Tests
export_traffic->rulechef-savingsCLI -> assert the generated HTML report (mirrorstests/test_reports.py::test_savings_cli's invocation pattern).pytest tests/ -q→ 316 passed, 1 skipped.ruff checkandmypy rulechef/engine.pyclean.Closes #20