Skip to content

Default to using the get tasks API. - #1153

Open
ggreer wants to merge 1 commit into
mainfrom
ggreer/get-tasks-default-true
Open

ggreer wants to merge 1 commit into
mainfrom
ggreer/get-tasks-default-true

Conversation

@ggreer

@ggreer ggreer commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

We added this a while back but never made it the default. This improves performance significantly for service mode connectors that do a lot of grants/revokes, and for service mode connectors that have event feeds.

Comment thread pkg/tasks/c1api/manager.go Outdated
}

func getTasksEnabledFromEnv() bool {
func getTasksDisabledFromEnv() bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: getTasksDisabledFromEnv actually returns whether GetTasks is enabled: unset returns true, BATON_GET_TASKS=false returns false, and the result goes into getTasksEnabled. A reader who trusts the name could write getTasksEnabled: !getTasksDisabledFromEnv() and silently flip the behavior. Consider keeping the old name getTasksEnabledFromEnv with only the default changed. (confidence: high)

Comment thread pkg/tasks/c1api/manager.go Outdated
serviceClient: serviceClient,
taskQueue: newTaskQueue(taskConcurrency),
getTasksEnabled: getTasksEnabledFromEnv(),
getTasksEnabled: getTasksDisabledFromEnv(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: Every service-mode connector now uses GetTasks by default, and there's no fallback to GetTask. TestNextReturnsGetTasksErrorWhenEnabled confirms that Unimplemented comes back as an error, and connectorrunner/runner.go:234-241 then just backs off and retries forever. A connector pointed at a C1 endpoint or proxy that doesn't serve GetTasks would stop picking up tasks and only log errors. Consider falling back to GetTask on codes.Unimplemented, or at least documenting BATON_GET_TASKS=false as the opt-out in the PR/release notes. (confidence: medium)

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor
Superseded — see the current review report for commit 2f63d275e5c8

General PR Review: Default to using the get tasks API.

Blocking Issues: 0 | Suggestions: 3 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base 3df6fad597fd.
Review mode: full
View review run

Review Summary

This PR changes the default of BATON_GET_TASKS in pkg/tasks/c1api/manager.go. The batched GetTasks polling path used to be opt-in. Now it's on when the variable is unset or can't be parsed, and it's off only when the variable is set to false. Tests that exercise the single-task GetTask path now set BATON_GET_TASKS=false. The GetTasks tests no longer set the variable, so they now cover the new default. I scanned the full diff for security and correctness issues and found none; the env parsing produces the intended behavior.

I applied the repo-local criteria's Defaults and Versioning sections, since this change flips a default. Risk triage:

  • Silence: partial. Errors are logged, but the runner retries forever without failing.
  • Durability: no.
  • Uncontrolled dimensions: yes. It depends on whether the C1 endpoint serves GetTasks.
  • Consumer distance: every service-mode connector.
  • Consequence: redeploy, or set the env var (rung 1).

That version-pair dependence makes the verdict nominally HIGH, but the env-var escape hatch keeps remediation cheap.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

  • New pkg/tasks/c1api/manager.go:296: getTasksDisabledFromEnv returns the enabled state (unset returns true, false returns false) and is assigned to getTasksEnabled. The inverted name invites a wrong ! at future call sites. (confidence: high)
  • New pkg/tasks/c1api/manager.go:528: The new default has no fallback to GetTask on codes.Unimplemented. runner.go:234-241 just backs off and retries, so a connector talking to an endpoint without GetTasks would stop processing tasks and only log errors. Add a fallback, or document the BATON_GET_TASKS=false opt-out. (confidence: medium)
  • New pkg/sdk/version.go:3: The Versioning criteria require default-behavior changes that affect connectors to be signalled in the version and PR, but the version wasn't bumped (v0.32.2) and the PR has no rollout or opt-out note. (confidence: medium)
Prompt for AI agents
Verify each finding against the current code and only fix it if needed.

## Suggestions

In `pkg/tasks/c1api/manager.go`:
- Around line 296-306: `getTasksDisabledFromEnv` returns true when GetTasks should be enabled. Rename it back to `getTasksEnabledFromEnv`, keep the new default (true when unset or unparseable), and update the call sites at line 528 and in manager_test.go `newTestManager`.
- Around line 219-290 / 528: With GetTasks now the default, handle `codes.Unimplemented` from `serviceClient.GetTasks` by falling back to the `GetTask` path, for example by setting `c.getTasksEnabled = false` and retrying via GetTask. Add a test for the fallback. If you don't want a fallback, document `BATON_GET_TASKS=false` as the opt-out in the PR description or release notes.

In `pkg/sdk/version.go`:
- Around line 3: Bump the SDK version to signal the default-behavior change, and add a rollout note that mentions the `BATON_GET_TASKS=false` opt-out.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor
Superseded — see the current review report for commit 476bfa6e6bdc

General PR Review: Default to using the get tasks API.

Blocking Issues: 0 | Suggestions: 3 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base 3df6fad597fd.
Review mode: full
View review run

Review Summary

This PR changes the default of BATON_GET_TASKS in pkg/tasks/c1api/manager.go. The batched GetTasks polling path used to be opt-in. Now it's on when the variable is unset or can't be parsed, and it's off only when the variable is set to false. Tests that exercise the single-task GetTask path now set BATON_GET_TASKS=false. The GetTasks tests no longer set the variable, so they now cover the new default. I scanned the full diff for security and correctness issues and found none; the env parsing produces the intended behavior.

I applied the repo-local criteria's Defaults and Versioning sections, since this change flips a default. Risk triage:

  • Silence: partial. Errors are logged, but the runner retries forever without failing.
  • Durability: no.
  • Uncontrolled dimensions: yes. It depends on whether the C1 endpoint serves GetTasks.
  • Consumer distance: every service-mode connector.
  • Consequence: redeploy, or set the env var (rung 1).

That version-pair dependence makes the verdict nominally HIGH, but the env-var escape hatch keeps remediation cheap.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

  • New pkg/tasks/c1api/manager.go:296: getTasksDisabledFromEnv returns the enabled state (unset returns true, false returns false) and is assigned to getTasksEnabled. The inverted name invites a wrong ! at future call sites. (confidence: high)
  • New pkg/tasks/c1api/manager.go:528: The new default has no fallback to GetTask on codes.Unimplemented. runner.go:234-241 just backs off and retries, so a connector talking to an endpoint without GetTasks would stop processing tasks and only log errors. Add a fallback, or document the BATON_GET_TASKS=false opt-out. (confidence: medium)
  • New pkg/sdk/version.go:3: The Versioning criteria require default-behavior changes that affect connectors to be signalled in the version and PR, but the version wasn't bumped (v0.32.2) and the PR has no rollout or opt-out note. (confidence: medium)
Prompt for AI agents
Verify each finding against the current code and only fix it if needed.

## Suggestions

In `pkg/tasks/c1api/manager.go`:
- Around line 296-306: `getTasksDisabledFromEnv` returns true when GetTasks should be enabled. Rename it back to `getTasksEnabledFromEnv`, keep the new default (true when unset or unparseable), and update the call sites at line 528 and in manager_test.go `newTestManager`.
- Around line 219-290 / 528: With GetTasks now the default, handle `codes.Unimplemented` from `serviceClient.GetTasks` by falling back to the `GetTask` path, for example by setting `c.getTasksEnabled = false` and retrying via GetTask. Add a test for the fallback. If you don't want a fallback, document `BATON_GET_TASKS=false` as the opt-out in the PR description or release notes.

In `pkg/sdk/version.go`:
- Around line 3: Bump the SDK version to signal the default-behavior change, and add a rollout note that mentions the `BATON_GET_TASKS=false` opt-out.

Reviewed commit: 2f63d275e5c8

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blocking issues found — see the full review report

We added this a while back but never made it the default. This improves performance significantly for connectors that do a lot of grants/revokes, and for event feeds.
@ggreer
ggreer force-pushed the ggreer/get-tasks-default-true branch from 2f63d27 to 476bfa6 Compare September 25, 2026 20:51
raw, ok := os.LookupEnv(getTasksEnv)
if !ok {
return false
return true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion (prior, still present; confidence: medium): GetTasks is now on by default for every service-mode connector, and there's no fallback to GetTask when the server returns codes.Unimplemented. Next returns the error (manager.go:276-279) and runner.go:234-241 just backs off and retries forever, so against an endpoint without GetTasks the connector stops processing tasks. You could fall back by setting c.getTasksEnabled = false on Unimplemented, or at least document BATON_GET_TASKS=false as the opt-out.

enabled, err := strconv.ParseBool(raw)
if err != nil {
return false
return true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion (confidence: medium): Unparseable values now fall back to enabled. So an operator who tries to opt out with BATON_GET_TASKS=no or =off (which strconv.ParseBool rejects) silently gets GetTasks. Log a warning on the parse error, or default to false when the variable is set but invalid, since setting it at all signals intent to change the default.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor
Superseded — see the current review report for commit 476bfa6e6bdc

General PR Review: Default to using the get tasks API.

Blocking Issues: 0 | Suggestions: 3 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base 3df6fad597fd.
Review mode: full
View review run

Review Summary

The PR flips getTasksEnabledFromEnv (pkg/tasks/c1api/manager.go:296-306) so that service-mode connectors use the batched GetTasks path by default. That now happens when BATON_GET_TASKS is unset or unparseable; BATON_GET_TASKS=false is the only way back to single GetTask polling. The tests now pin disableGetTasks on the legacy-path cases and drop enableGetTasks from the batch cases, so both paths stay covered. I scanned the full diff for security and correctness issues.

I applied the repo-local criteria:

  • Risk triage:
    • Silence: partial. Failures are logged errors, not silent wrong data.
    • Durability: no. No c1z, token or wire change.
    • Uncontrolled dimensions: yes. Behavior depends on whether the server implements GetTasks.
    • Consumer distance: yes. Every downstream service-mode connector picks this up on upgrade.
    • Remediation: redeploy with the env var set (rung 1).
    • Verdict: MEDIUM.
  • Defaults and Versioning: this is a deliberate default-behavior change, which drives the suggestions below.
  • Other areas: no exported API, proto, serialized-state or dependency changes.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

  • Prior — still present pkg/tasks/c1api/manager.go:263-279: There is no fallback to GetTask on codes.Unimplemented from GetTasks. Next returns the error when the queue is empty, and pkg/connectorrunner/runner.go:234-241 backs off and retries indefinitely. Against an endpoint lacking GetTasks, task processing would stop, with only error logs. TestNextReturnsGetTasksErrorWhenEnabled confirms this behavior. (confidence: medium)
  • New pkg/tasks/c1api/manager.go:301-304: An unparseable BATON_GET_TASKS value (for example no or off) now enables GetTasks, so a failed opt-out attempt silently gets the new behavior. (confidence: medium)
  • Prior — still present pkg/sdk/version.go:3: The default-behavior change isn't signalled. The version is still v0.32.2 and the PR body has no rollout or opt-out note mentioning BATON_GET_TASKS=false, which the repo's Defaults/Versioning criteria ask for. (confidence: medium)

Resolved prior findings

  • The inverted-name concern (getTasksDisabledFromEnv returning the enabled state) is fixed: the function is named getTasksEnabledFromEnv at pkg/tasks/c1api/manager.go:296 and at the call sites manager.go:528 and manager_test.go:128.
Prompt for AI agents
Verify each finding against the current code and only fix it if needed.

## Suggestions

In `pkg/tasks/c1api/manager.go`:
- Around line 263-279: When `c.serviceClient.GetTasks` returns a gRPC status with `codes.Unimplemented`, fall back to the legacy path. Set `c.getTasksEnabled = false`, log a warning, and service this call via `GetTask`. Update `TestNextReturnsGetTasksErrorWhenEnabled` to assert the fallback. If you don't want a fallback, document `BATON_GET_TASKS=false` as the opt-out in the PR description or release notes.
- Around line 301-304: When `strconv.ParseBool` fails on a set `BATON_GET_TASKS` value, log a warning naming the invalid value. Consider returning false in that case, since the operator explicitly set the variable, and only default to true when it is unset.

In `pkg/sdk/version.go`:
- Around line 3: Bump the SDK version to signal the default change to GetTasks. Add a rollout note to the PR describing the new default and the `BATON_GET_TASKS=false` opt-out.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

General PR Review: Default to using the get tasks API.

Blocking Issues: 0 | Suggestions: 3 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base 3df6fad597fd.
Review mode: full
View review run

Review Summary

The PR flips getTasksEnabledFromEnv (pkg/tasks/c1api/manager.go:296-306) so that service-mode connectors use the batched GetTasks path by default. That now happens when BATON_GET_TASKS is unset or unparseable; BATON_GET_TASKS=false is the only way back to single GetTask polling. The tests now pin disableGetTasks on the legacy-path cases and drop enableGetTasks from the batch cases, so both paths stay covered. I scanned the full diff for security and correctness issues.

I applied the repo-local criteria:

  • Risk triage:
    • Silence: partial. Failures are logged errors, not silent wrong data.
    • Durability: no. No c1z, token or wire change.
    • Uncontrolled dimensions: yes. Behavior depends on whether the server implements GetTasks.
    • Consumer distance: yes. Every downstream service-mode connector picks this up on upgrade.
    • Remediation: redeploy with the env var set (rung 1).
    • Verdict: MEDIUM.
  • Defaults and Versioning: this is a deliberate default-behavior change, which drives the suggestions below.
  • Other areas: no exported API, proto, serialized-state or dependency changes.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

  • Prior — still present pkg/tasks/c1api/manager.go:263-279: There is no fallback to GetTask on codes.Unimplemented from GetTasks. Next returns the error when the queue is empty, and pkg/connectorrunner/runner.go:234-241 backs off and retries indefinitely. Against an endpoint lacking GetTasks, task processing would stop, with only error logs. TestNextReturnsGetTasksErrorWhenEnabled confirms this behavior. (confidence: medium)
  • New pkg/tasks/c1api/manager.go:301-304: An unparseable BATON_GET_TASKS value (for example no or off) now enables GetTasks, so a failed opt-out attempt silently gets the new behavior. (confidence: medium)
  • Prior — still present pkg/sdk/version.go:3: The default-behavior change isn't signalled. The version is still v0.32.2 and the PR body has no rollout or opt-out note mentioning BATON_GET_TASKS=false, which the repo's Defaults/Versioning criteria ask for. (confidence: medium)

Resolved prior findings

  • The inverted-name concern (getTasksDisabledFromEnv returning the enabled state) is fixed: the function is named getTasksEnabledFromEnv at pkg/tasks/c1api/manager.go:296 and at the call sites manager.go:528 and manager_test.go:128.
Prompt for AI agents
Verify each finding against the current code and only fix it if needed.

## Suggestions

In `pkg/tasks/c1api/manager.go`:
- Around line 263-279: When `c.serviceClient.GetTasks` returns a gRPC status with `codes.Unimplemented`, fall back to the legacy path. Set `c.getTasksEnabled = false`, log a warning, and service this call via `GetTask`. Update `TestNextReturnsGetTasksErrorWhenEnabled` to assert the fallback. If you don't want a fallback, document `BATON_GET_TASKS=false` as the opt-out in the PR description or release notes.
- Around line 301-304: When `strconv.ParseBool` fails on a set `BATON_GET_TASKS` value, log a warning naming the invalid value. Consider returning false in that case, since the operator explicitly set the variable, and only default to true when it is unset.

In `pkg/sdk/version.go`:
- Around line 3: Bump the SDK version to signal the default change to GetTasks. Add a rollout note to the PR describing the new default and the `BATON_GET_TASKS=false` opt-out.

Reviewed commit: 476bfa6e6bdc

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blocking issues found — see the full review report

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