-
Notifications
You must be signed in to change notification settings - Fork 1
fix(collection): identity dedup + chunk IN() + kill tree + help TTL + safe CDP cleanup [修复组⑥] #30
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| # CLAUDE.md | ||
|
|
||
| <!-- Add your custom instructions below. Repowise will never modify anything outside the REPOWISE markers. --> | ||
| <!-- Examples: coding style rules, test commands, workflow preferences, constraints --> | ||
|
|
||
| <!-- REPOWISE:START — Do not edit below this line. Auto-generated by Repowise. --> | ||
| ## IMPORTANT: Codebase Intelligence Instructions for opencli-admin | ||
|
|
||
| > This repository is indexed by [Repowise](https://repowise.dev). | ||
| > Use the MCP tools below for orientation, discovery, and enriched context | ||
| > (documentation, ownership, history, decisions). **Always verify against | ||
| > actual source files before making changes** — the index may be stale. | ||
|
|
||
| Last indexed: 2026-07-12 (commit c326a2a) | ||
| ### Entry Points | ||
| - `backend/main.py` | ||
| - `odp-rs/crates/odp-ingest/src/main.rs` | ||
| - `odp-rs/crates/odp-store/src/main.rs` | ||
| - `iii/workers/collector-discord/src/main.py` | ||
| - `iii/workers/collector-opencli/src/main.py` | ||
| - `iii/workers/odp-ingest-bridge/src/main.py` | ||
| - `iii/workers/schedule-bootstrap/src/main.py` | ||
| - `odp-rs/crates/odp-contracts/src/lib.rs` | ||
| ### Tech Stack | ||
| **Languages:** Python, TypeScript | ||
| **Frameworks:** FastAPI, HTTPX, Pydantic | ||
| **Databases:** Alembic, SQLAlchemy | ||
| **Infra:** Celery, Docker, Docker Compose### Architectural Layers | ||
| | Layer | Files | Purpose | | ||
| |-------|-------|---------| | ||
| | Application | 431 | | | ||
| | API | 48 | | | ||
| | UI | 84 | | | ||
| | Config | 4 | | | ||
| | Types | 22 | | | ||
| | Data | 25 | | | ||
| | Service | 83 | | | ||
| | Docs & Tooling | 197 | | | ||
| | Test | 170 | | | ||
|
|
||
| ### Guided Tour (12 steps) | ||
| 1. `README_HANDOVER.md` | ||
| 2. `main.py` | ||
| 3. `main.rs` | ||
| 4. `main.rs` | ||
| 5. `frontend.mjs` | ||
| 6. `schema.ts` | ||
| ... and 6 more steps | ||
| ### Hotspots (High Churn) | ||
| | File | Churn | 90d Commits | Owner | | ||
| |------|-------|-------------|-------| | ||
| | `backend/channels/opencli_channel.py` | 100.0th %ile | 8 | xujinghua | | ||
| | `tests/integration/test_workflow_compile_api.py` | 99.9th %ile | 15 | lunnt | | ||
| | `backend/workflow/opencli_hda_tracer.py` | 99.8th %ile | 6 | lunnt | | ||
| | `tests/integration/test_workflow_opencli_hda_trace_api.py` | 99.6th %ile | 9 | lunnt | | ||
| | `frontend/lib/flow/store.ts` | 99.5th %ile | 7 | lunnt | | ||
|
|
||
| ## Code health | ||
| Three signals: **defect risk** (the overall score), **maintainability** (smells that hurt readability/change-cost without predicting bugs), and **performance** (static performance RISK: I/O-in-loop / N+1 shapes that waste work, high-precision/low-recall). Maintainability and performance are co-equal views, never blended into the defect headline. See `docs/CODE_HEALTH.md`. | ||
|
|
||
| Defect risk, Hotspot health: 5.42/10 (stable) · | ||
| Average: 8.0/10 · | ||
| Worst: 1.0/10 (`frontend/lib/flow/store.ts`) | ||
| Maintainability, Average: 8.88/10 | ||
| Performance risk, Average: 9.93/10 | ||
|
|
||
| ### Critical biomarkers | ||
| - `frontend/components/flow/workflow-editor.tsx` — churn risk — impact −2.3 | ||
| - `tests/integration/test_workflow_opencli_hda_trace_api.py` — change entropy — impact −2.3 | ||
| - `backend/schemas/control.py` — change entropy — impact −2.1 | ||
| - `backend/config.py` — untested hotspot — impact −2.0 | ||
| - `frontend/components/ui/card.tsx` — untested hotspot — impact −2.0 | ||
|
|
||
| ### Repowise MCP Tools | ||
|
|
||
| This repo has the Repowise MCP server configured. The tools below answer questions `grep`/`Read` cannot. Every response carries an `_meta` envelope with `index_age_days`, `indexed_commit`, and a `stale_warning` only when the index has actually diverged from HEAD — silence means the index is current. | ||
|
|
||
| **When to call which tool:** | ||
|
|
||
| | Tool | What only this tool answers | | ||
| |------|------------------------------| | ||
| | `get_answer(question)` | Synthesised answer with citations and a content-grounded `confidence`. First call for "how does X work" / "where is Y" / "why is Z" — and the one-shot for "explain function/method/class X": when the question names an indexed symbol, get_answer anchors its defining file (even when fuzzy retrieval would miss it) and returns the symbol's full live body in `symbol_bodies` — read that instead of a `get_symbol` follow-up. Value questions may return `grounding: "extracted"` (verbatim source line). On low confidence returns `best_guesses` with one-line justifications, plus `code_rationale` (rationale comments mined live from the candidate source) when the "why" lives in a code comment the wiki never captured. | | ||
| | `get_context(targets=[...])` | Triage card for files/modules/symbols — title, summary, signatures, `hotspot` bit, `decision_records` titles, `symbol_id`s. File targets auto-upgrade to a `verified` skeleton (every signature, ~37% of a full Read). `include=["callers"]` works on file targets too (import + call rollup). | | ||
| | `get_symbol(...)` | Source bytes with live-verified bounds. Three forms: `"path.py::Name"` (indexed symbol), `"path.py:140-180"` (live range read, ≤200 lines), `"repowise#<hex>"` (omission ref). Index misses return `fallback_lines` from a live grep instead of a dead end. | | ||
| | `search_codebase(query, mode?, kind?, symbol_kind?)` | Hybrid code search. `mode="auto"` (default) routes by query shape: an identifier → indexed symbol hits (`symbol_id`/`file`/line bounds — pipe into `get_symbol`), a path → file pages (pipe into `get_context`), prose → wiki-semantic search, mixed → hybrid (symbols first). Force a branch with `mode=symbol\|path\|concept\|hybrid`. Concept hits carry `search_method` (`embedding` vs `bm25` fallback); decision records rank below file pages unless the query is why-shaped. | | ||
| | `get_why(query, targets?)` | Architectural decision archaeology — *why* the code is shaped this way. Call before refactors or pattern divergences. Falls back to git archaeology when no ADRs exist for a file, and to `code_rationale` (rationale comments mined from the source) when neither decisions nor git history explain it. | | ||
| | `get_risk(targets, changed_files?)` | What history says about touching these files: churn, owners, blast radius. Pass `changed_files` for PR mode → returns a `directive` (`will_break`, `missing_cochanges`, `missing_tests`). | | ||
| | `get_health(targets?, include?)` | Code-health scores + biomarker findings (defect / maintainability / performance pillars). Self-check before a PR — read the same signals the merge-gate judges your change on. Default is lean; opt in with `include`: `["accuracy"]` (does the score rank the buggy files first — precision@K + `lift`), `["signals"]` (per-file prior-defects / churn / owners / degree, targeted mode), `["churn_complexity"]` (volatile-and-complex danger-zone files), `["biomarkers"]` (all findings), and a dimension name `["performance"]` / `["defect"]` / `["maintainability"]` to filter findings to one pillar. | | ||
| | `get_dead_code(...)` | Tiered unreachable / unused-export / zombie-package findings. Run before a cleanup sprint, not before a targeted fix. | | ||
| | `get_overview(repo?)` | Architecture map + `tool_guide` recipes. One-time orientation; skip on subsequent calls in the same session. | | ||
|
|
||
| **Trust protocol — when a response replaces reading the source:** | ||
| - `verified: true` on any response means the served content was checked against the live working tree. **Never follow a verified response with a Read of the same lines** — you would be paying twice for identical bytes. | ||
| - `get_answer` with `confidence: "high"` or `grounding: "extracted"` is content-grounded (asserted values were verified against retrieved source; ≥1 citation is source-backed). Cite it directly. `quotes` entries `{path, lines, quote}` are verbatim live source — quote them instead of re-reading. `symbol_bodies` entries `{path, name, lines, source}` are the full live body of a named definition — read that body, do not call `get_symbol` for the same symbol (a `continuation` token names the next range if it was truncated). | ||
| - `code_rationale` entries `{path, lines, comment}` (on a low-confidence `get_answer` or a fallen-back `get_why`) are rationale comments read live from the source. When the "why" you asked for is a code comment rather than an ADR, the comment is right there: cite it instead of opening the file to hunt for it. | ||
| - Reading code: `get_context` skeleton first (~37% of a full Read), then `get_symbol` for bodies, `"path.py:a-b"` range reads for anything between symbols. Raw `Read` is for files the index marks `mostly_full` or cannot serve. On a **large file** `get_symbol("path::Name")` is the win — it serves one verified body instead of pulling the whole file into context. | ||
| - The **only** re-read triggers: `bounds: "approximate"`, `_meta.stale_warning`, `search_method: "bm25"`, or `confidence: "low"`/`retrieval_quality: "weak"`. | ||
| - Disallowed rationalizations for extra reads: "just to be safe", "to double-check the tool", "to see the full context" (use the skeleton / a range read), "the file might have changed" (that is what `verified` already checked). | ||
| - When a plain `Grep` is the right tool, use it: an exhaustive literal-token sweep (rename every call site, find all occurrences) is one grep and unbeatable on cost. MCP's edge there is not fewer tokens — it is the `callers_total`/`callers_truncated` honesty signal that tells you whether a list is complete; reach for `get_context(include=["callers"])` when silent incompleteness would bite. | ||
|
|
||
| **Composition tips:** | ||
| - `get_answer` → if `confidence` is `medium`/`low`, follow `best_guesses[0].file` or `fallback_targets[0]` into `get_context`, then `get_symbol` for bytes. | ||
| - `get_context` returns `decision_records` titles → `get_why(targets=[...])` for the rationale; `hotspot: true` → `get_risk` before editing. | ||
| - PR review → `get_risk(targets=[...], changed_files=[...])`; read the `directive` block first. | ||
| - A `tombstone` error means the file was deleted/renamed since indexing — follow `successor_paths`. | ||
|
|
||
| ### Output Distillation | ||
|
|
||
| - Prefer `repowise distill <cmd>` for noisy commands — test runs, builds, `git status`/`log`/`diff`, searches, file listings. It runs the command unchanged (exit code preserved) and prints a compact, errors-first rendering; every error line survives. | ||
| - Output may contain a marker like `[repowise#a1b2c3d4e5f6: 230 lines omitted (~6.1k tokens); restore: repowise expand a1b2c3d4e5f6]`. The omitted content is fully preserved — run `repowise expand <ref>` to retrieve it, or `repowise expand <ref> -q <regex>` for just the matching lines. | ||
| - Never re-run a command to see omitted output; expand the marker instead. | ||
| - For structure-level questions about a large indexed file ("what's in here", "which function handles X"), `get_context(["path"], include=["skeleton"])` returns the file with bodies elided — every signature plus the bodies of the most central symbols — at a fraction of the cost of a full Read. | ||
|
|
||
| ### Codebase Conventions | ||
| **Commands:** | ||
| - Build: `npm run build` | ||
| - Test: `npm run test` | ||
| - Lint: `npm run lint` | ||
| - Dev: `npm run dev` | ||
| - Format: `npm run format` | ||
| - Typecheck: `npm run typecheck` | ||
|
|
||
| <!-- REPOWISE:END --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "version": "0.0.1", | ||
| "configurations": [ | ||
| { | ||
| "name": "frontend-dev", | ||
| "runtimeExecutable": "pnpm", | ||
| "runtimeArgs": ["-C", "frontend", "exec", "next", "dev", "-p", "8030"], | ||
| "port": 8030 | ||
| }, | ||
| { | ||
| "name": "backend-stack", | ||
| "runtimeExecutable": "docker", | ||
| "runtimeArgs": ["compose", "up", "api", "agent-1"], | ||
| "port": 8031 | ||
| } | ||
| ] | ||
| } |
1 change: 1 addition & 0 deletions
1
.omc/state/sessions/b4f7d02c-1da1-4b4d-9835-33e44401355e/hud-cache.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"session_id":"b4f7d02c-1da1-4b4d-9835-33e44401355e","context_samples":[{"ts_ms":1783878055117,"tokens":109500},{"ts_ms":1783878057926,"tokens":109939},{"ts_ms":1783878059350,"tokens":109939},{"ts_ms":1783878062169,"tokens":109939},{"ts_ms":1783878065137,"tokens":112312},{"ts_ms":1783878066527,"tokens":112312},{"ts_ms":1783878069643,"tokens":112437},{"ts_ms":1783878070036,"tokens":112437},{"ts_ms":1783878070541,"tokens":112437},{"ts_ms":1783878071081,"tokens":112437},{"ts_ms":1783878077649,"tokens":113096},{"ts_ms":1783878078111,"tokens":113096},{"ts_ms":1783878083683,"tokens":113513},{"ts_ms":1783878084794,"tokens":113513},{"ts_ms":1783878091897,"tokens":114044},{"ts_ms":1783878093626,"tokens":114044},{"ts_ms":1783878095116,"tokens":114044},{"ts_ms":1783878100551,"tokens":114749},{"ts_ms":1783878117149,"tokens":114749},{"ts_ms":1783878475480,"tokens":116909},{"ts_ms":1783878477603,"tokens":116909},{"ts_ms":1783878481720,"tokens":118189},{"ts_ms":1783878483660,"tokens":118189},{"ts_ms":1783878488025,"tokens":118636},{"ts_ms":1783878488449,"tokens":118636},{"ts_ms":1783878495026,"tokens":119031},{"ts_ms":1783878514349,"tokens":119031},{"ts_ms":1783878521236,"tokens":121158},{"ts_ms":1783878586833,"tokens":121464},{"ts_ms":1783878587475,"tokens":121464},{"ts_ms":1783878597857,"tokens":121836},{"ts_ms":1783878604356,"tokens":122080},{"ts_ms":1783878604705,"tokens":122080},{"ts_ms":1783878614717,"tokens":122341},{"ts_ms":1783878621949,"tokens":122341},{"ts_ms":1783878630484,"tokens":123658}],"last_updated_ms":1783878630484,"session_start_tokens":72839} | ||
1 change: 1 addition & 0 deletions
1
.omc/state/sessions/dc752497-c4fd-4221-ae35-e78f40e96767/hud-cache.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"session_id":"dc752497-c4fd-4221-ae35-e78f40e96767","context_samples":[{"ts_ms":1783877236367,"tokens":0},{"ts_ms":1784175633941,"tokens":0}],"last_updated_ms":1784175633941,"session_start_tokens":null} |
1 change: 1 addition & 0 deletions
1
.omc/state/sessions/de0b7a77-e9c7-46ac-961a-f0e90ffa1f07/hud-cache.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"session_id":"de0b7a77-e9c7-46ac-961a-f0e90ffa1f07","context_samples":[{"ts_ms":1783867603857,"tokens":0},{"ts_ms":1783867659239,"tokens":0}],"last_updated_ms":1783867659239,"session_start_tokens":null} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
这些
.omc/state/目录下的 session 缓存文件是本地运行状态,不应该提交到版本控制中。建议将.omc/目录添加到.gitignore中,并从 Git 中移除 these 文件。