Skip to content

feat(agent): add counterfactual reasons to decision snapshots - #361

Merged
JSONbored merged 6 commits into
JSONbored:mainfrom
bitloi:feat/issue-284-counterfactual-reasons
Jun 4, 2026
Merged

feat(agent): add counterfactual reasons to decision snapshots#361
JSONbored merged 6 commits into
JSONbored:mainfrom
bitloi:feat/issue-284-counterfactual-reasons

Conversation

@bitloi

@bitloi bitloi commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #284

  • Adds structured counterfactualReasons to repo decisions and decision actions so snapshots can explain why obvious alternatives were rejected.
  • Threads scoped counterfactuals into agent context snapshots as grouped rejectedAlternatives per selected repo.
  • Keeps counterfactual public summaries deterministic, advisory, and sanitized.

Scope

  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; global coverage stays at or above 97% for lines, statements, functions, and branches (aim for 98%+ branch coverage locally so CI variance does not fail near the threshold)
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • npm run test:coverage / npm run validate was attempted locally, but this shell is on Node 24 while .nvmrc requires Node 22. The unrelated test/unit/local-scorer-adapter.test.ts external-command fixtures fail locally with scorer_failed fallback results before coverage can complete. Focused feat(agent): add counterfactual reasons to decision snapshots #284 tests pass with npx vitest run test/unit/decision-pack.test.ts test/unit/agent-orchestrator.test.ts (59 tests), and CI should run the full Node 22 gate.
  • Partial focused coverage was also attempted with npx vitest run --coverage test/unit/decision-pack.test.ts test/unit/agent-orchestrator.test.ts; the tests pass, but the repo-wide 97% global threshold fails as expected for a partial suite.
  • GitHub Actions validate passed on this PR after submission.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. — N/A, no auth/session/GitHub App behavior changed.
  • API/OpenAPI/MCP behavior is updated and tested where needed. — no API schema change; existing generic decision/snapshot payloads carry the new structured data, and npm run ui:openapi:check passed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. — N/A, no UI changes.
  • Visible UI changes include screenshots or a short recording. — N/A, no visible UI changes.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs. — N/A, no docs/changelog change needed.

Notes

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bitloi this is ready from this pass.

A few notes:

  • Adding structured counterfactual reasons to repo decisions and scoped snapshots improves explainability without exposing raw private scoring context.
  • The implementation keeps facts, assumptions, and public summaries separated.
  • The focused decision-pack/orchestrator tests cover the new behavior, and CI validate is green.

No code changes are requested from this review pass.

@dosubot dosubot Bot added the lgtm label Jun 4, 2026
@JSONbored
JSONbored self-requested a review June 4, 2026 19:06

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bitloi this remains merge-ready.

A few notes:

  • The counterfactual reason additions are scoped to the decision snapshot behavior.
  • The current branch is locally merge-clean against main.
  • No code changes requested.

Validation expected:

  • Keep the current green CI run after any required branch update.

@JSONbored
JSONbored merged commit f201246 into JSONbored:main Jun 4, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jun 4, 2026
@github-actions github-actions Bot mentioned this pull request Jun 5, 2026
12 tasks
@JSONbored JSONbored added gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. and removed feature labels Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

feat(agent): add counterfactual reasons to decision snapshots

2 participants