-
Notifications
You must be signed in to change notification settings - Fork 11
feat(claude-plugin): record guideline usage per session in audit.log #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
98e7c32
feat(claude-plugin): record guideline usage per session in audit.log
vinodmut 9cc5eea
style(tests): apply ruff format to sandbox learn+recall test
vinodmut 5cfa46f
fix(learn): guard payload and assessment types in log_influence.py
vinodmut e6a55d5
fix(learn): resolve recalled slugs across subscribed entity trees
vinodmut 0999295
test(learn): add unit tests for log_influence.py
vinodmut c005954
fix(claude-plugin): qualify recall audit ids across local/subscribed …
vinodmut 52c481f
Merge remote-tracking branch 'public/main' into provenance-usage
vinodmut d86e8dd
fix(learn): renumber influence step to Step 5 after merge
vinodmut a18073c
test(learn): switch log_influence tests to temp_project_dir fixture
vinodmut cbef977
test(learn): assert no audit writes on invalid JSON input
vinodmut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
79 changes: 79 additions & 0 deletions
79
platform-integrations/claude/plugins/evolve-lite/skills/learn/scripts/log_influence.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| #!/usr/bin/env python3 | ||
| """Append post-hoc influence assessments to .evolve/audit.log. | ||
|
|
||
| Reads JSON from stdin of the form: | ||
| { | ||
| "session_id": "<transcript stem>", | ||
| "assessments": [ | ||
| {"entity": "<slug>", "verdict": "followed|contradicted|not_applicable", | ||
| "evidence": "<short justification>"}, | ||
| ... | ||
| ] | ||
| } | ||
| """ | ||
|
|
||
| import json | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent.parent / "lib")) | ||
| from entity_io import get_evolve_dir, log as _log # noqa: E402 | ||
| import audit # noqa: E402 | ||
|
|
||
|
|
||
| _ALLOWED_VERDICTS = {"followed", "contradicted", "not_applicable"} | ||
|
|
||
|
|
||
| def log(message): | ||
| _log("influence", message) | ||
|
|
||
|
|
||
| def main(): | ||
| try: | ||
| payload = json.load(sys.stdin) | ||
| except json.JSONDecodeError as exc: | ||
| log(f"Invalid JSON input: {exc}") | ||
| print(f"Error: invalid JSON input - {exc}", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| if not isinstance(payload, dict): | ||
| log(f"Bad payload type: {type(payload).__name__}") | ||
| print("Error: payload must be a JSON object.", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| session_id = payload.get("session_id") | ||
| assessments = payload.get("assessments", []) | ||
| if not session_id or not isinstance(assessments, list): | ||
| log(f"Bad payload shape: session_id={session_id!r} assessments_type={type(assessments).__name__}") | ||
| print("Error: payload must include `session_id` and a list `assessments`.", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| project_root = str(get_evolve_dir().resolve().parent) | ||
|
|
||
| written = 0 | ||
| for a in assessments: | ||
| if not isinstance(a, dict): | ||
| log(f"Skipping non-dict assessment item: {a!r}") | ||
| continue | ||
| entity = a.get("entity") | ||
| verdict = a.get("verdict") | ||
| evidence = a.get("evidence", "") | ||
| if not entity or verdict not in _ALLOWED_VERDICTS: | ||
| log(f"Skipping invalid assessment: {a}") | ||
| continue | ||
| audit.append( | ||
| project_root=project_root, | ||
| event="influence", | ||
| session_id=session_id, | ||
| entity=entity, | ||
| verdict=verdict, | ||
| evidence=evidence, | ||
| ) | ||
| written += 1 | ||
|
|
||
| log(f"Wrote {written} influence record(s) for session {session_id}") | ||
| print(f"Recorded {written} influence assessment(s).") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.