Skip to content

feat: install ledger — every plugin/theme install with its door and source (P6.3 phase 2, SiteAgent 2.22.0) - #139

Merged
BenKalsky merged 9 commits into
mainfrom
feat/install-ledger-2-22
Sep 26, 2026
Merged

BenKalsky merged 9 commits into
mainfrom
feat/install-ledger-2-22

Conversation

@BenKalsky

Copy link
Copy Markdown
Member

Implements Plan A of Digitizers/Aura docs/superpowers/plans/2026-09-26-install-ledger-plan-a-siteagent-2-22.md (spec docs/superpowers/specs/2026-09-21-agent-installed-packages-design.md §4).

  • New Aura_Worker_Install_Ledger observes the upgrader for plugin/theme runs only (per-run token in hook_extra; upgrader_pre_download at PHP_INT_MAX; entry at upgrader_install_package_result), records and never decides.
  • Each entry: when, type, action, slug, version (main file), transport (siteagent by SiteAgent's own upgrader object, wp_cli, core auto-update via doing_action('wp_maybe_auto_update') — never the skin, cron, rest, wp_admin), user_id, auth, app-password NAME (never the uuid), route, source.
  • Ring of 200 entries / 90 days in two non-autoloaded options (network options on multisite); purged physically on read and daily (wp_scheduled_delete); every row validated on read; any unreadable storage reports ledger_unreadable and is recovered behind a coverage boundary; write order only ever under-claims coverage. Reactivation restarts coverage; per-site activation on multisite reports ledger_partial_network.
  • audit_agent_code reports it as installs (consumed by Aura #597). Uninstall removes the network rows.
  • Personal data (user_id, app-password name, route) kept by owner decision, ≤90 days / 200 entries.

Tests: 5643 OK (baseline 5544 + 99), phpcs clean on touched files. Built subagent-driven with per-task reviews and a final whole-branch review. Version bump and changelog in the separate release PR.

🤖 Generated with Claude Code

BenKalsky and others added 7 commits September 26, 2026 12:50
…nce computed on read (P6.3 phase 2)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ed out, not corruption; append validates what it stores

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ames, transport, auth, source (P6.3 phase 2)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ndary; failed runs drop their frame

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
….3 phase 2)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…(P6.3 phase 2)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…multisite reports ledger_partial_network; stale read-only claims, dead counter, wire test

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@BenKalsky

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-26T12:15:19.693666Z 8dc8e01 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd0238930a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// ledger.
if ( class_exists( 'Aura_Worker_Install_Ledger' ) ) {
try {
Aura_Worker_Install_Ledger::restart_coverage();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restart the shared network ledger only once

On a network-wide activation, aura_worker_for_each_site() invokes this function once per site, but the ledger state is stored with update_site_option() and is therefore shared by the entire network. The first site creates a clean ledger, while the second and every later site call restart_coverage() on that same ledger, setting evicted: true and moving since again even on a fresh installation where no coverage was lost. Restart the network-scoped ledger once outside the per-site loop, while retaining the per-site behavior for non-network activation.

Useful? React with 👍 / 👎.

Comment on lines +456 to +458
return Aura_Worker_Install_Ledger::as_siteagent( function () use ( $upgrader, $install_source ) {
return $upgrader->install( $install_source, array( 'overwrite_package' => true ) );
}, $upgrader );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the original URL for verified self-updates

When expected_sha256 is supplied, this path first downloads $zip_url and changes $install_source to the temporary file before entering the ledger wrapper. Consequently, upgrader_pre_download sees only that temp path and records source.kind: local_path, losing the actual remote host for every verified self-update. Pass the original source into the ledger correlation so secure self-updates report the CDN or WordPress host they really came from.

Useful? React with 👍 / 👎.

…ctivation; a verified self-update records its real source

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@BenKalsky

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 143de752cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// ledger.
if ( class_exists( 'Aura_Worker_Install_Ledger' ) ) {
try {
Aura_Worker_Install_Ledger::restart_coverage();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restart coverage before per-site activation initializes it

Although the restart was moved outside the per-site loop, it still runs after that loop. On a fresh activation, aura_worker_activate_site() calls aura_worker_maybe_upgrade(), which calls ensure_started() and creates the state and empty ring; this subsequent restart_coverage() therefore treats the fresh ledger as existing and immediately sets evicted: true. This affects both single-site and network-wide fresh activations, falsely reporting that coverage was lost before anything could have been observed.

Useful? React with 👍 / 👎.

Comment on lines +456 to +458
return Aura_Worker_Install_Ledger::as_siteagent( function () use ( $upgrader, $install_source ) {
return $upgrader->install( $install_source, array( 'overwrite_package' => true ) );
}, $upgrader, $zip_url );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Mark SiteAgent self-updates as updates

When self_update() reaches this wrapper, it is replacing the already-installed SiteAgent plugin, but Plugin_Upgrader::install() supplies hook metadata with action: install and no plugin target. Consequently action_of() records every SiteAgent self-update as an install, making the new audit ledger inaccurate for this update path; the wrapper needs to carry an update-action override in addition to the original source URL.

Useful? React with 👍 / 👎.

…itialises the ledger; a self-update records action update

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@BenKalsky

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 8dc8e01ab4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@BenKalsky

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 8dc8e01ab4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@BenKalsky
BenKalsky merged commit 59c601b into main Sep 26, 2026
6 checks passed
@BenKalsky
BenKalsky deleted the feat/install-ledger-2-22 branch September 26, 2026 12:29
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