text
stringlengths
185
73.3k
repo
stringlengths
7
100
path
stringlengths
4
146
language
stringclasses
7 values
hash
stringlengths
16
16
score
float64
7
8.5
stars
int64
0
237k
"""CLI composition root helpers. One of the three places allowed to name a concrete adapter (ADR-0003). Every command builds its object graph here, so wiring lives in one readable place rather than being scattered across command bodies. """ from __future__ import annotations import subprocess from dataclasses import...
theurian/theurian
packages/theurian-core/src/theurian/cli/context.py
.py
9ca7979967dc73d5
7.42
6
"""What ``theurian index status`` reports, computed (FR-R2). Split out of :mod:`theurian.cli.index_commands`, which holds the command itself and stays the module ``tests/unit/test_resolve_context_call_sites.py`` pins ``index_status`` to. What moved here is everything the command *derives* before it emits: the publishe...
theurian/theurian
packages/theurian-core/src/theurian/cli/index_status_report.py
.py
9723e3adeb072d98
7.42
6
"""Theurian CLI entry point. A composition root: this is one of the three places allowed to name concrete adapters (ADR-0003). Milestone 0 ships only the version surface, because that is what the plugin's compatibility gate depends on -- everything else lands in Milestones 1 through 8. Every command supports ``--json...
theurian/theurian
packages/theurian-core/src/theurian/cli/main.py
.py
b69231cd85e463b0
7.42
6
"""The pipeline ``migrate apply`` runs, and the dry replay ``propose accept`` runs. A composition root (ADR-0003): one of the places allowed to name a concrete adapter. It exists for one reason, and the reason is ADR-0027 decision 2's hard condition -- **``accept``'s pre-check must invoke the same engine path ``migrat...
theurian/theurian
packages/theurian-core/src/theurian/cli/migration_pipeline.py
.py
e177f7d457c5d1ef
7.42
6
"""The one place a CLI value is made safe to print to a terminal. Every text-mode emitter in the CLI -- `commands._render`, `commands._fail`, and `main._emit` -- routes each value and key it prints through :func:`escape_terminal_controls`, so that no string a command *emits through them* can move the cursor or start a...
theurian/theurian
packages/theurian-core/src/theurian/cli/output.py
.py
dc7602dbcf2831b4
7.42
6
"""Daemon lifecycle: assemble, guard, and serve (ADR-0002, ADR-0011). A composition root. This is where the token, the registry, the MCP tools, and the single-instance guard are wired into one running process. """ from __future__ import annotations import asyncio from datetime import UTC, datetime from pathlib impor...
theurian/theurian
packages/theurian-core/src/theurian/daemon/runner.py
.py
4b95e6d23aadd5d8
7.42
6
"""The Theurian daemon (ADR-0002, ADR-0011). A Starlette application exposing: - ``GET /health`` — unauthenticated, liveness and identity only - ``/mcp`` — the MCP server over Streamable HTTP, bearer-authenticated Bearer authentication is a Starlette middleware rather than the SDK's ``AuthSettings``, which requires ...
theurian/theurian
packages/theurian-core/src/theurian/daemon/server.py
.py
fa1f55a38762735a
7.42
6
"""Splitting a document into retrievable passages (FR-R2). A pure function of text. Retrieval returns *chunks*, not whole documents, because an architecture decision record is often ten pages of which one paragraph answers the question — and returning the other nine spends a caller's context budget on material they di...
theurian/theurian
packages/theurian-core/src/theurian/domain/chunking.py
.py
f6112bd917ea7291
7.42
6
"""Per-request context. There is no process-global ``currentProject`` and no connection-scoped state. Every call carries its own context, which is what makes cross-project isolation testable rather than aspirational (ADR-0002, SEC-13). """ from __future__ import annotations from dataclasses import dataclass from typ...
theurian/theurian
packages/theurian-core/src/theurian/domain/context.py
.py
58d9a3dd135f4dd1
7.42
6
"""Closed vocabularies, and the two rules that read one of them. These are ``StrEnum`` so they serialise to their own names in JSON and YAML, which keeps migration files and MCP payloads readable without a mapping table. :func:`may_surface` and :func:`may_disclose` are here rather than beside a caller because each ha...
theurian/theurian
packages/theurian-core/src/theurian/domain/enums.py
.py
96f77eaaa23f2d35
7.42
6
"""Ingestion result types. A parser failure fails **one document**, not the run. A malformed YAML file among two hundred knowledge documents must not make the other 199 unavailable, so failures are values carried in a report rather than exceptions that unwind the whole walk (FR-S1, FR-S4). """ from __future__ import ...
theurian/theurian
packages/theurian-core/src/theurian/domain/ingestion.py
.py
c9591da2e5a82a5e
7.42
6
"""Knowledge entities: items, revisions, relations, anchors, aliases, evidence. A :class:`KnowledgeRevision` is immutable. A :class:`KnowledgeItem` is a mutable pointer to the revision that is current now. See ADR-0006. """ from __future__ import annotations from dataclasses import dataclass, field, replace from dat...
theurian/theurian
packages/theurian-core/src/theurian/domain/knowledge.py
.py
8c5bae25d799c482
7.42
6
"""Knowledge migration model (ADR-0005). A migration is a declarative, storage-independent statement about knowledge state. The types here describe what a migration *is*; applying one is the application layer's job, and loading one from disk is the infrastructure's. """ from __future__ import annotations from collec...
theurian/theurian
packages/theurian-core/src/theurian/domain/migration.py
.py
5763d2fd3b740c79
7.42
6
"""Shared pytest fixtures for sdrf-skills tools tests.""" from __future__ import annotations import os from pathlib import Path import pytest EXAMPLES_DIR = Path(__file__).parent.parent / "examples" @pytest.fixture def synthetic_sdrf_path() -> Path: return EXAMPLES_DIR / "PXD_synthetic.sdrf.tsv" @pytest.fix...
bigbio/sdrf-skills
tests/conftest.py
.py
d7031da0b75b7076
8.1
15
"""Tests for tools.completeness — quality scoring.""" from __future__ import annotations from pathlib import Path import pytest from tools.completeness import score_sdrf, QualityReport, AGE_PATTERN, MS_PROTEOMICS_REQUIRED class TestScoreSdrf: def test_synthetic_sdrf_scores(self, synthetic_sdrf_path: Path): ...
bigbio/sdrf-skills
tests/test_completeness.py
.py
35e3780e43d82a95
8.1
15
"""Tests for tools.sdrf_fixer — auto-fixer.""" from __future__ import annotations from pathlib import Path import pytest from tools.sdrf_fixer import fix_sdrf, FixReport class TestFixSdrf: def test_synthetic_fixes_unimod_swap(self, synthetic_sdrf_path: Path): """Row 3 has UNIMOD:21 for Acetyl — should...
bigbio/sdrf-skills
tests/test_fixer.py
.py
6e4b32d7fb8268cf
8.1
15
"""Tests for tools.hallucination — ontology hallucination detector.""" from __future__ import annotations from pathlib import Path from unittest.mock import MagicMock, patch import pytest from tools.hallucination import ( HallucinationReport, detect_hallucinations, _check_unimod_swap, _check_modific...
bigbio/sdrf-skills
tests/test_hallucination.py
.py
1fbe3ab659dadd76
7.1
15
"""Tests for tools.ols_client payload normalisation.""" from __future__ import annotations from tools.ols_client import OLSClient, _collect_synonyms, _labels_match class TestCollectSynonyms: """OLS4 spells the synonym field three different ways. Regression tests: only ``synonyms`` was read, so every term r...
bigbio/sdrf-skills
tests/test_ols_client.py
.py
a0749660a40a3a28
8.1
15
"""Unified CLI entry point for sdrf-skills tools. Usage: python -m tools check <file.sdrf.tsv> # hallucination check python -m tools score <file.sdrf.tsv> # quality scoring python -m tools fix <file.sdrf.tsv> [-o out] # auto-fix python -m tools benchmark <PXD1> <file2> ... # benchmark ...
bigbio/sdrf-skills
tools/cli.py
.py
94b101b02a3dfdb8
7.6
15
"""Mapping from SDRF column names to expected ontology sources. Derived from TERMS.tsv `values` field and the sdrf-knowledge SKILL.md (formerly sdrf-terms). Used as a fallback when the spec submodule is not initialized. """ from __future__ import annotations from pathlib import Path from typing import Any # Maps ch...
bigbio/sdrf-skills
tools/column_ontology_map.py
.py
7d82e6ccf4171b0b
7.6
15
"""CLI source consistency for Muyan Pilot (Issue #152). The official local deployment is the EDITABLE uv tool install: uv tool install --force --reinstall --editable \\ --python /usr/bin/python3 <deployment checkout> The tool env's Python imports ``muyan_pilot`` directly from the deployment checkout (the...
xqliu/muyan-pilot
cli_source.py
.py
491e644d45be5a3c
7.42
6
"""Git transport contract (Issue #114). Two authentication channels with distinct responsibilities: - **Git data operations** (fetch, push — including pushing `.github/workflows/*.yml`) go over **SSH** (`git@github.com:owner/repo.git`), authenticated by the machine's SSH key. A workflow push must never depend o...
xqliu/muyan-pilot
git_transport.py
.py
e5780001d14dc03d
7.42
6
#!/usr/bin/env python3 """Live Pi session activity tracking (Issues #24, #40). Pi writes its session as an append-only JSONL file under the task worktree (`.pi-session/*.jsonl`) while it runs. This module follows that file and reduces it to a small, redacted activity snapshot: session id, event count, current phase, l...
xqliu/muyan-pilot
pi_activity.py
.py
e39aca5e733b361b
7.42
6
#!/usr/bin/env python3 """Idle-stall recovery for a running Pi session (Issue #94). A Pi session can stall while a tool call hangs forever (a `while True` test in the TDD red phase, a `next(generator)` that never returns, ...): the Pi process waits for its child, the session JSONL freezes, and the slot is held forever...
xqliu/muyan-pilot
pi_recovery.py
.py
852d5a0dce60ae11
7.42
6
"""Cross-process concurrency slots for Muyan Pilot (Issue #39). The local machine can only serve a limited number of concurrent Pilot tasks, so the configured ``max_concurrency`` is enforced with one slot file per allowed task under ``<repo_dir>/.muyan-pilot/slots/``. Each slot file is a plain file whose exclusive ``...
xqliu/muyan-pilot
pilot_slots.py
.py
2eb80e53901cc2db
7.42
6
#!/usr/bin/env python3 """Automatic GitHub progress publishing (Issue #18). The runner keeps exactly one live progress comment per run on the source Issue. The comment carries a hidden HTML run marker (`<!-- muyan-pilot:run=<run_id> -->`) so a restarted process finds the same comment again and keeps PATCHing it in pla...
xqliu/muyan-pilot
progress.py
.py
bfc758e8524b5a20
7.42
6
"""Systemd deployment consistency for Muyan Pilot (Issue #103, #149). The repo templates ``systemd/muyan-pilot@.service`` and ``systemd/muyan-pilot@.timer`` are the single source of truth for the user-level units. This module provides: - an idempotent install (overwrite-copy the templates into the user unit directo...
xqliu/muyan-pilot
systemd_deploy.py
.py
b854f6db26856e85
7.42
6
"""Shared test fixtures for the Muyan Pilot suite. The deployment preflights (Issue #103 unit drift, Issue #114 git transport) read the REAL machine state (the user unit directory, the checkout's ``origin`` remote, SSH connectivity); the in-process dispatch tests use tmp repo_dirs that carry no ``systemd/`` templates ...
xqliu/muyan-pilot
tests/conftest.py
.py
0dcf01de8043fddc
7.92
6
"""Guard the repository development contract. `AGENTS.md` is the stable contract every local Pi bootstrap run reads before changing code (see `prompt.md`). These tests fail when the file is missing or when a required contract item is removed, so the contract cannot silently drift away from the rules this repo actually...
xqliu/muyan-pilot
tests/test_agents_md.py
.py
20bc86fcf09e9d13
7.92
6
"""Regression tests for the GitHub Actions CI workflow (Issue #56). The repository contract (AGENTS.md) says the full pytest suite must run with 100% line/branch coverage via the coverage commands. Until now that only happened on the local Runner machine. The workflow in `.github/workflows/ci.yml` runs the same contra...
xqliu/muyan-pilot
tests/test_ci_workflow.py
.py
ec704d91efd39f0d
7.92
6
"""Chinese documentation contract (Issue #116). The Chinese docs live in `docs/zh/` (the verified Mintlify i18n layout: same structure as the default English pages at the `docs/` root) and keep the SAME single source of truth as the English pages — the implementation facts (labels, config fields, commands, ports, the ...
xqliu/muyan-pilot
tests/test_docs_i18n.py
.py
abd5483fa8b3a361
7.92
6
"""Documentation contract for GitHub external state (Issue #49). The README/AGENTS must document the labels, run markers, and recovery state exactly as the code implements them: every `ai-*` label the docs mention must exist in the runner's label set, the README must carry a label table with meaning/enter/leave for al...
xqliu/muyan-pilot
tests/test_docs_labels.py
.py
0048ab132d50f005
7.92
6
"""Mermaid diagram contract (Issue #116). The docs must ship two diagrams, in BOTH languages (English at the `docs/` root, Chinese under `docs/zh/`): 1. the system architecture overview (index page): GitHub Issues/PRs, the systemd timer/service, the Runner, the Pi sessions, the task worktree, the core llama-ser...
xqliu/muyan-pilot
tests/test_docs_mermaid.py
.py
3faf82cec9a08812
7.92
6
"""Release documentation contract (Issue #128). The docs `Releases`/`发布` group must mirror the REAL release state of the repository — verified against origin with `git ls-remote --tags origin` and `gh release list` (this run): tags `v0.1.0`, `v0.1.1`, `v0.1.2` exist; GitHub Releases `v0.1.1`, `v0.1.2` exist; **no `v0....
xqliu/muyan-pilot
tests/test_docs_releases.py
.py
2b4b126bb190ad91
7.92
6
"""Real git smoke tests for Issue #31 base-freeze behavior. These tests execute actual git commands inside a temporary local repository (no network, no remote push, no protected branch) and prove the acceptance criteria: - a task worktree is created from the latest ``origin/<base>`` even when the main worktree is c...
xqliu/muyan-pilot
tests/test_git_base_smoke.py
.py
f5211ca9f7e1e72e
7.92
6
"""Real git smoke tests for the auto review/fix/merge gate (Issue #34). These tests execute actual git commands inside a temporary local repository (no network, no remote push of a protected branch, no real GitHub merge) and prove the merge-gate acceptance criteria: - a PR head that contains the latest ``origin/<base...
xqliu/muyan-pilot
tests/test_git_merge_smoke.py
.py
a896ca9fb017208e
7.92
6
"""Guard the public repository license (Issue #81). `xqliu/muyan-pilot` is public, so the repository root must carry a license file GitHub can recognize. The Issue fixes Apache License 2.0 (SPDX identifier `Apache-2.0`) as the default and requires the README to link to the file. These tests fail when the file is missi...
xqliu/muyan-pilot
tests/test_license.py
.py
1c82a931f545d52a
7.92
6
"""v0.1.0 release reconciliation record (Issue #97). The release state reconciliation is a one-time GitHub-state task: the durable, auditable artifact in the repository is the reconciliation record ``docs/release-v0.1.0.md``. These tests pin that record against the REAL git history and the REAL CLI: - the tag/commit ...
xqliu/muyan-pilot
tests/test_release_v01.py
.py
e42ea5ba8ed5a349
7.92
6
"""Run artifacts stay out of version control (Issue #80 review round 1). `plan.md` and `test.log` are per-run artifacts written into the task worktree (prompt.md steps 2 and 5). A worktree is created from the frozen base SHA (`git worktree add ... <base_sha>`): if these files were tracked in the base, every new worktr...
xqliu/muyan-pilot
tests/test_run_artifacts.py
.py
2e985db0d684d40b
7.92
6
"""Regression tests for the systemd scheduling files (Issues #21, #33, #51, #149). The scheduler runs 24 hours a day: the idle polling interval is 5 minutes across the full day (00:00, 00:05, ..., 23:55). The timer must not add a task duration limit, must not queue catch-up ticks, and the README must document the same...
xqliu/muyan-pilot
tests/test_systemd_timer.py
.py
b29d15c44502bb39
7.92
6
"""MkDocs hooks: render builtin demos into standalone pages and splice them into the docs.""" import os import re import shutil import sys HERE = os.path.dirname(__file__) sys.path.insert(0, HERE) from demos import DEMOS from pyjinhx._component import BaseComponent, _pascal_to_snake from pyjinhx.assets import Asset...
paulomtts/pyjinhx
docs/hooks.py
.py
325dcdb27a42aa48
7.52
10
"""The todo example's FastAPI wiring: one app, four routes, no page shell. Every route returns a component and lets the adapter turn it into HTML — there is no HTMLResponse and no ctx= anywhere in this file, because PjxScopeMiddleware opens the request scope and injects the app context the components' load() methods r...
paulomtts/pyjinhx
examples/todo/app.py
.py
808e6add213b5bd9
7.52
10
from examples.todo.context import TodoAppContext from examples.todo.keys import Keys from pyjinhx import ReactiveComponent class ClearButton(ReactiveComponent, react={Keys.TODOS}): """The clear-completed action, disabled while nothing is completed.""" completed: int = 0 @classmethod def load(cls, ct...
paulomtts/pyjinhx
examples/todo/components/clear_button/clear_button.py
.py
babe0c62fd11790f
7.02
10
from examples.todo.context import TodoAppContext from examples.todo.keys import Keys from pyjinhx import ReactiveComponent class Counter(ReactiveComponent, react={Keys.TODOS}): """How many todos are still open.""" remaining: int = 0 @classmethod def load(cls, ctx: TodoAppContext | None = None) -> "C...
paulomtts/pyjinhx
examples/todo/components/counter/counter.py
.py
779871f5a253b89e
7.02
10
from examples.todo.components.item_row import ItemRow from examples.todo.context import TodoAppContext from examples.todo.keys import Keys from pyjinhx import ReactiveComponent class ItemList(ReactiveComponent, react={Keys.TODO_LIST}): """The list of todo rows.""" items: list[ItemRow] = [] # noqa: RUF012 --...
paulomtts/pyjinhx
examples/todo/components/item_list/item_list.py
.py
cd671bdd3dc783d8
7.52
10
from typing import Annotated from examples.todo.context import TodoAppContext from examples.todo.keys import Keys from pyjinhx import PjxKey, ReactiveComponent class ItemRow(ReactiveComponent, react={Keys.TODOS}): """One todo, keyed by its id so each row caches its own load result.""" todo_id: Annotated[int...
paulomtts/pyjinhx
examples/todo/components/item_row/item_row.py
.py
04a7c14efdb1b772
7.52
10
from examples.todo.context import TodoAppContext from examples.todo.keys import Keys from pyjinhx import ReactiveComponent class Total(ReactiveComponent, react={Keys.TODOS}): """How many todos exist in total.""" count: int = 0 @classmethod def load(cls, ctx: TodoAppContext | None = None) -> "Total":...
paulomtts/pyjinhx
examples/todo/components/total/total.py
.py
870d04ef62e20197
7.02
10
"""pyjinhx — server-rendered, htmx-wired components for Python web apps. This module re-exports the public API; advanced or internal usage lives in the submodules (`pyjinhx.reactive.keys`, `pyjinhx.reactive.mutations`, `pyjinhx.registry`, `pyjinhx.rendering`). """ from __future__ import annotations import sys import...
paulomtts/pyjinhx
pyjinhx/__init__.py
.py
b7f91ee488ac14ce
7.52
10
"""AppContext: the marker an app's own context class subclasses to be injectable. Import-pure on purpose - stdlib only, no pyjinhx imports - so the reactive load() wrap can reach down into it from class-definition time without adding an edge back into the render spine. Deliberately not PjxContext: that class is the f...
paulomtts/pyjinhx
pyjinhx/app_context.py
.py
b6ddf1829c71f1e7
7.52
10
"""L2.2 assets — delivery modes, emission, and the manifest of a request's assets.""" import hashlib import os from collections.abc import Callable, Iterable from dataclasses import dataclass from enum import Enum from pathlib import Path from typing import TYPE_CHECKING if TYPE_CHECKING: from pyjinhx.session imp...
paulomtts/pyjinhx
pyjinhx/assets.py
.py
2635ba23c9bc4993
7.52
10
from typing import Any from pydantic import Field, computed_field, field_validator from pyjinhx._component import AttrValue, BaseComponent, ExtraAttrs class PJXPaginator(BaseComponent): """A windowed pagination nav whose page links can drive HTMX swaps.""" page: int total_pages: int = Field(ge=1) u...
paulomtts/pyjinhx
pyjinhx/builtins/pjx_paginator/pjx_paginator.py
.py
d778e092140a5ee3
7.52
10
from __future__ import annotations from dataclasses import dataclass from typing import List, Tuple import torch from sglang.srt.layers.attention.utils import create_flashinfer_kv_indices_triton from sglang.srt.distributed import get_tp_group from sglang.srt.layers.logits_processor import LogitsProcessorOutput from ...
DocPang/qwen38-k100ai-int8-optimization
hotfixes/v1.2.2/patch/sglang/srt/speculative/dflash_info.py
.py
f24f1bb01ee93e78
7
9
#!/usr/bin/env python3 """PreToolUse hook: block cross-user DM sends via the bus primitive (ms-110 / e-3444). Reads the Claude Code PreToolUse event on stdin and, when the tool call is a cross-project (potentially cross-user) DM sent by calling the bus primitive directly — not via /beacon-dm-send and without a valid o...
kurogin23mech-source/beacon
.archive/ms-110-hook-shelved/beacon-pretooluse-dm-guard.py
.py
9a0ae09a600d5d53
7.5
9
"""Beacon FirestoreStore - Cloud-backed project storage. Stores the entire project.json as a single Firestore document. Collection: projects/{project_id} """ from __future__ import annotations import json from datetime import datetime class FirestoreStore: """Store implementation backed by Google Cloud Firesto...
kurogin23mech-source/beacon
.trash/store_firestore.py
.py
003e976d97423c95
7.5
9
"""beacon-find-root — Python entry-point for the project-root walk-up helper. Mirrors the behaviour of ``bin/beacon-find-root`` (shell script) so that ``pip install beacon`` produces a ``beacon-find-root`` / ``beacon-find-root.exe`` binary in the user's Scripts directory. The Skills shipped under ``skills/*.md`` call ...
kurogin23mech-source/beacon
beacon_cli/find_root.py
.py
8eb390fac50d4cbd
7.5
9
"""PostToolUse hook: surface STOP signals to the AI (ms-55 e-1721). Companion to ``post_commit.py`` (commit detection) and ``save_hook.py`` (MCP auto-save). This hook closes the loop on the "止まる側" half of ms-55 SPEC: after every tool call, check whether the inbox-side hook has dropped a ``halt-request.json`` on disk f...
kurogin23mech-source/beacon
beacon_cli/hooks/halt_check.py
.py
46ce752f8526e1bd
7.5
9
"""Cross-platform MCP save hook (PostToolUse, matcher: mcp__). Python translation of ``bin/beacon-save-hook.sh`` (ms-44 e-777). Watches for MCP write operations against the Google Drive integration and auto-records them as ``beacon save`` entries under the currently active milestone. Bash → Python contract notes: *...
kurogin23mech-source/beacon
beacon_cli/hooks/save_hook.py
.py
42f771b3a925de1a
7.5
9
"""SessionStart hook: beacon の自動アップデート (ms-103)。 bclaude セッション開始時に呼ばれ、新しい版が出ていれば自動でインストールする。 サーバに新機能が入っても各ユーザーの CLI / bridge が古いままだと全面適用が遅れる ため、起動を機に自然に最新へ追従させる。 契約 (= Claude Code SessionStart hook): * Stdin: SessionStart JSON (中身は使わないが pipe を詰まらせないよう drain する)。 * Stdout: 空 (通知が要るときだけ 1 行。セッション開始をブロックしない)...
kurogin23mech-source/beacon
beacon_cli/hooks/session_start.py
.py
519c04970dcb0aa8
7.5
9
"""Cross-project session discovery for /beacon-dm-send. Two discovery sources are supported: 1. **Server-first (cloud-first identity, ms-62 / e-1502)**: ask the cloud server for the user's project memberships via ``GET /api/me/projects``, then query each project's ``beacon bus directory`` (= live session list) ...
kurogin23mech-source/beacon
beacon_cli/skills_helpers/dm_discover.py
.py
b6ace4694fb9c514
7.5
9
"""Stable-recipient-identity resolve (ms-93 / e-2520). `session_id` (sid) is an ephemeral *route token*, not an identity: a bridge restart or a Codex daemon re-mint produces a fresh sid, so a sender that remembers a raw sid ends up addressing a session that died a minute ago (observed repeatedly 2026-07-07: a DNS-cuto...
kurogin23mech-source/beacon
beacon_cli/skills_helpers/identity_resolve.py
.py
4e50a647f4a39cc6
7.5
9
#!/usr/bin/env python3 """bin/context-usage-monitor.py — standalone Stop hook (ms-44 e-854). Single-file Python port of ``bin/context-usage-monitor.sh`` so Windows pipx users (no bash, no jq) can register Claude Code's Stop hook by absolute path: { "hooks": { "Stop": [{ "matcher": "", ...
kurogin23mech-source/beacon
bin/context-usage-monitor.py
.py
17ccfcdbbd339c45
7.5
9
"""Reference ``beacon_sink`` for headless machines (PE detector Lambda 等) — ms-151. 外部の常駐プログラム (人が介在しない machine) が、自分の run_record (運転記録) と incident (異常記録) を Beacon cloud へ直接書くための **差し替え口の参照実装**。PE detector Lambda は既存の ``beacon_sink`` stub をこのクラスに差し替えるだけで書ける。 依存は標準ライブラリのみ (urllib)。Lambda に requests 等を同梱しなくても動く。 ## 使い...
kurogin23mech-source/beacon
docs/integrations/beacon_sink.py
.py
8deaf990cf683931
7.5
9
"""Attack-list schema for inside-sales acquisition (ms-132 e-4501). An *attack list* is the concrete shape ms-132 puts on top of the generic ms-131 table-doc primitive: a table linked to an Acquisition (``acq-``) whose every row is one prospect Account to reach out to. This module owns the canonical column schema — Ac...
kurogin23mech-source/beacon
lib/attack_list.py
.py
6d4ac39aedd8e09e
7.5
9
r"""Branch name helpers for the ms-51 branch-driven workflow. The single export is :func:`ms_branch_name`, which takes an MS id and an MS title and returns the canonical branch name used by ``beacon ms start`` and ``beacon ms join --checkout``. Format:: ms-<id_number>-<slug> Where ``<slug>`` is derived from the...
kurogin23mech-source/beacon
lib/branch.py
.py
da3c471137cce5e0
7.5
9
from scapy.all import wrpcap, rdpcap from utils.logger import log class PCAPManager: """ Handles PCAP import/export functionality Compatible with Wireshark """ def export_pcap(self, packets, filename): """ Export captured packets to PCAP file packets: list of Sc...
mwakidenis/Network-Packet-Sniffer-Traffic-Analyse-GUI
network-sniffer/core/pcap_manager.py
.py
a21cc0a53473260c
7.65
19
from PySide6.QtCore import QThread, Signal import pyshark import asyncio from utils.logger import log class PySharkSniffer(QThread): packet_signal = Signal(object) # Set your TShark path here TSHARK_PATH = r"D:\Wireshark\tshark.exe" def __init__(self, iface): super().__init__() self.i...
mwakidenis/Network-Packet-Sniffer-Traffic-Analyse-GUI
network-sniffer/core/pyshark_sniffer.py
.py
3c6b040f247eb71d
7.65
19
"""Measure local five-layer tool-call decision latency. This is a local measurement utility, not a cross-host performance guarantee. Run after installing the server extra: python benchmark/tool_call_latency.py --iterations 200 """ from __future__ import annotations import argparse import json import statistics i...
poojakira/mcp-agent-security-gateway
benchmark/tool_call_latency.py
.py
636234bee04c9a01
7.63
17
"""Locust load test for MCP Security Gateway Monitor. Target: 5000 requests/second sustained throughput. Run with: locust -f locustfile.py --host=http://localhost:8080 --users 500 --spawn-rate 50 For headless mode targeting 5000 req/s: locust -f locustfile.py --host=http://localhost:8080 \ --users 10...
poojakira/mcp-agent-security-gateway
locustfile.py
.py
e7f3be2d293da63b
7.63
17
"""Cryptographic tool manifest signing and verification. WHY THIS EXISTS: Anthropic's position on the MCP STDIO RCE flaw was that "securing the STDIO interface is the responsibility of whoever deploys it, not of the protocol." This means there is ZERO protocol-level assurance that a tool's schema, description, or capa...
poojakira/mcp-agent-security-gateway
src/mcp_monitor/advanced/manifest.py
.py
346c1a0380e9cad9
7.63
17
"""Client middleware for routing real MCP tool calls through the security gateway. This is how a live product feed is produced: wrap your agent's tool-execution function with ``guard()``. Every tool call is scanned by the running gateway (POST /api/scan), which streams the verdict to the live dashboard and blocks call...
poojakira/mcp-agent-security-gateway
src/mcp_monitor/client.py
.py
187c59059125763c
7.63
17
"""Terminal-based report renderer for MCP security simulations. Displays catalog replay results with color-coded severity, layer-by-layer breakdown, and scoped defense statistics for the supplied simulation report. """ from __future__ import annotations import time from typing import Any from mcp_monitor.redteam.si...
poojakira/mcp-agent-security-gateway
src/mcp_monitor/dashboard/terminal.py
.py
97f5b48937536bad
7.63
17
"""Layer B: DPI egress proxy — compares MCP INTENT vs ACTUAL network call. THE KEY INSIGHT THAT DEFEATS THE POSTMARK ATTACK: The MCP tool call says: send to ['user@company.com']. The actual HTTP POST to api.postmarkapp.com says: To=user@company.com, Bcc=phan@giftshop.club. If you compare the two, the discrepancy ...
poojakira/mcp-agent-security-gateway
src/mcp_monitor/defense10/egress_proxy.py
.py
5ab90b70de827742
7.63
17
"""Honeypot / canary token system. WHY THIS CATCHES ATTACKS EVERY OTHER LAYER MISSES: Plant fake secrets ("canary tokens") in the environment — a fake API key, a fake password, a fake customer record. No legitimate workflow ever uses them. If one of these EVER appears in an outbound tool call, you have a high-confiden...
poojakira/mcp-agent-security-gateway
src/mcp_monitor/defense10/honeypot.py
.py
d461e9af55394784
7.63
17
"""10-layer defense orchestrator for combining available signals into one verdict. Chains the original 5 layers with the defense10 components: L1 Application detectors (regex, PII, shadow, exfil) L2 Inline proxy enforcement L3 Kernel/network monitor (/proc + eBPF) — sees server-side calls L4 ...
poojakira/mcp-agent-security-gateway
src/mcp_monitor/defense10/orchestrator10.py
.py
3b5cdc697fea2679
7.63
17
"""Layer 5+ : Rate limiting + recipient whitelist (BLAST RADIUS LIMITING). WHY THIS IS THE MOST IMPORTANT LAYER AGAINST A DETERMINED ADVERSARY: Detection is never 100%. Something eventually evades every filter. So the final defense is: even if the attack SUCCEEDS, cap the damage. The Postmark attack exfiltrated 3,000...
poojakira/mcp-agent-security-gateway
src/mcp_monitor/defense10/rate_limiter.py
.py
97e3fc335e8b79a0
7.63
17
"""Layer A: REAL Docker/OCI sandbox isolation for untrusted MCP servers. WHY THIS IS THE STRONGEST SINGLE CONTROL: If the MCP server runs in a container with '--network none' (or only an egress proxy), it CANNOT connect to giftshop.club no matter what its code does. The kernel enforces the boundary. The attacker's one...
poojakira/mcp-agent-security-gateway
src/mcp_monitor/defense10/sandbox.py
.py
d33bf5829e17fa4e
7.63
17
"""Alerting hooks for critical security findings. Posts JSON webhooks to configurable URLs (Slack/PagerDuty compatible) when findings exceed a risk threshold. Uses fire-and-forget threading. """ from __future__ import annotations import json import threading import time import urllib.error import urllib.parse import...
poojakira/mcp-agent-security-gateway
src/mcp_monitor/production/alerting.py
.py
f0d52c3e96fadf4d
7.63
17
"""Circuit breaker pattern for defense layers. Prevents cascading failures by opening the circuit after consecutive errors, then probing with half-open state after a timeout. """ from __future__ import annotations import enum import threading import time from collections.abc import Callable from typing import Any ...
poojakira/mcp-agent-security-gateway
src/mcp_monitor/production/circuit_breaker.py
.py
6cd9324e8c626775
7.63
17
"""Configuration via environment variables (12-factor app). All settings are read from os.environ with sensible defaults. """ from __future__ import annotations import os class Config: """Production configuration read from environment variables.""" def __init__(self) -> None: self.listen_host: str...
poojakira/mcp-agent-security-gateway
src/mcp_monitor/production/config.py
.py
9705c56012213e71
7.63
17
"""Structured JSON logging using stdlib logging module. Produces ELK/Datadog-compatible JSON log entries with trace context. """ from __future__ import annotations import json import logging import time from typing import Any class JSONFormatter(logging.Formatter): """Formats log records as JSON with trace con...
poojakira/mcp-agent-security-gateway
src/mcp_monitor/production/logging.py
.py
591f97d858f7dc96
7.63
17
""" Base class for diagnostic CLI to centralize common operations. """ from aqua.core.logger import log_configure from aqua.core.util import get_arg from aqua.core.version import __version__ as aqua_version from .defaults import SAVE_FORMAT from .util import close_cluster, load_diagnostic_config, merge_config_args, o...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/base/cli_base.py
.py
3f02f0905dae9659
7.45
7
"""Module containing functions necessary to add metadata to different output formats.""" import os import xml.etree.ElementTree as ET from PIL import Image, PngImagePlugin from pypdf import PdfReader, PdfWriter from aqua.core.logger import log_configure def add_pdf_metadata(pdf_path: str, metadata: dict, loglevel:...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/base/metadata.py
.py
c6892c13bcba6fab
7.45
7
""" String utility functions for AQUA diagnostics. """ import re def collapse_era5_duplicate(text: str) -> str: """ ERA5 is catalogued with both model ('ERA5') and experiment ('era5'), which would otherwise render as the duplicate 'ERA5 era5' in titles and captions. Args: text (str): Title o...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/base/strings.py
.py
2f3de01a166f91a9
7.45
7
"""Time utilities for AQUA diagnostics""" import pandas as pd def start_end_dates(startdate=None, enddate=None, start_std=None, end_std=None): """ Evaluate start and end dates for data retrieve so Reader call covers also the std-dates when set. They should be of the form 'YYYY-MM-DD' or 'YYYYMMDD'. ...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/base/time_util.py
.py
26247351ccc68271
7.45
7
""" Title generation class and utilities for AQUA plots. """ from typing import Optional, Union from aqua.core.util import strlist_to_phrase, to_list from .strings import collapse_era5_duplicate, harmonize_lists class TitleBuilder: """ Class to generate standardized titles for AQUA plots. Args: ...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/base/title.py
.py
cccd24efff739362
7.45
7
""" Utility functions for the CLI """ import argparse import os from dask.distributed import Client, LocalCluster from aqua.core.configurer import ConfigPath from aqua.core.logger import log_configure from aqua.core.util import get_arg, load_yaml def template_parse_arguments(parser: argparse.ArgumentParser): "...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/base/util.py
.py
7cbc543b711d9ca6
7.45
7
"""Command-line interface for Biases diagnostic.""" import argparse import sys from aqua.core.exceptions import NoDataError from aqua.core.util import to_list from aqua.diagnostics import Climatology, PlotBias from aqua.diagnostics.base import DiagnosticCLI, template_parse_arguments TOOLNAME = "Biases" TOOLNAME_KEY ...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/biases/cli_biases.py
.py
5a3da470c4f9b6bd
7.45
7
"""Module for computing and plotting boxplots of field means from climate model datasets.""" import pandas as pd import xarray as xr from aqua.core.logger import log_configure from aqua.core.util import to_list from aqua.diagnostics.base import Diagnostic class Boxplots(Diagnostic): """Class for computing and p...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/boxplots/boxplots.py
.py
175bb2fd3ecc3d43
7.45
7
"""Command-line interface for Boxplots diagnostic.""" import argparse import sys from aqua.core.exceptions import NotEnoughDataError from aqua.diagnostics import Boxplots, PlotBoxplots from aqua.diagnostics.base import DiagnosticCLI, template_parse_arguments # default tool name TOOLNAME = "Boxplots" TOOLNAME_KEY = T...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/boxplots/cli_boxplots.py
.py
26d0669d3de559ab
7.45
7
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ AQUA ECmean4 Performance diagnostic CLI """ import argparse import os import sys import xarray as xr from ecmean import __version__ as eceversion from aqua import Reader from aqua import __version__ as aquaversion from aqua.core.configurer import ConfigPath from aqu...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/ecmean/cli_ecmean.py
.py
01002fb3cbaedc6d
7.45
7
# ruff: noqa: N999 import xarray as xr from aqua.core.logger import log_configure # from aqua.exceptions import NoDataError from .base import BaseMixin from .util import compute_statistics xr.set_options(keep_attrs=True) class EnsembleTimeseries(BaseMixin): """ This class computes mean and standard deviati...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/ensemble/ensembleTimeseries.py
.py
9100d24fac2d3f09
7.45
7
""" Utility functions for the ensemble class """ import gc from collections import Counter import numpy as np import pandas as pd import xarray as xr from aqua import Reader from aqua.core.configurer import ConfigPath from aqua.core.exceptions import NoDataError from aqua.core.logger import log_configure def reade...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/ensemble/util.py
.py
3d7e98103181faba
7.45
7
#!/usr/bin/env python3 """Command-line interface for Histogram diagnostic.""" import argparse import sys from aqua.diagnostics.base import DiagnosticCLI, load_var_config, template_parse_arguments from aqua.diagnostics.histogram import Histogram, PlotHistogram def parse_arguments(args): """Parse command-line arg...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/histogram/cli_histogram.py
.py
a5b1447ef8c04d8d
7.45
7
from aqua.core.fixer import EvaluateFormula from aqua.core.histogram import histogram from aqua.core.logger import log_configure from aqua.diagnostics.base import Diagnostic class Histogram(Diagnostic): """ Class to compute histograms and probability density functions (PDFs) of a variable over a specified...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/histogram/histogram.py
.py
1279a43638bfe849
7.45
7
from typing import Union import matplotlib.pyplot as plt from aqua.core.graphics import plot_histogram from aqua.core.logger import log_configure from aqua.core.util import DEFAULT_REALIZATION, time_to_string, to_list from aqua.diagnostics.base import SAVE_FORMAT, OutputSaver, TitleBuilder, collapse_era5_duplicate ...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/histogram/plot_histogram.py
.py
e2faa71d228efb79
7.45
7
""" Command-line interface for LatLonProfiles diagnostic. This CLI allows to run the LatLonProfiles diagnostic for zonal or meridional profiles. Details of the run are defined in a yaml configuration file for a single or multiple experiments. """ import argparse import sys from aqua.core.exceptions import NotEnoughD...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/lat_lon_profiles/cli_lat_lon_profiles.py
.py
2bbdffcf8182f55b
7.45
7
#!/usr/bin/env python3 """Command-line interface for Ocean drift diagnostic. This CLI allows to run the hovmoller, OceanDrift diagnostics. Details of the run are defined in a yaml configuration file for a single or multiple experiments. """ import argparse import sys from aqua.core.util import to_list from aqua.diag...
DestinE-Climate-DT/AQUA-diagnostics
aqua/diagnostics/ocean_drift/cli_ocean_drift.py
.py
bd94186791af020f
7.45
7
import os import importlib.util from pathlib import Path from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from sqlalchemy import text from src.api.routes import auth, users, products, inventory, invoices, ledgers, company, payments, smtp, email as email_routes, shortcuts, invoice_series ...
nikhilb2/simple_invoicing
backend/app_main.py
.py
9664e338d6403f83
7.5
9
""" Add buyer/company snapshot columns to invoices """ from sqlalchemy import text def up(conn) -> None: columns = { "buyer_id": "ALTER TABLE invoices ADD COLUMN buyer_id INTEGER", "buyer_name": "ALTER TABLE invoices ADD COLUMN buyer_name VARCHAR", "buyer_address": "ALTER TABLE invoices A...
nikhilb2/simple_invoicing
backend/migrations/20260101000001_add_buyer_company_to_invoices.py
.py
1db3dda1ae2f7ab0
7.5
9
""" Add extended fields to company_profiles """ from sqlalchemy import text def up(conn) -> None: columns = { "currency_code": "ALTER TABLE company_profiles ADD COLUMN currency_code VARCHAR", "email": "ALTER TABLE company_profiles ADD COLUMN email VARCHAR", "website": "ALTER TABLE company...
nikhilb2/simple_invoicing
backend/migrations/20260101000002_add_extended_company_fields.py
.py
1dae81007f2c3bda
7.5
9