Commit Graph

32 Commits

Author SHA1 Message Date
peptiderepo
1bf4754f26 ci: remove advisory CTO Review (Haiku) workflow
Advisory, non-gating PR reviewer superseded by the independent qa-review deploy gate. Removes redundant OpenRouter (Claude Haiku) spend. CEO directive 2026-06-23.

Agent-Session: remove-cto-review-20260623
2026-06-23 18:12:56 +07:00
peptiderepo
f1c5a295a4 ci: fix peptide-e2e org ref + deploy.yml permissions (#31)
Fix stale peptiderepo/peptide-e2e refs.

Agent-Session: fix-e2e-ref-20260617
2026-06-17 11:37:57 +07:00
peptiderepo
ff474326fb Adopt reusable CI standard (#30)
Squash-merged from claude/adopt-ci-20260616.

QA-approved; all CI checks green on 3b4e3f04.

Agent-Session: deploy-ci-rollout-news-plugin-2026-06-16
2026-06-16 21:30:24 +07:00
peptiderepo
3cb9ffb70d ci(review): drop multi-model panel to Haiku-only (#29)
QA A/B decision 2026-06-12 (CEO-ratified): Haiku-only. Evidence: convo/cto/threads/2026-06-qa-ab-review/. QA verdict per repo in qa-reviews/.

Agent-Session: cto-panel-merge-20260612
2026-06-12 21:53:41 +07:00
peptiderepo
0b247646ca ci: adopt shared reusable deploy workflow (#28)
Replaces the per-repo staging/smoke/production jobs with one call to
peptiderepo/peptide-e2e/.github/workflows/deploy-app.yml (target_path=wp-content/plugins/peptide-news-plugin).
Validated end-to-end on the calculator pilot.

Agent-Session: cto rollout-reusable-deploy
2026-06-09 19:15:58 +07:00
peptiderepo
1dfd926437 ci(audit): retry PR-association check (#27)
listPullRequestsAssociatedWithCommit is eventually-consistent after a squash
merge; the single immediate call intermittently flagged legit merges as
'direct push to main'. Now polls up to 5x/10s before opening an issue.

Agent-Session: cto audit-race-fix
2026-06-09 13:39:15 +07:00
peptiderepo
e1d21631ce ci: restore deploy pipeline (#26)
Same 0-job-failure fix as prautoblogger #147 / prcore #14.

Agent-Session: cto restore-deploy-org-sweep
2026-06-09 13:27:08 +07:00
peptiderepo
bb8b6f037f ci: make smoke gate informational (#25)
Smoke runs but does not block prod promotion until triage completes.

Agent-Session: cto batch-merge-smoke-informational
2026-05-14 21:00:56 +07:00
peptiderepo
57051167fe ci: migrate to rsync deploy, fix concurrency group, add smoke gate 2026-04-26 11:55:56 +07:00
peptiderepo
f5b3690495 ci: standardize PHP matrix to 8.1/8.2/8.3, PHPCS continue-on-error 2026-04-26 11:55:55 +07:00
peptiderepo
f6156d723b fix(ci): treat phpcs exit 2 (warnings-only) as success
PHPCS exits 2 when there are warnings but no errors. The ruleset already
downgrades known pre-existing patterns to <type>warning</type>. CI should
fail only on exit 1 (actual errors).
2026-04-24 06:21:13 +00:00
peptiderepo
6988a1fe7b fix(ci): move ignore_warnings_on_exit into phpcs.xml.dist to unblock pipeline
--runtime-set ignore_warnings_on_exit 1 in ci.yml was not taking effect;
pipeline has been failing on PHPCS warnings since run #76 despite all
violations being intentionally downgraded to <type>warning</type>.

Fix: add <config name="ignore_warnings_on_exit" value="1"/> directly
to .phpcs.xml.dist so it is applied at the ruleset level.
2026-04-24 06:19:06 +00:00
peptiderepo
83a5c3b5ca ci: add staging deploy step + production approval gate 2026-04-24 13:12:41 +07:00
peptiderepo
9be13a089d ci(cto-review): add app-map freshness check to QA gate (#16)
When a PR modifies the admin settings surface, file/class structure, or data flow, the QA reviewer now flags the PR as a MAJOR concern unless the PR description references an accompanying update to the CTO app-map at `Peptide Repo CTO/app-maps/<repo-slug>.md`.

The CTO workspace is a separate repo, so CI cannot verify the doc update mechanically — the reviewer inspects the PR description for an explicit mention.

Why: the CTO-level app-maps are the single-pane-of-glass reference that lets the CTO answer questions like 'which settings does this plugin expose?' without grepping the repo each time. Without a merge-gate prompt, these maps drift out of sync with the code.

Co-authored-by: peptiderepo <peptiderepo@users.noreply.github.com>
2026-04-22 18:33:29 +07:00
peptiderepo
d65862504e feat(ci): add Neurometric PR-Summarizer as 4th QA voice (#6)
Neurometric markets a task-specialized PR-Summarizer SLM (Qwen3-4B +
specialist system prompt) on a free tier. Adding it as a 4th voice in
the existing A/B reviewer panel to see whether a specialized small
model catches things the 3 general-purpose voices miss.

The SLM does not honor OpenAI tool-calling, so it cannot return our
structured submit_review schema. Wired as a "prose voice":

- MODELS tuple gains a 6th provider_type field
  ("openrouter_tools" | "neurometric_prose")
- call_model() dispatches; new call_neurometric_prose() path hits
  api.neurometric.ai/v1 without tools, embeds raw markdown output,
  and infers verdict from keyword heuristic
- Render branch in PR comment marks the verdict as heuristic and
  notes tokens/cost are not tracked (free tier)
- Never the primary voice; heading still driven by Haiku

Also hardens the shared render path against models that omit the
optional 'summary' field (rev.get('summary') fallback).

Requires new repo secret NEUROMETRIC_API_KEY (already set on all four
peptiderepo repos). Voice self-skips with inline error if missing.

Agent-Session: cowork-neurometric-qa-voice-20260415

Co-authored-by: peptiderepo <peptiderepo@users.noreply.github.com>
2026-04-15 16:12:02 +07:00
peptiderepo
e1efc20237 ci: reviewer cost cap + 3-model A/B harness (#4)
* ci: cost cap + 3-model A/B harness on CTO reviewer

Two enhancements to the PR reviewer:

1. Monthly spend cap: tracked in Repo Variables (CTO_REVIEW_MONTH,
   CTO_REVIEW_SPEND_CENTS, CTO_REVIEW_CAP_CENTS). Default cap $10/month.
   Auto-resets on month rollover. Posts a skip-comment on PRs when cap hit.

2. A/B harness: reviews every PR with 3 models in parallel
   (Claude Haiku 4.5, DeepSeek V3.1, Kimi K2 Thinking). Comment shows
   all 3 verdicts side-by-side so we can compare quality/cost on real
   PRs before picking a permanent default. Drop to 1 model by editing
   the MODELS list after A/B window closes.

Agent-Session: cowork-reviewer-ab-20260414

* ci: use CTO_ADMIN_TOKEN for repo variables + restore formal APPROVE/REQUEST_CHANGES

Default GITHUB_TOKEN cannot mutate Repository Variables (always 403).
Use a PAT-backed secret CTO_ADMIN_TOKEN for the budget counter steps.
Also restores formal APPROVE/REQUEST_CHANGES verdicts now that repo
setting can_approve_pull_request_reviews is enabled.

Agent-Session: cowork-reviewer-ab-20260414

* ci: address review feedback — per-model timeout + simpler cost math

- Per-model timeout of 60s so one hung model does not block siblings
- Simplify cost_cents math (cost_usd * 100 directly, no double-rounding)

Defer: fine-grained PAT for CTO_ADMIN_TOKEN (requires manual OAuth device flow).

Agent-Session: cowork-reviewer-ab-20260414

* ci: stop exposing CTO_ADMIN_TOKEN as env var (security cleanup)

Pass the PAT only via github-token param. continue-on-error on the
budget step so a missing/expired secret degrades gracefully instead
of failing the whole workflow.

Agent-Session: cowork-reviewer-ab-20260414
2026-04-14 17:35:08 +07:00
peptiderepo
0b1049ac73 ci: post CTO review as COMMENT instead of APPROVE (#3)
GITHUB_TOKEN cannot formally approve PRs without a repo setting toggle.
Verdict is still prominent in the first line of the review body, and
the human merges based on reading it — no behavior loss.

Agent-Session: cowork-reviewer-fix-20260414
2026-04-14 16:53:14 +07:00
peptiderepo
352db67ac4 ci: add review gate (tripwire audit + Claude auto-review via OpenRouter) (#2)
* ci: add main-push audit tripwire

Flags direct pushes to main that did not come from a merged PR.
Free-plan workaround since branch protection requires GitHub Pro.

* docs: add Git Workflow section to CONVENTIONS.md

Documents the PR-gated review process enforced at the agent layer.
Free-plan workaround since branch protection requires GitHub Pro.

* ci: add Claude-powered CTO PR review workflow

Auto-reviews every PR with Claude Haiku 4.5 and posts a structured
review (APPROVE / REQUEST_CHANGES / COMMENT). Does NOT auto-merge — a
human still clicks Merge. Requires ANTHROPIC_API_KEY secret on the repo.

* ci: switch CTO reviewer from Anthropic direct to OpenRouter

Reuses the OPENROUTER_API_KEY secret that already backs the other AI
plugins. Consolidates AI spend on one bill. Model: anthropic/claude-haiku-4.5.
2026-04-14 16:45:51 +07:00
Terence
b7da4f42b9 feat: add LLM cost tracking with budget enforcement and admin dashboard
- New Cost_Tracker class: logs every API call (model, tokens, cost), enforces
  monthly budgets with hard-stop mode, provides aggregated reporting
- New llm_costs database table with indexes on created_at, model, operation
- Modified LLM class: call_openrouter_with_usage() extracts token usage from
  OpenRouter responses; budget gate checks before each API call
- Admin settings: monthly budget (USD), enforcement mode (disabled/warn/hard-stop),
  cost log retention period
- Admin cost dashboard: budget progress bar, daily cost chart (Chart.js),
  per-model and per-operation breakdowns, recent API call log
- PHPUnit tests: 16 tests covering cost calculation, pricing lookups,
  budget enforcement logic, and model validation
- Updated ARCHITECTURE.md with new table schema, data flow, and key decisions
- Updated CONVENTIONS.md with "how to add cost tracking for a new operation"
- Version bump to 2.4.0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 04:18:30 +07:00
peptiderepo
6796121003 fix: tell PHPCS to ignore warnings on exit in CI
PHPCS exits with code 2 when fixable violations exist, even if they
are all warnings (0 errors). Add --runtime-set ignore_warnings_on_exit 1
so that warnings are still displayed but don't fail the CI job.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-12 17:28:46 +07:00
peptiderepo
3bd320dcef chore: remove stale peptide-news-plugin/ nested directory
The nested peptide-news-plugin/ directory was a leftover from the old
manual zip-based deployment approach. The CI/CD pipeline (deploy.yml)
checks out files directly from main into the deploy branch and never
references this directory. Removing it to eliminate confusion and
reduce repo size.

Also cleans up CI exclusion patterns in ci.yml and .phpcs.xml.dist
that were skipping this directory during linting/testing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-12 16:54:01 +07:00
Terence Ong
d78347de40 fix: update CI security audit and lint exclusions for new files
- Exclude uninstall.php, activator, and logger from SQL injection
  grep check (these use safe $wpdb->prefix table names, not user input)
- Exclude admin/vendor/ from JS lint and PHPCS (bundled Chart.js)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 11:52:36 +07:00
Terence Ong
32e21bc59d fix: comprehensive code quality remediation from audit findings
Security (7 fixes):
- SEC-001: Use wpdb->prepare() for COUNT query in REST API
- SEC-002: Set httponly=true on session cookie to prevent XSS
- SEC-003: Mask API keys in admin settings (show last 4 chars only)
- SEC-004: Check capability before nonce in manual fetch handler
- SEC-005: Validate redirect domains to prevent open redirects
- SEC-006: Escape all article fields before REST API response
- SEC-007: Add capability check to AJAX summary handler

Infrastructure (7 fixes):
- WPS-002: Clear cron schedule on plugin deactivation
- WPS-003: Bundle Chart.js locally instead of CDN without SRI
- WPS-004: Add uninstall.php for clean plugin removal
- DB-001: Add foreign key constraints with CASCADE deletes
- DB-002: Clamp pagination to valid page range
- CI-001: Use StrictHostKeyChecking=accept-new in deploy
- CI-002: Add security scanning step to CI pipeline
- CI-003: Add rollback workflow via workflow_dispatch

Performance & Quality (8 fixes):
- PHP-001: Validate widget $instance as array before access
- PHP-002: Return null from get_client_ip() for invalid IPs
- PHP-003: Process RSS feeds in chunked batches of 10
- PHP-004: Wire up clear_article_cache() in fetch cycle
- PERF-001: Cache source names in transient for strip_source_suffix
- PERF-002: Add server-side transient caching for REST API
- ARCH-002: Make LLM API URL configurable via WordPress options

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 11:47:43 +07:00
Terence Ong
31df32da2d fix: make ssh-keyscan non-fatal in deploy workflow
ssh-keyscan can fail transiently; since rsync already uses
StrictHostKeyChecking=no, the keyscan is best-effort only.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 10:40:49 +07:00
Terence Ong
c13919c217 fix: switch plugin deploy from git-pull to rsync
The git-pull deploy failed silently because Hostinger doesn't have SSH
keys to access the private GitHub repo. Switched to rsync from the GH
Actions runner (same proven approach as the theme repo), which avoids
needing git access on the server entirely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 10:34:17 +07:00
peptiderepo
d86a259693 fix: add ssh-keyscan for GitHub host key verification 2026-04-07 12:46:45 +07:00
peptiderepo
ce05735544 Replace Hostinger GIT integration with SSH direct deploy
Hostinger GIT integration has a persistent backend bug that prevents using the correct plugin directory name. This replaces it with SSH-based deployment:

- Sync deploy branch with clean plugin runtime files
- SSH into Hostinger and git pull deploy branch directly
- Purge LiteSpeed cache after successful deploy
2026-04-07 12:43:09 +07:00
Terence Ong
0b29059463 fix: use linear history for deploy branch instead of orphan/force-push
Hostinger's git pull fails with divergent branches when force-pushing
orphan commits. Switch to a linear commit strategy: checkout the
existing deploy branch, sync plugin files from main, and push normally.
This keeps Hostinger's git pull fast-forward compatible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 15:14:19 +07:00
Terence Ong
1304d205fa refactor: switch deploy to Hostinger GIT pull-based strategy
Replace broken SCP/SSH deploy (blocked by Hostinger firewall) with a
deploy-branch strategy. After CI passes, GitHub Actions pushes only
plugin files to the 'deploy' branch. Hostinger's built-in GIT
integration watches this branch via webhook and auto-pulls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 15:06:18 +07:00
Terence Ong
61d06c10c4 Switch deploy from FTP to SSH/SCP for Hostinger compatibility
FTP deploy timed out due to Hostinger blocking FTPS from external CI
servers. Switched to appleboy/scp-action using SSH on port 65002,
which is more reliable for CI/CD pipelines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 14:48:50 +07:00
Terence Ong
b9d14cbb59 Add workflow_call trigger to CI for reusable workflow support
The deploy workflow references CI via `uses: ./.github/workflows/ci.yml`
which requires the CI workflow to have an `on: workflow_call` trigger.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 14:35:27 +07:00
Terence Ong
849ffa1260 Add CI/CD pipeline with automated testing and SFTP deployment
Introduces GitHub Actions workflows for continuous integration and
deployment. CI runs PHP linting (7.4, 8.1, 8.3), PHPCS with WordPress
coding standards, PHPUnit tests across PHP versions, and JS syntax
checks. Deployment to Hostinger via FTPS triggers on push to main
after all CI checks pass, with optional LiteSpeed cache purge.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 13:41:47 +07:00