Repository navigation
Add propose --learn-from to seed observations from Hermes run history - #11
Merged
Merged
Conversation
Co-Authored-By: bot_apk <apk@cognition.ai>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: bot_apk <apk@cognition.ai>
# Conflicts: # mandate_core/cli.py
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.
Summary
hermes mandate propose <job> --learn-from <source>reads the job's existing Hermes history, stores the tool calls it finds as observations, and compiles a pending mandate. A job with history can get a proposal without waiting for 3 live observe runs. It never approves and never changes the job's mode.How to run
Grammar (in the README command table and
mandate_core/history.py):history|cron:<name or id>| path to a session.jsonlor a directory of them.--workdiroverrides the workdir (default:workdirfromcron/jobs.json, then the live observations' root, then cwd).What changed
mandate_core/history.py(new): resolves the source under$HERMES_HOME(default~/.hermes). Cron runs are sessions namedcron_<job_id>_*insessions/*.jsonlandstate.db(opened read-only). Takes assistanttool_calls(function.name+function.arguments), skips unparseable lines, badtool_calls, calls with missing names or non-JSON args, and calls whose tool result saysMANDATE BLOCKED.cron/output/<id>/*.mdandcron/executions.dbare only counted, so the CLI can say "Hermes knows N runs but only M left a transcript". Nothing is written to the Hermes dir.Engine.shape_for(tool, args, cwd, root): the livepre_tool_callpath and the importer now share one normalize +to_json(redaction) +rootstep, so a learned observation is byte-for-byte the same shape the live hook would store (tested).source TEXT NOT NULL DEFAULT 'hook'added torunsandobservations(migrated in place on open).replace_history()writes learned runs assource='history'with run idhistory:<session_id>. Re-learning replaces those runs instead of stacking evidence.Rule.historyandPolicy.history_runs.compile_policy(..., history=<run ids>)counts learned evidence separately. Render only changes when history is present:parseround-trips the new fields.# learned from history: ...,# skipped: ..., a thin-history warning, and a warning that learned rules reflect what the job did before Mandate was watching. With no usable calls it exits 1 withno usable Hermes history for <job> ... Nothing was written.and writes no job, observation, or policy rows. Leash Line tail showsN run(s) observed (H learned from Hermes history).watchmentions the shortcut.proof/and the README results block are regenerated bymake prove-all(second commit).Tests
tests/test_history.py: parser (good and malformed rows, string/dict args, blocked calls, dedupe), source grammar,state.db+ ledger reading, fixture history with zero live runs proposes, distinctsourcemarking in store, YAML and Leash Line, learned calls redacted and identical to live shapes (no file contents, token, private key), determinism across two fresh stores plus re-learn is a no-op, no-history error, and--learn-fromleaves an enforcing job's mode and active version alone whileapprovewithout TTY still refuses.history-triagecron job whose history is written by Hermes's owncreate_job,SessionDB.append_message,divert_session_transcript_jsonlandsave_job_output, with one malformed row.propose --learn-from historythrough the realhermes mandateCLI giveshistory_runs: 3, stays OBSERVING with nothing approved, and an unknown job fails non-zero.make prove-all: validate passed and 122 passed, 0 failed on both Hermes v0.23.0 and v0.23.1 (was 112). Pinned Hermes SHAs unchanged.Gaps
cron_<job_id>_*id aren't picked up byhistory/cron:. Pass the transcript path instead..mdfiles have no tool calls, so they're only used for run counts.MANDATE BLOCKEDresults.Link to Devin session: https://app.devin.ai/sessions/054a0222339047a686312c8e13750d29
Open in Devin Desktop: https://app.devin.ai/desktop/session/054a0222339047a686312c8e13750d29?variant=devin