add retry sms manually

This commit is contained in:
javad committed 2026-09-23 18:23:18 +03:30
1 parent 33930e972c
commit cb92abbb41
42 files changed
+1628 -1484

No files matched your search

+81 -42
View File
@@ -1,42 +1,81 @@
# Project operating rules
## Development server
- Always bind the Django development server to `0.0.0.0:8000` so the project is reachable from phones and other devices through the computer's local-network IP address. Do not start it on `127.0.0.1` unless the user explicitly requests localhost-only access.
- Before starting or restarting Django on port `8000`, inspect the port and identify every existing listener.
- Stop the previous project server and its parent/child process tree before launching the replacement.
- After launch, verify that exactly one process is listening on port `8000`.
- Verify the listener is bound to `0.0.0.0:8000`, then fetch the site locally through `127.0.0.1:8000` as a health check.
- Fetch a changed page/static asset from the live server and confirm the expected new content is actually being served.
- When frontend assets change, remind the user to perform a hard refresh, but do not treat browser cache as the cause until the live listener and served content have been verified.
- Keep the active server session identifier and shut it down cleanly before starting another instance.
## Graphify queries
- Treat questions about this codebase as Graphify queries first whenever `graphify-out/graph.json` exists.
- Before querying, expand the user's Persian question against the actual vocabulary in `graphify-out/graph.json`.
- Use the best combination of Persian and English terms that are present in the graph vocabulary; never rely on automatic translation, stemming, or synonyms inside Graphify.
- For code queries, prioritize the graph's English identifiers (class, function, model, template, route, and file names), because the structural code graph is predominantly English; add Persian terms when they actually exist in the graph, especially for requirements and documentation.
- Choose the traversal deliberately: BFS for broad relationships, DFS for dependency/data-flow traces, `path` for a shortest connection, and `explain` for one node and its neighbors.
- Validate important Graphify findings against the referenced source code or project documentation before acting on them.
## Python package mirror
- Use Liara's PyPI mirror for Python dependency resolution and installation: `https://package-mirror.liara.ir/repository/pypi/simple`.
- Prefer the persistent user-level pip configuration over repeating `--index-url` in individual commands.
- If the mirror is temporarily unavailable or missing a required package/version, report it before using the public PyPI index as a fallback.
## Frontend and PWA cache safety
- Every locally served frontend asset in templates must include `static_asset_version` in its URL.
- Keep the service-worker registration URL versioned with the same value and keep `updateViaCache: 'none'`; changing only the service-worker cache name is not sufficient.
- Any change to frontend caching or PWA lifecycle code must preserve the regression assertions in `tests/test_views.py` and pass `tests/e2e/test_pwa_versioning.py` with service workers enabled.
- Before blaming a user's browser cache, verify the live listener and served asset content according to the development-server rules above.
## End-to-end browser tests
- Put browser scenarios under `tests/e2e/`, mark them `e2e`, and use Django's transactional `live_server`.
- Use the managed Chromium and isolated BrowserContext provided by `tests/e2e/conftest.py`; do not launch browsers directly inside tests. Keep Playwright function-scoped because a session-scoped sync Playwright event loop conflicts with Django's synchronous test-database setup.
- Keep selectors and reusable browser actions in `tests/e2e/pages/` Page Objects, while tests remain focused on user-visible outcomes.
- Never use fixed sleeps for synchronization. Use Playwright locators, `expect`, navigation, response, or application-state waits.
- Preserve automatic screenshot and trace capture on failure. PWA scenarios must explicitly enable service workers and carry the `pwa` marker.
# Project Operating & Agent Guidelines
## 1. Codebase Navigation & Analysis (Ripwire vs. Graphify)
> **Rule of Thumb:** Default to **Ripwire** for all hands-on coding, AST, edits, call graphs, and tests. Reserve **Graphify** strictly for high-level architectural understanding, cross-artifact relations, and non-code assets.
CLI-only (never use MCP). Route strictly by question and artifact type. Never query both tools for the same sub-task; never execute in parallel. Always prefer `--expand` over reading entire files.
| Metric / Dimension | **Ripwire** (Deterministic AST) | **Graphify** (Semantic KG) |
|---|---|---|
| **Primary Scope** | Local source code AST, symbol graphs, in-repo text | Cross-artifact: Code + Docs + PDFs + Media + SQL Schema |
| **Best at** | Callers, callees, impact, tests, quality delta, `--arch`, `--doc-drift` | Conceptual "How A relates to B", ADR/RFC context, schemas |
| **Primary CLI** | `ripwire . --for="…"`, `--callers=SYM`, `--impact=SYM`, `--test-gate` | `graphify query "…"`, `graphify path "A" "B"`, `graphify explain "node"` |
| **Boundary** | Prose meaning, non-code files, cross-asset concepts | Exact symbol references, impact analysis, code test gates |
### Routing Gate & Pipeline
1. **Trivial edits (≤1 file, no exported symbols):** Modify directly without querying either tool.
2. **Execution routing:**
- Hands-on coding, symbols, AST, usages, impact, and tests → **Ripwire**.
- Architecture discovery, cross-artifact concepts (PDF, media, docs, ADR/RFC), and SQL schemas → **Graphify**. (Note: `.sql` symbols use Ripwire; schema semantics use Graphify).
- Ambiguous/Mixed tasks → Run `ripwire . --help-task="task"` to classify, then route by artifact.
3. **Graphify query rules (when selected):**
- Requires `graphify-out/graph.json`; if absent, route code questions to Ripwire.
- **Bilingual alignment:** Match terms directly against `graphify-out/graph.json` vocabulary. Prioritize English code identifiers; include Persian terms only when verified in graph documentation/requirements. Never rely on internal translation or stemming.
- **Traversal selection:** Use BFS for broad relationships, DFS for dependency traces, `path` for shortest linkage, and `explain` for node neighbors.
- Always cross-verify critical graph findings against source code before editing.
4. **Pre-edit impact gate:** Before any non-trivial code change, inspect the target symbol with both `ripwire . --impact=SYM` and `ripwire . --uses=SYM`; if either query refuses or is ambiguous, resolve the symbol using the CLI guidance before editing.
5. **Post-edit pipeline:** Run `ripwire . --test-gate` followed by `ripwire . --quality-delta`.
---
## 2. Dynamic Help, Self-Correction & Staleness
Never stall on tool errors or hallucinate flags. Dynamic CLI help always takes precedence over memorized parameters.
- **Help Precedence:** Before using an unfamiliar or ambiguous capability, inspect `ripwire --help` or `ripwire --help=--FLAG`; if any instruction or remembered syntax conflicts with that output, the CLI help is authoritative.
- **Dynamic Inspection (on error or flag confusion):**
- Ripwire: `ripwire --help`, `ripwire --help=--FLAG`, `ripwire . --doctor`, `ripwire . --help-task="task"`
- Graphify: `graphify --help`, `graphify <cmd> --help`
- **Fallback & Retries (Cap at 1):**
- If a command fails or rejects flags: inspect its `--help` and retry once.
- If a tool returns empty results or an explicit refusal: try the alternative tool once; if still unresolved, report to user.
- If data is suspected to be stale: run `graphify update .` or `ripwire . --no-cache` and retry once.
- If a tool binary is missing (`command -v` check fails): state missing dependency clearly; do not guess syntax.
---
## 3. Git Operations & Safety
- **Read-only (Agent allowed):** `git status`, `git diff`, `git log`.
- **Human-gated (User execution only):** `git add`, `commit`, `push`, `checkout`, `merge`, `rebase`, and branch management. If needed, request user action and pause.
- **Exception:** `graphify hook install` is permitted (read-side only).
---
## 4. Development Server Lifecycle
- **Binding:** Always bind Django to `0.0.0.0:8000` (LAN accessible). Never use `127.0.0.1` unless explicitly requested.
- **Process Management:** Before launching, inspect port `8000`. Terminate previous project server instances and their child process trees cleanly.
- **Health Verification:** Confirm exactly one process listens on `0.0.0.0:8000`, then fetch `127.0.0.1:8000` locally to verify health.
- **Asset Confirmation:** When checking frontend changes, verify the served content on the live server before suggesting browser cache issues to the user.
---
## 5. Environment, Frontend & PWA Safety
- **Python virtual environment:** Use the repository `.venv` for all Python and Django commands during development, tests, dependency management, and server startup. From WSL, run `.venv/Scripts/python.exe`; from Windows, run `.venv\Scripts\python.exe`. Run pip with `<venv-python> -m pip` and Django with `<venv-python> manage.py ...`. Do not use system Python or pip or create a second environment unless the user requests it.
- **PyPI Mirror:** Use Liara's mirror: `https://package-mirror.liara.ir/repository/pypi/simple`. Use user-level pip configuration. Report downtime before falling back to public PyPI.
- **Asset Versioning:** All locally served frontend assets must include `static_asset_version` in their URLs.
- **PWA Lifecycle:** Keep the service worker registration URL versioned with `updateViaCache: 'none'`.
- **Cache Regression Gate:** Changes to frontend caching or PWA code must pass assertions in `tests/test_views.py` and `tests/e2e/test_pwa_versioning.py`.
---
## 6. End-to-End Browser Tests (Playwright)
- **Organization:** Place tests in `tests/e2e/`, mark with `e2e`, and run against Django's transactional `live_server`.
- **Scope & Lifecycle:** Use managed Chromium and BrowserContext from `tests/e2e/conftest.py`. Keep Playwright function-scoped to prevent event loop deadlocks with Django's synchronous database setup.
- **Page Objects:** Encapsulate interactions inside `tests/e2e/pages/`. Tests must assert user-visible outcomes only.
- **Synchronization:** Never use hardcoded sleeps. Rely on Playwright locators, `expect`, navigation, and state-change assertions.
- **Diagnostics:** Maintain automatic screenshot/trace capture on failure. PWA scenarios must enable service workers and use the `pwa` marker.