Skip to content

fix: filter resolved beans from blocked_by/blocking in JSON output (Refs: beans-k0as)#175

Open
SamLeatherdale wants to merge 1 commit intohmans:mainfrom
SamLeatherdale:fix/beans-k0as-filter-resolved-blockers-from-json-output
Open

fix: filter resolved beans from blocked_by/blocking in JSON output (Refs: beans-k0as)#175
SamLeatherdale wants to merge 1 commit intohmans:mainfrom
SamLeatherdale:fix/beans-k0as-filter-resolved-blockers-from-json-output

Conversation

@SamLeatherdale
Copy link

Problem

The blocked_by and blocking arrays in CLI JSON output (beans show --json, beans list --json) and the GraphQL blockingIds/blockedByIds fields return raw frontmatter — they include bean IDs regardless of whether those referenced beans are already completed or scrapped.

This causes agents and scripts to misread a bean as still blocked when all its blockers are already done. For example, a bean with:

"blocked_by": ["beans-b622", "beans-4kki"]

will look blocked to an agent even if both b622 and 4kki have status: completed. The agent has no way to know the dependency is resolved without fetching each blocker individually.

The runtime --ready filter (via findActiveBlockersLocked) already correctly ignores resolved blockers when deciding which beans are available to work on — but the serialized output was not aligned with this behaviour, creating a confusing inconsistency.

This is related to #68.

Fix

Added ActiveBlockedByIds and ActiveBlockingIds methods on Core that walk the frontmatter ID lists and exclude any entries whose referenced beans are completed or scrapped, reusing the existing isResolvedStatus check. Applied in:

  • BeanBlockedByIds / BeanBlockingIds GraphQL resolvers
  • beans show --json and beans list --json CLI output

After the fix, a bean whose blockers are all completed will have an empty (omitted) blocked_by field in JSON, making its unblocked state immediately clear.

Test plan

  • beans show --json <id> for a bean with only completed blockers shows no blocked_by field
  • beans list --json similarly omits resolved blocker IDs
  • beans show --json <id> for a bean with a mix of active and completed blockers shows only the active blocker IDs
  • Unit tests for ActiveBlockedByIds and ActiveBlockingIds pass (go test ./pkg/beancore/...)

Refs: beans-k0as

Made with Cursor

- Add `ActiveBlockedByIds` and `ActiveBlockingIds` methods on `Core`
  that exclude completed/scrapped beans using the existing
  `isResolvedStatus` check
- Apply filtering in `BeanBlockedByIds` and `BeanBlockingIds` GraphQL
  resolvers so the API reflects live blockers only
- Apply filtering in `beans show --json` and `beans list --json` before
  serialization so CLI consumers see the same filtered view
- Add tests for both new Core methods

Refs: beans-k0as
Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant