-
Notifications
You must be signed in to change notification settings - Fork 0
Claude/plan v3 deployment vp mpw #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c3ce323
1c1d19c
92e93e6
3d4befe
41c2083
c279f5f
81ff2af
86a6e1d
b6e211c
5c27692
efe20d6
6ab6734
49efa74
ee1184c
ad306be
c865189
f0f53aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -402,4 +402,37 @@ Mandatory rules for any AI agent touching this repo: | |
| - 2026-02-27: Added QA tester scaffolding (`qa/context/bot_capabilities.json`, `qa/context/repo_info.json`, `qa/state/provider_status.json`, `qa/README_QA.md`), with runtime refresh via `/qa_*` commands and 10-minute provider cooldown reset. | ||
| - 2026-02-27: Hardened SSHV Run prompt flow so admin text in private DM executes against active SSHV sessions if pending state desynchronizes. | ||
| - 2026-02-28: v3.1 — added group command guard middleware (`GROUP_PASSTHROUGH_COMMANDS` + `bot.use` interceptor); added `onboardingProgressBar()` and progress header on each onboarding step prompt (auto-deletes after 8s); added one-time onboarding completion card (tracked via `user.onboarding.completionCardShown`); added `🔗 Group Linking` to Admin System Tools keyboard (`admin_sys_group_linking` callback with back-to-system-tools navigation). | ||
| - 2026-03-01: Created `docs/` feature documentation system — 15 per-feature `.md` files, central `docs/INDEX.md` with full callback + pending-action cross-reference, and `docs/TODO_FUNCTIONALITY_UPGRADE.md` tracking 14 open upgrade/stale-menu items. Future Claude sessions must consult `docs/INDEX.md` first, then the relevant feature `.md`, before reading `index.js`. | ||
| - 2026-03-01: Phase implementation — resolved T-01/T-02/T-03/T-15 from TODO list. (1) Walkthrough: `sendWalkthroughStep()` upgraded with `clearOldMenus()`, Back disabled on step 1, Finish on last step, `walk_done` on last step returns to main menu. New doc: `16-walkthrough.md`. (2) Menu stacking: `clearOldMenus()` added to `sendOnboardingReferralPrompt`, `renderSshvConsole`, `renderGroupLinkingTools`, `tips_cmd_edit`, `tips_cmd_remove`. (3) Tooltip view: `tips_cmd_view` selector + `tip_view_{id}` handler with Prev/Next/Edit/Toggle/Delete/Back/AdminMenu — "👁 View Tooltip" button added to dashboard. (4) Broadcast failures: 500-item cap removed; all failures logged via `adminLog()`; `/broadcast_failed` shows chunks of 30 with overflow note; >20% failure rate triggers admin DM warnings. PR comments fixed: `add_tooltip.sh` array validation hardened; `docs/12-group-linking.md` entry-point callback corrected to `admin_sys_group_linking`; merge conflicts (PRs #112-114) resolved keeping SIGTERM→SIGKILL safety improvements. 60/60 tests pass. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix broadcast-failure retention contradiction in the authoritative map. Line 406 says the 500-item cap was removed, but the earlier safety section says failure tracking caps exist to bound memory growth. Keep one consistent statement, or explicitly document current retention policy. As per coding guidelines: "RUNEWAGER_FUNCTIONALITY_MAP.md: Always treat RUNEWAGER_FUNCTIONALITY_MAP.md as the authoritative source of truth before and after code changes". 🤖 Prompt for AI Agents |
||
| - 2026-02-28: PR #112 review + audit pass — fixed 10 issues: (R1) `await_tip_import_batch` dedicated pending type with JSON-array router; (R2) `generate_tooltips.sh` command-substitution pollution fixed via `RUNEWAGER_APP` env var; (R3) `add_tooltip.sh` shell-injection fixed via `TOOLTIP_TEXT_ENV`/`TOOLTIP_TMP_FILE` env vars and `<<'EOF'`; (R4) `catchAllCases` test extended with multiline patterns + `CATCH_ALL_CORES` updated; (R5) `extractCommandHandlerNames` test extended with `let`/`var`/no-semicolon fixtures; (R6) typo "auto-deletes 8s" → "auto-deletes after 8s"; (A1) dead `buildGiveawayAnnouncementText(giveaway,remainingStr)` removed; (A2) simplified `buildGiveawayAnnouncementKeyboard` with wrong callback removed; (A3+A4) duplicate `bot.action('admin_cat_system')` and `bot.action('admin_cat_support')` first registrations removed. All 60 tests pass. | ||
|
|
||
| --- | ||
|
|
||
| ## 26. Feature Documentation System | ||
|
|
||
| > **For all Claude sessions: start here, not by searching `index.js`.** | ||
|
|
||
| All bot functionality is documented in `docs/`: | ||
|
|
||
| | File | Contents | | ||
| |------|---------| | ||
| | [`docs/INDEX.md`](docs/INDEX.md) | **Primary index** — every callback, command, pending action cross-referenced to its feature doc | | ||
| | [`docs/features/01-onboarding.md`](docs/features/01-onboarding.md) | `/start`, age gate, referral, username link | | ||
| | [`docs/features/02-user-menu.md`](docs/features/02-user-menu.md) | User persistent menu, settings, submenus | | ||
| | [`docs/features/03-admin-menu.md`](docs/features/03-admin-menu.md) | Admin persistent menu, stats, tools, controls | | ||
| | [`docs/features/04-giveaway.md`](docs/features/04-giveaway.md) | Full giveaway wizard + join + finalization | | ||
| | [`docs/features/05-bonus-30sc.md`](docs/features/05-bonus-30sc.md) | 30 SC wager bonus request + admin approval | | ||
| | [`docs/features/06-promos.md`](docs/features/06-promos.md) | Promo creation, claim, admin management | | ||
| | [`docs/features/07-tooltips.md`](docs/features/07-tooltips.md) | Tooltip add/edit/view/remove/import/settings | | ||
| | [`docs/features/08-referral.md`](docs/features/08-referral.md) | Referral codes, boosts, leaderboard | | ||
| | [`docs/features/09-sshv.md`](docs/features/09-sshv.md) | Admin VPS console, security, session GC | | ||
| | [`docs/features/10-deploy-ops.md`](docs/features/10-deploy-ops.md) | Deploy, rollback, health, testall, metrics | | ||
| | [`docs/features/11-user-lookup.md`](docs/features/11-user-lookup.md) | Whois, bonus status, schema refresh | | ||
| | [`docs/features/12-group-linking.md`](docs/features/12-group-linking.md) | Group/channel link, view, remove, test | | ||
| | [`docs/features/13-bug-reports.md`](docs/features/13-bug-reports.md) | User submit, admin view/resolve/export | | ||
| | [`docs/features/14-announcements.md`](docs/features/14-announcements.md) | Broadcast builder, preview, retry | | ||
| | [`docs/features/15-misc-commands.md`](docs/features/15-misc-commands.md) | All other commands + background timers | | ||
| | [`docs/features/16-walkthrough.md`](docs/features/16-walkthrough.md) | 35-step walkthrough, nav guards, completion | | ||
| | [`docs/TODO_FUNCTIONALITY_UPGRADE.md`](docs/TODO_FUNCTIONALITY_UPGRADE.md) | T-01–T-15 upgrade log (T-01/02/03/15 resolved) | | ||
|
|
||
| **Mandate:** Any added/changed/removed feature → update the relevant feature `.md` + `docs/INDEX.md` + this map section, in the same commit. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -232,21 +232,11 @@ fi | |||||
| # --------------------------------------------------------- | ||||||
| # 3c) Kill anything blocking the bot port before starting | ||||||
| # --------------------------------------------------------- | ||||||
| DEPLOY_PORT="$(grep -E '^PORT=' "$PROJECT_DIR/.env" 2>/dev/null | head -1 | cut -d= -f2 | tr -d '"' | tr -d "'" | tr -d $'\r')" | ||||||
| DEPLOY_PORT="$(grep -E '^PORT=' "$PROJECT_DIR/.env" 2>/dev/null | head -1 | cut -d= -f2 | cut -d'#' -f1 | tr -d '"' | tr -d "'" | tr -d ' ' | tr -d $'\r')" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The PORT parsing in the new "3c) Kill anything blocking the bot port" block runs a failing grep/cut pipeline under Severity Level: Major
|
||||||
| DEPLOY_PORT="$(grep -E '^PORT=' "$PROJECT_DIR/.env" 2>/dev/null | head -1 | cut -d= -f2 | cut -d'#' -f1 | tr -d '"' | tr -d "'" | tr -d ' ' | tr -d $'\r')" | |
| DEPLOY_PORT="$(grep -E '^PORT=' "$PROJECT_DIR/.env" 2>/dev/null | head -1 | cut -d= -f2 | cut -d'#' -f1 | tr -d '"' | tr -d "'" | tr -d ' ' | tr -d $'\r' || true)" |
Steps of Reproduction ✅
1. Ensure the VPS has the PR version of `deploy.sh` deployed at
`/var/www/html/Runewager/deploy.sh` (verified in `/workspace/Runewager/deploy.sh`, lines
24–38 set `set -euo pipefail` and `PROJECT_DIR`).
2. Remove or rename the `.env` file in the project directory so that `$PROJECT_DIR/.env`
does not exist, or create a `.env` file without any `PORT=` line (the deploy script does
not guard this access with `-f` at line 235, unlike BOT_TOKEN/ADMIN_IDS at lines 46–50
which explicitly check `-f "$PROJECT_DIR/.env"`).
3. Run the deploy script, e.g. `bash /var/www/html/Runewager/deploy.sh vps`; execution
proceeds through steps 0–3b successfully, then reaches the "3c) Kill anything blocking the
bot port before starting" block at lines 232–251.
4. At line 235, `DEPLOY_PORT="$(grep -E '^PORT=' "$PROJECT_DIR/.env" 2>/dev/null | head -1
| cut ... | tr -d $'\r')"` executes: since `.env` is missing (grep exit 2) or has no
`PORT=` (grep exit 1), the pipeline exits non‑zero; with `set -euo pipefail`, this
non‑zero status in a simple assignment causes the script to trigger the ERR trap and abort
the deploy before `DEPLOY_PORT` can fall back to the default
`DEPLOY_PORT="${DEPLOY_PORT:-3000}"` at line 236.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** deploy.sh
**Line:** 235:235
**Comment:**
*Logic Error: The PORT parsing in the new "3c) Kill anything blocking the bot port" block runs a failing grep/cut pipeline under `set -euo pipefail` without a trailing `|| true`, so if `.env` is missing or lacks a `PORT=` line the non-zero exit status will abort the entire deploy script instead of falling back to the default port.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,11 +19,38 @@ if [ "$NODE_MAJOR" -lt 20 ] 2>/dev/null; then | |||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| # Pull latest code | ||||||
| echo "[dev-run] Pulling latest code from origin main..." | ||||||
| git -C "$ROOT_DIR" fetch origin main 2>&1 \ | ||||||
| && git -C "$ROOT_DIR" reset --hard origin/main 2>&1 \ | ||||||
| || echo "[dev-run] WARN: git pull failed — starting with local copy" | ||||||
| # Optionally pull latest code (off by default in dev to preserve local changes). | ||||||
| # Reads RUNEWAGER_AUTO_UPDATE from environment first, then from .env as fallback. | ||||||
| # Set RUNEWAGER_AUTO_UPDATE=1 in environment or .env to enable auto-pull. | ||||||
| _AUTO_UPD_DOTENV=$(grep -E '^RUNEWAGER_AUTO_UPDATE=' "$ROOT_DIR/.env" 2>/dev/null | head -1 | cut -d= -f2 | cut -d'#' -f1 | tr -d '"' | tr -d "'" | tr -d ' ' || true) | ||||||
| _AUTO_UPDATE="${RUNEWAGER_AUTO_UPDATE:-${_AUTO_UPD_DOTENV:-0}}" | ||||||
| if [ "$_AUTO_UPDATE" = "1" ]; then | ||||||
| echo "[dev-run] Fetching latest code from origin main..." | ||||||
| if git -C "$ROOT_DIR" fetch origin main 2>&1; then | ||||||
| # Read RUNEWAGER_FORCE_RESET from env then .env fallback (default: off). | ||||||
| # Only perform the destructive reset --hard when explicitly opted in. | ||||||
| _FORCE_RST_DOTENV=$(grep -E '^RUNEWAGER_FORCE_RESET=' "$ROOT_DIR/.env" 2>/dev/null | head -1 | cut -d= -f2 | cut -d'#' -f1 | tr -d '"' | tr -d "'" | tr -d ' ' || true) | ||||||
| _FORCE_RESET="${RUNEWAGER_FORCE_RESET:-${_FORCE_RST_DOTENV:-0}}" | ||||||
| if [ "$_FORCE_RESET" = "1" ]; then | ||||||
| echo "[dev-run] RUNEWAGER_FORCE_RESET=1 — running git reset --hard origin/main..." | ||||||
| if git -C "$ROOT_DIR" reset --hard origin/main 2>&1; then | ||||||
| echo "[dev-run] Code hard-reset to $(git -C "$ROOT_DIR" rev-parse --short HEAD)" | ||||||
| else | ||||||
| echo "[dev-run] WARN: git reset --hard failed — starting with local copy" | ||||||
| fi | ||||||
| else | ||||||
| if git -C "$ROOT_DIR" merge --ff-only origin/main 2>&1; then | ||||||
| echo "[dev-run] Code updated to $(git -C "$ROOT_DIR" rev-parse --short HEAD)" | ||||||
| else | ||||||
| echo "[dev-run] WARN: fast-forward merge failed (local commits diverged?). Set RUNEWAGER_FORCE_RESET=1 to hard-reset." | ||||||
| fi | ||||||
| fi | ||||||
| else | ||||||
| echo "[dev-run] WARN: git fetch failed — starting with local copy" | ||||||
| fi | ||||||
| else | ||||||
| echo "[dev-run] RUNEWAGER_AUTO_UPDATE not set — skipping git pull (set to 1 in .env or environment to enable)" | ||||||
| fi | ||||||
|
|
||||||
| # Refresh tooltips | ||||||
| TOOLTIP_SCRIPT="$ROOT_DIR/generate_tooltips.sh" | ||||||
|
|
@@ -34,18 +61,10 @@ if [ -x "$TOOLTIP_SCRIPT" ]; then | |||||
| fi | ||||||
|
|
||||||
| # Kill anything blocking port 3000 (or PORT from .env) | ||||||
| DEV_PORT=$(grep -E '^PORT=' "$ROOT_DIR/.env" 2>/dev/null | head -1 | cut -d= -f2 | tr -d '"' | tr -d "'" || true) | ||||||
| DEV_PORT=$(grep -E '^PORT=' "$ROOT_DIR/.env" 2>/dev/null | head -1 | cut -d= -f2 | cut -d'#' -f1 | tr -d '"' | tr -d "'" | tr -d ' ' || true) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The dev-run PORT extraction does not strip a trailing carriage return from Severity Level: Major
|
||||||
| DEV_PORT=$(grep -E '^PORT=' "$ROOT_DIR/.env" 2>/dev/null | head -1 | cut -d= -f2 | cut -d'#' -f1 | tr -d '"' | tr -d "'" | tr -d ' ' || true) | |
| DEV_PORT=$(grep -E '^PORT=' "$ROOT_DIR/.env" 2>/dev/null | head -1 | cut -d= -f2 | cut -d'#' -f1 | tr -d '"' | tr -d "'" | tr -d ' ' | tr -d '\r' || true) |
Steps of Reproduction ✅
1. In `/workspace/Runewager/dev-run.sh:36-50`, note that `DEV_PORT` is parsed from
`$ROOT_DIR/.env` and only quotes and spaces are stripped (`tr -d '"'`, `tr -d "'"`, `tr -d
' '`), but no carriage return is removed.
2. On a Windows or WSL development machine, create `$ROOT_DIR/.env` with CRLF endings so
the line storing the port is `PORT=3000\r\n` (for example, by editing `.env` in a Windows
editor and saving with default CRLF line endings).
3. Start any long‑running process bound to TCP port 3000 (e.g. an old `node index.js`
instance from a previous run or `python -m http.server 3000`) so that `lsof`/`fuser`
should find a listener on port `3000`.
4. Run `./dev-run.sh` from the repo root: `DEV_PORT` becomes `3000\r`, so the subsequent
`lsof -ti :"$DEV_PORT"` or `fuser -n tcp "$DEV_PORT"` at `dev-run.sh:39-42` do not match
the existing listener; `_DEV_PIDS` remains empty, no processes are killed, and when `exec
node index.js` at `dev-run.sh:54` runs, Node fails to bind with `EADDRINUSE` because the
old process is still holding port 3000.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** dev-run.sh
**Line:** 37:37
**Comment:**
*Possible Bug: The dev-run PORT extraction does not strip a trailing carriage return from `.env` values, so on CRLF `.env` files the computed port (e.g. `3000\r`) can cause `lsof`/`fuser` lookups to fail silently and leave the old process running on the intended port.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve directive conflict: map-first vs docs-index-first.
Line 405 says sessions must consult
docs/INDEX.mdfirst, which conflicts with this file’s own map-first contract (Line 396-399). Keep one authoritative ordering to prevent process drift.Suggested patch
Based on learnings: "Always treat RUNEWAGER_FUNCTIONALITY_MAP.md as the authoritative source of truth before and after code changes" and "Begin every coding session by reading RUNEWAGER_FUNCTIONALITY_MAP.md; end with full verification pass".
🤖 Prompt for AI Agents