Skip to content

feat(plugin): /context-guru:cache-campaign builds, shows and switches keep-alive campaigns - #522

Merged
amiddavid merged 1 commit into
mainfrom
port/cache-campaign-command
Oct 15, 2026
Merged

amiddavid merged 1 commit into
mainfrom
port/cache-campaign-command

Conversation

@OsherElhadad

Copy link
Copy Markdown
Collaborator

What

A plugin command over the proxy's campaign routes from #521:

/context-guru:cache-campaign                        latest campaign
/context-guru:cache-campaign build --id TENANT [--builder auto] [--session-end]
/context-guru:cache-campaign show ID [details]
/context-guru:cache-campaign mode ID off|shadow|active [--force]
  • build starts a build and waits up to 80 s, then prints the id to check later.
  • show gives one line: does the plan beat the best fixed rule on this tenant's history, with an interval; details lists every strategy compared and, for the auto builder, the plan that runs next to the fleet's.
  • mode: shadow decides and spends nothing; active is refused unless the build recommended it (--force overrides).
  • Same script in the Codex plugin (show only from Codex).

How to turn it on

Manager only: set CG_DASH_COOKIE to the dashboard login cookie. Without it the routes answer 401 and the command says so. A proxy without the campaign routes (anything before #521) gets a sample screen labelled EXAMPLE, not your data.

How it fails safe

show is read-only. build and mode only call the manager routes, which enforce the ship gate and audit every call. Unreachable proxy, 401/403 and server errors each produce one plain line.

Docs

New docs/plugin/cache-campaign.md, a row in docs/plugin/index.md, mkdocs nav.

Tests

  • go test ./context-guru-plugin pass (cg_campaign_test.go: stub proxy for build/poll, show, details, mode, 409 and 401 paths, older-proxy fallback, Codex copy identical).

@OsherElhadad OsherElhadad left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review: APPROVE at 86638fd. (Posted as a comment: GitHub does not let the author account approve.)

  • This is a port of private #3, reviewed and merged there. The plugin and codex copies of cg.py are byte-identical. go vet is clean and the plugin Campaign tests pass.
  • The PR targets main without #521's routes. Until #521 merges, the command hits a 404 and shows the labelled example, so merging in either order is safe. Merging #521 first gives users the working command straight away.
  • The commit is by Osher-Elhadad, signed off, with no AI attribution. The PR text has no identifiers or figures.

Approved.

@OsherElhadad OsherElhadad left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Re-review: APPROVE at 1ea4e2c. (Posted as a comment: GitHub does not let the author account approve.)

  • allowed-tools now pre-approves only the reads: cache-campaign with no argument, and cache-campaign show:*. build and mode get Claude Code's permission prompt. With the old cg.py:* restored, TestCacheCampaignSkillPreApprovesOnlyReads fails.
  • 7cf6f4b's docs anchor fix and the pointer to /context-guru:adapt cache are fine. The plugin Campaign and Skill tests pass and go vet is clean. Both commits are signed off with no AI attribution.

Nits, non-blocking:

  • cache-campaign details (latest campaign with details) is a read but is not pre-approved.
  • The skill runs python3 "${CLAUDE_PLUGIN_ROOT}/scripts/cg.py" in quotes, but the patterns have no quotes, so a pre-approval may never match. This is pre-existing and the same in every plugin skill; it is worth one live check.

@OsherElhadad OsherElhadad left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Re-review: APPROVE at 0e28b67. It adds cg.py cache-campaign details, a read, to the pre-approvals and updates the test. Only reads are pre-approved: build and mode still get the permission prompt. The plugin Campaign and Skill tests pass. Signed off. This approval covers 0e28b67.

@OsherElhadad OsherElhadad left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Re-review: APPROVE at 11a4aed (0abf0f7 quoted patterns, 11a4aed test). (Posted as a comment: GitHub does not let the author account approve.)

  • Patterns. The patterns are now quoted the way the skill's command line quotes the path: cg.py" cache-campaign (exact), cg.py" cache-campaign details (exact) and cg.py" cache-campaign show:* (prefix). build and mode match none of them, so they still get the permission prompt. TestCacheCampaignSkillPreApprovesOnlyReads bans cg.py:*, cache-campaign:*, build and mode:*, and TestCacheCampaignPatternsCoverTheReadsAndNoWrite checks every read line is covered and no write line is.
  • The open question, no-argument read and a trailing space. In Claude Code 2.1.299 the permission check trims the command first (e.command.trim()) and then compares an exact rule with ===. With an empty $ARGUMENTS, the trailing space from cache-campaign $ARGUMENTS is removed before matching, so the exact cg.py" cache-campaign rule matches. If a client ever left the space in, the only cost would be a permission prompt, never a wider grant.
  • CI is green (build-test, purego, trivy, DCO). Both commits are signed off with no AI attribution.

Approved.

… keep-alive campaigns

A manager command over the proxy's campaign routes (#536):

- build [--builder auto] [--session-end]: start a build for a tenant and wait up to 80 s.
- show [ID] [details]: the verdict against the best fixed rule; details lists every strategy.
- mode ID off|shadow|active [--force]: shadow spends nothing; active needs a ship
  recommendation unless forced.

The routes are manager only: Api.send now sends CG_DASH_COOKIE when set. The command
uses the shared Api.send (a timeout reads "did not answer in time") and the shared --force
flag. The skill pre-approves only its reads (no argument, details, show), quoted the way
the skill runs them; build and mode get the permission prompt. A proxy without the routes
gets a sample screen labelled as an example. Same script in the Codex plugin. Users pick
their own keep-alive strategy with save-more cache; docs/plugin/cache-campaign.md says so.

Signed-off-by: Osher-Elhadad <[email protected]>
@OsherElhadad
OsherElhadad force-pushed the port/cache-campaign-command branch from 11a4aed to daa62af Compare October 15, 2026 11:14

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of the rebase (daa62af)

Verdict: approve.

What I checked

  • Range-diff against the approved 11a4aedb. Every change is a conflict resolution or follows from #526:
    • Api.req is gone. The command uses #526's Api.send. CG_DASH_COOKIE is now sent inside send.
    • A timeout (code == -1) now reads "did not answer in time".
    • --force is the shared flag. The force option moved from campaign{} to the top level.
    • cache-campaign is added to CMDS, not to READS or WRITES.
    • The usage text lists #526's save-more and remove-mcp-and-skills, plus cache-campaign.
    • --mock falls back to a loopback base, merged into #526's base line.
    • The skill and test are new since the approval. They are covered below.
  • Pre-approval. The skill allows three patterns: no argument, details (both exact) and show:*. build and mode match none. I traced the odd inputs (show apply, show revert, show build). None reaches a write. #526 refuses apply and revert under a read command.
  • Nothing lost from #526. KINDS, READS, WRITES, adapt_words and the main-side dispatch are as on main. Docs index and mkdocs.yml hold #526's pages plus Cache campaign. I could not run mkdocs here (not installed).
  • Both cg.py copies are byte-identical. No test enforces this. The Codex skill has no allowed-tools, which is right.

Tests (eval box 1)

  • go test ./context-guru-plugin: ok, 371 s.
  • Mutation: I added a build:* pattern to the skill. TestCacheCampaignSkillPreApprovesOnlyReads and TestCacheCampaignPatternsCoverTheReadsAndNoWrite both failed. I removed the box copy.

No blocking findings.

@amiddavid
amiddavid merged commit 5f159c9 into main Oct 15, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants