Skip to content

Centralize pending-action timeout handling; add tests and map/agent updates - #96

Merged
gamblecodezcom merged 1 commit into
mainfrom
codex/perform-full-audit-and-implementation-for-runewager-bot
Feb 26, 2026
Merged

Centralize pending-action timeout handling; add tests and map/agent updates#96
gamblecodezcom merged 1 commit into
mainfrom
codex/perform-full-audit-and-implementation-for-runewager-bot

Conversation

@gamblecodezcom

@gamblecodezcom gamblecodezcom commented Feb 26, 2026

Copy link
Copy Markdown
Owner

User description

Motivation

  • Fix inconsistent pending-action timeout handling so wait-for-input states reliably seed createdAt, expire after the configured PENDING_ACTION_TIMEOUT_MS, clear state, and provide a safe Main Menu recovery path.
  • Ensure documentation and agent guidance reflect real runtime behavior so the map-first workflow and verification gates are enforced.

Description

  • Added evaluatePendingActionTimeout(user, now) in index.js to centralize pending-action timeout evaluation and normalization.
  • Rewired the text input router (bot.on('text')) to call evaluatePendingActionTimeout(...) and show a recovery inline keyboard when a pending state expires.
  • Added unit tests in test/unit.test.js covering evaluatePendingActionTimeout behavior: createdAt seeding, expiry clearing, and fallback type labeling.
  • Updated RUNEWAGER_FUNCTIONALITY_MAP.md to document the enforced pending-action timeout behavior and updated CLAUDE.md with a Runewager 2.0 agent contract to require map-first, code-first parity and verification steps.

Testing

  • Ran the repository test suite via npm test --silent, which executed the unit tests and smoke checks and returned all passing results (38 tests passed).
  • Verified the bot.on('text') pending-action timeout path by unit tests added for timestamp seeding and expiry clearing, and validated no test failures occurred.

Codex Task


CodeAnt-AI Description

Centralize pending-action timeout handling and add user-visible timeout recovery

What Changed

  • Pending input states now always get a timestamp on first check and automatically expire after 15 minutes; when expired the pending state is cleared and the bot replies with a prompt offering the Main Menu.
  • The text message handler uses a single timeout evaluator so timeout behavior is consistent across flows and command escapes safely clear pending states.
  • Unit tests were added to verify timestamp seeding, expiry clearing, and fallback labeling; documentation and the agent contract were updated to require map-first implementation and to document the enforced pending-action timeout behavior.

Impact

✅ Fewer stuck pending states
✅ Clearer timeout recovery with Main Menu prompt
✅ Consistent 15-minute pending expirations

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai

codeant-ai Bot commented Feb 26, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Feb 26, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@gamblecodezcom has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 24 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b95e1ea and 00c8dd7.

📒 Files selected for processing (4)
  • CLAUDE.md
  • RUNEWAGER_FUNCTIONALITY_MAP.md
  • index.js
  • test/unit.test.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/perform-full-audit-and-implementation-for-runewager-bot

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gamblecodezcom
gamblecodezcom merged commit 47d668e into main Feb 26, 2026
5 checks passed
@gamblecodezcom
gamblecodezcom deleted the codex/perform-full-audit-and-implementation-for-runewager-bot branch February 26, 2026 21:45
@codeant-ai

codeant-ai Bot commented Feb 26, 2026

Copy link
Copy Markdown

Sequence Diagram

Shows how incoming text is routed through the new pending-action timeout evaluator; if a pending state expired it is cleared and the bot returns a Main Menu recovery prompt, otherwise normal text handling continues. This captures the core behavior introduced by the PR.

sequenceDiagram
    participant User
    participant Bot
    participant TimeoutEvaluator

    User->>Bot: Send text message
    Bot->>TimeoutEvaluator: evaluatePendingActionTimeout(user, now)
    alt Pending expired
        TimeoutEvaluator-->>Bot: { hadPending: true, expired: true, expiredType }
        Bot-->>User: Reply "timed out" + Main Menu inline keyboard (clear pending)
    else Pending active or none
        TimeoutEvaluator-->>Bot: { hadPending: false|true, expired: false }
        Bot->>Bot: Continue normal text handling (commands, input routing)
        Bot-->>User: Proceed with normal response or command handling
Loading

Generated by CodeAnt AI

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label Feb 26, 2026
@codeant-ai

codeant-ai Bot commented Feb 26, 2026

Copy link
Copy Markdown

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Mutation Risk
    evaluatePendingActionTimeout mutates the passed user object (seeds user.pendingAction.createdAt and sets user.pendingAction = null on expiry). Callers/tests may rely on or be surprised by these side effects; verify this mutation is intended and safe across all call sites.

  • Tests depend on side-effects
    New unit tests assert that evaluatePendingActionTimeout mutates user.pendingAction.createdAt and clears user.pendingAction. Relying on these side-effects in tests couples behavior tightly; consider whether tests should assert returned values only or explicitly document/verify the mutation contract.

  • Magic Constant
    The timeout uses an inline literal 15 * 60 * 1000. Extracting this into a named constant (or importing the canonical value) will improve clarity and ensure tests and runtime use the same value.

@codeant-ai

codeant-ai Bot commented Feb 26, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant