Repository navigation
feat(hydrator): correct policy adherence counts and add Trust Index output - #12
Open
chou-godaddy wants to merge 3 commits into
Open
chou-godaddy wants to merge 3 commits into
chou-godaddy wants to merge 3 commits into
Conversation
Add opt-in policy decision measurements and a generic Trust Index score. Preserve findings as structured evidence, isolate resource limits per agent, and leave both legacy signal formats and counting rules unchanged. Document registration, weight-zero inspection, migration, and stale-score limitations without changing the Trust Index reference implementation. Refs agentnameservice#9 Signed-off-by: chou-godaddy <chou@godaddy.com>
Stop a half-written final log line or an ordinary log line that mentions the OCSF-JSON marker from withholding every agent's score, and stop coverage, operational and connection-failure records from hiding a stated policy decision by enforcing that once after classification instead of in each branch. Reject Helm evidence file paths, which would fail every scheduled run after the first; make evidence assembly read-only; and feed the activity and legacy aggregators as separate event consumers. Document the remaining limits before the signal weight is raised above zero. Refs agentnameservice#9 Signed-off-by: chou-godaddy <chou@godaddy.com>
A local run against OpenShell v0.1.5 and agent-trust-discovery showed that the activity log hid audited violations, that an allowed upstream 503 had no regression test, and that a mid-window policy change was invisible to the Trust Index because policy context stayed in local evidence. Evidence now reports policyChanged, and score explanations name the policies behind the counts. Also clears goconst findings reported by a clean golangci-lint cache and documents that rerunning the same window does not replace a stored score. Signed-off-by: chou-godaddy <chou@godaddy.com>
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
ans-ocsf-hydratorcould report 100% policy adherence while an agent violated its policy. In OpenShell's audit mode, violations are logged with allow enums and only the message saysaudit. Connection errors counted as violations, session records counted as allowed, and one request produced several records. This PR corrects those counts in a new, opt-inopenshell.behavior.activityoutput thatagent-trust-discoveryimports directly through its existing{score, explanation}signal format. The existing signals are unchanged.Fixes #9
Changes
internal/hydrator/activity_event.go): an ordered rule list routes each OCSF record. The five L7 formats (L7_REQUEST,GRAPHQL_L7_REQUEST,JSONRPC_L7_REQUEST,L7_REQUEST_TRANSFORMED,WEBSOCKET_L7_REQUEST) are parsed into allowed, denied, audited, or unknown. Connection errors, sessions, DNS refusals, middleware telemetry, passthrough HTTP, and coverage records become diagnostics instead of decisions. A record that states a decision but cannot be counted marks the agent incomplete, so it cannot hide a denial.activity_score.go): connection, initial HTTP, post-rewrite, and WebSocket checks are counted separately. The score is the rounded minimum of100 × allowed / (allowed + denied + audited)over groups that meetactivity.min_decisions. Unknown decisions or exhausted deduplication budgets withhold only the affected agent's score.activity.go,--evidence-output): per-agent JSONL with the window, counts per group, sample size, finding origins and match counts, policy hashes and versions,policyChanged, and diagnostics. Finding-only windows produce evidence without a score. Findings never change the score.observation.go,run.go,cmd/ans-ocsf-hydrator):signals.activityenables the new observation; risk codes are omitted. Explanations summarize findings and name the policies behind the counts.deploy/examples/hydrator-activity.yaml,deploy/examples/trust-index-score-signals.yaml(registration withthreshold: 0), the Helm window comment, anddocs/hydrator-activity.mdwith migration steps and known limits.Defensive checks beyond the issue
Audit records are partly written by the sandbox being measured, so the new path adds four checks that #9 does not ask for. Each one withholds a score rather than risk reporting a wrong one. They are covered by unit tests; normal traffic does not trigger them, so the live run does not exercise them.
activity.max_uids, default 1,000,000, next to the per-agentactivity.max_uids_per_agent): when the total fills, the agent holding the most event IDs is markeddedup_saturatedand its set is released, so later agents still fit in memory.unrepresented_dns_refusals), so a refusal with no matching denial cannot disappear.unreadable_audit_records) until the file rotates. An incomplete final line that is still being written only adds a diagnostic.--evidence-outputcreates the file exclusively with mode 0600 and refuses to overwrite an existing file. The Helm chart accepts only stdout (-) or disabled, because the CronJob reruns every schedule and would collide with its previous evidence file.Per-agent maps and text fields from audit records are also bounded.
Testing
go test -race ./...,go vet ./...,gofmt, andgolangci-lintv2.10.1 with a clean cache: all pass, 0 issues. Hydrator coverage 97.8%.agent-trust-discovery@e94aca5:mainand this branch is byte-identical on the same captures.enforcement: audit, two forbidden POSTs reached the upstream and were logged asaction_id 1 / disposition_id 1withL7_REQUEST audit. LegacyprotocolAdherencereports 1.0; the new score is 67.openshell.behavior.activity: 0, imports the output without conversion, and shows each score at weight 0 without changing the behavior dimension.openshell policy setyieldspolicyChanged: trueand an explanation naming both policy hashes.Rollout criteria
Retained and superseded scores are consumer behavior, and this repository has no
agent-trust-discoverydependency. They are covered byagent-trust-discoverytests (TestImportObservations_Supersede,TestAppendObservationDedupsIdenticalTriple) and were confirmed in the live run: a skipped report kept an earlier 100, and a later clean window replaced a 67. Re-posting the same window is ignored by the consumer, as documented.Known limits
The signal stays at weight 0 until the consumer can expire stale scores.
docs/hydrator-activity.mdlists the remaining limits: a sandbox can withhold its own new score with conflicting records, or every agent's with one unreadable audit line until the file rotates; a single violation among 200 or more decisions still rounds to 100; and this measures policy adherence, not content safety.AI assistance
Assisted-by: Cursor (Claude Opus 5.5)