-
Notifications
You must be signed in to change notification settings - Fork 312
feat: drop-in observability kit with audit comparison and behavioral signals #22711
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
+4,357
−105
Merged
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d01144d
Improve agentic audit baselines and execution observability
mnkiefer a8b86d6
Merge branch 'main' into obs-tools
mnkiefer 80942d2
Merge branch 'main' into obs-tools
pelikhan b22b7cd
Merge branch 'main' into obs-tools
pelikhan 5abdb23
fix: address review comments for observability audit improvements
Copilot d32e410
enhance audit comparison and reporting with task domain & behavior fi…
mnkiefer 89f4ad9
simplify string checks and error handling
mnkiefer 1b1b538
Merge branch 'main' into obs-tools
mnkiefer 41ce17b
Merge branch 'main' into obs-tools
pelikhan b27da9c
Merge branch 'main' into obs-tools
mnkiefer 97cf927
rm observability policy cmd and related
mnkiefer 6e7fd2e
Merge branch 'main' into obs-tools
mnkiefer 3a1c0b3
clean up
mnkiefer 7baf503
rm docs
mnkiefer c1ac9aa
avoid unnecessary refactoring
mnkiefer 80b6893
update agentic observability kit
mnkiefer 65499a9
add episode and DAG model details
mnkiefer 2532822
add deterministic episode model and related fields to logs
mnkiefer ee077e2
fix lint error
mnkiefer 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| // @ts-check | ||
| /// <reference types="@actions/github-script" /> | ||
|
|
||
| const fs = require("fs"); | ||
|
|
||
| const AW_INFO_PATH = "/tmp/gh-aw/aw_info.json"; | ||
| const AGENT_OUTPUT_PATH = "/tmp/gh-aw/agent_output.json"; | ||
| const gatewayEventPaths = ["/tmp/gh-aw/mcp-logs/gateway.jsonl", "/tmp/gh-aw/mcp-logs/rpc-messages.jsonl"]; | ||
|
|
||
| function readJSONIfExists(path) { | ||
| if (!fs.existsSync(path)) { | ||
| return null; | ||
| } | ||
|
|
||
| try { | ||
| return JSON.parse(fs.readFileSync(path, "utf8")); | ||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| function countBlockedRequests() { | ||
| for (const path of gatewayEventPaths) { | ||
| if (!fs.existsSync(path)) { | ||
| continue; | ||
| } | ||
|
|
||
| const content = fs.readFileSync(path, "utf8"); | ||
| return content | ||
| .split("\n") | ||
| .map(line => line.trim()) | ||
| .filter(Boolean) | ||
| .reduce((count, line) => { | ||
| try { | ||
| const entry = JSON.parse(line); | ||
| return entry && entry.type === "DIFC_FILTERED" ? count + 1 : count; | ||
| } catch { | ||
| return count; | ||
| } | ||
| }, 0); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| function uniqueCreatedItemTypes(items) { | ||
| const types = new Set(); | ||
|
|
||
| for (const item of items) { | ||
| if (item && typeof item.type === "string" && item.type.trim() !== "") { | ||
| types.add(item.type); | ||
| } | ||
| } | ||
|
|
||
| return [...types].sort(); | ||
| } | ||
|
|
||
| function collectObservabilityData() { | ||
| const awInfo = readJSONIfExists(AW_INFO_PATH) || {}; | ||
| const agentOutput = readJSONIfExists(AGENT_OUTPUT_PATH) || { items: [], errors: [] }; | ||
| const items = Array.isArray(agentOutput.items) ? agentOutput.items : []; | ||
| const errors = Array.isArray(agentOutput.errors) ? agentOutput.errors : []; | ||
| const traceId = awInfo.context && typeof awInfo.context.workflow_call_id === "string" ? awInfo.context.workflow_call_id : ""; | ||
|
|
||
| return { | ||
| workflowName: awInfo.workflow_name || "", | ||
| engineId: awInfo.engine_id || "", | ||
| traceId, | ||
| staged: awInfo.staged === true, | ||
| firewallEnabled: awInfo.firewall_enabled === true, | ||
| createdItemCount: items.length, | ||
| createdItemTypes: uniqueCreatedItemTypes(items), | ||
| outputErrorCount: errors.length, | ||
| blockedRequests: countBlockedRequests(), | ||
| }; | ||
| } | ||
|
|
||
| function buildObservabilitySummary(data) { | ||
| const posture = data.createdItemCount > 0 ? "write-capable" : "read-only"; | ||
| const lines = []; | ||
|
|
||
| lines.push("<details>"); | ||
| lines.push("<summary><b>Observability</b></summary>"); | ||
| lines.push(""); | ||
|
|
||
| if (data.workflowName) { | ||
| lines.push(`- **workflow**: ${data.workflowName}`); | ||
| } | ||
| if (data.engineId) { | ||
| lines.push(`- **engine**: ${data.engineId}`); | ||
| } | ||
| if (data.traceId) { | ||
| lines.push(`- **trace id**: ${data.traceId}`); | ||
| } | ||
|
|
||
| lines.push(`- **posture**: ${posture}`); | ||
| lines.push(`- **created items**: ${data.createdItemCount}`); | ||
| lines.push(`- **blocked requests**: ${data.blockedRequests}`); | ||
| lines.push(`- **agent output errors**: ${data.outputErrorCount}`); | ||
| lines.push(`- **firewall enabled**: ${data.firewallEnabled}`); | ||
| lines.push(`- **staged**: ${data.staged}`); | ||
|
|
||
| if (data.createdItemTypes.length > 0) { | ||
| lines.push("- **item types**:"); | ||
| for (const itemType of data.createdItemTypes) { | ||
| lines.push(` - ${itemType}`); | ||
| } | ||
| } | ||
|
|
||
| lines.push(""); | ||
| lines.push("</details>"); | ||
|
|
||
| return lines.join("\n") + "\n"; | ||
| } | ||
|
|
||
| async function main(core) { | ||
| const mode = process.env.GH_AW_OBSERVABILITY_JOB_SUMMARY || ""; | ||
| if (mode !== "on") { | ||
| core.info(`Skipping observability summary: mode=${mode || "unset"}`); | ||
| return; | ||
| } | ||
|
|
||
| const data = collectObservabilityData(); | ||
| const markdown = buildObservabilitySummary(data); | ||
| await core.summary.addRaw(markdown).write(); | ||
| core.info("Generated observability summary in step summary"); | ||
| } | ||
|
|
||
| module.exports = { | ||
| buildObservabilitySummary, | ||
| collectObservabilityData, | ||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; | ||
| import fs from "fs"; | ||
|
|
||
| const mockCore = { | ||
| info: vi.fn(), | ||
| summary: { | ||
| addRaw: vi.fn().mockReturnThis(), | ||
| write: vi.fn().mockResolvedValue(), | ||
| }, | ||
| }; | ||
|
|
||
| global.core = mockCore; | ||
|
|
||
| describe("generate_observability_summary.cjs", () => { | ||
| let module; | ||
|
|
||
| beforeEach(async () => { | ||
| vi.clearAllMocks(); | ||
| fs.mkdirSync("/tmp/gh-aw/mcp-logs", { recursive: true }); | ||
| process.env.GH_AW_OBSERVABILITY_JOB_SUMMARY = "on"; | ||
| module = await import("./generate_observability_summary.cjs"); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| delete process.env.GH_AW_OBSERVABILITY_JOB_SUMMARY; | ||
| for (const path of ["/tmp/gh-aw/aw_info.json", "/tmp/gh-aw/agent_output.json", "/tmp/gh-aw/mcp-logs/gateway.jsonl", "/tmp/gh-aw/mcp-logs/rpc-messages.jsonl"]) { | ||
| if (fs.existsSync(path)) { | ||
| fs.unlinkSync(path); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| it("builds summary from runtime observability files", async () => { | ||
| fs.writeFileSync( | ||
| "/tmp/gh-aw/aw_info.json", | ||
| JSON.stringify({ | ||
| workflow_name: "triage-workflow", | ||
| engine_id: "copilot", | ||
| staged: false, | ||
| firewall_enabled: true, | ||
| context: { workflow_call_id: "trace-123" }, | ||
| }) | ||
| ); | ||
| fs.writeFileSync( | ||
| "/tmp/gh-aw/agent_output.json", | ||
| JSON.stringify({ | ||
| items: [{ type: "create_issue" }, { type: "add_comment" }], | ||
| errors: ["validation failed"], | ||
| }) | ||
| ); | ||
| fs.writeFileSync("/tmp/gh-aw/mcp-logs/gateway.jsonl", [JSON.stringify({ type: "DIFC_FILTERED" }), JSON.stringify({ type: "REQUEST" })].join("\n")); | ||
|
|
||
| await module.main(mockCore); | ||
|
|
||
| expect(mockCore.summary.addRaw).toHaveBeenCalledTimes(1); | ||
| const summary = mockCore.summary.addRaw.mock.calls[0][0]; | ||
| expect(summary).toContain("<summary><b>Observability</b></summary>"); | ||
| expect(summary).toContain("- **workflow**: triage-workflow"); | ||
| expect(summary).toContain("- **engine**: copilot"); | ||
| expect(summary).toContain("- **trace id**: trace-123"); | ||
| expect(summary).toContain("- **posture**: write-capable"); | ||
| expect(summary).toContain("- **created items**: 2"); | ||
| expect(summary).toContain("- **blocked requests**: 1"); | ||
| expect(summary).toContain("- **agent output errors**: 1"); | ||
| expect(summary).toContain(" - add_comment"); | ||
| expect(summary).toContain(" - create_issue"); | ||
| expect(mockCore.summary.write).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it("skips summary generation when opt-in mode is disabled", async () => { | ||
| process.env.GH_AW_OBSERVABILITY_JOB_SUMMARY = "off"; | ||
|
|
||
| await module.main(mockCore); | ||
|
|
||
| expect(mockCore.summary.addRaw).not.toHaveBeenCalled(); | ||
| expect(mockCore.summary.write).not.toHaveBeenCalled(); | ||
| expect(mockCore.info).toHaveBeenCalledWith("Skipping observability summary: mode=off"); | ||
| }); | ||
| }); |
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.