everything-gemini 2.2.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BENCHMARK.md +33 -33
- package/CHANGELOG.md +84 -0
- package/README.md +91 -6
- package/agents/cross-repo-orchestrator.md +33 -0
- package/agents/darwin-prompt-engineer.md +35 -0
- package/agents/resilience-engineer.md +36 -0
- package/agents/swarm-coordinator.md +35 -0
- package/bin/everything-gemini +1175 -13
- package/docs/LAUNCH_KIT_PHP2SHELL.md +240 -0
- package/docs/LAUNCH_KIT_v2.4.0.md +164 -0
- package/docs/LAUNCH_KIT_v2.5.0.md +187 -0
- package/docs/LAUNCH_KIT_v2.6.0.md +174 -0
- package/docs/index.html +32 -14
- package/examples/python-sdk/cross_repo_swarm_and_compaction.py +175 -0
- package/examples/python-sdk/ephemeral_swarm_orchestration.py +169 -0
- package/examples/python-sdk/resilience_and_telemetry_pipeline.py +183 -0
- package/hooks/context-compactor/hooks.json +16 -0
- package/hooks/context-compactor/scripts/compact-context.sh +40 -0
- package/hooks/drift-detector/hooks.json +16 -0
- package/hooks/drift-detector/scripts/detect-drift.sh +50 -0
- package/hooks/thinking-budget/hooks.json +16 -0
- package/hooks/thinking-budget/scripts/budget-thinking.sh +56 -0
- package/package.json +1 -1
- package/skills/adversarial-fuzz-generator/SKILL.md +95 -0
- package/skills/context-distillation-compressor/SKILL.md +109 -0
- package/skills/cost-oracle-finops/SKILL.md +142 -0
- package/skills/cross-repo-swarm-sync/SKILL.md +122 -0
- package/skills/cve-remediation-orchestrator/SKILL.md +111 -0
- package/skills/cve-remediation-orchestrator/scripts/verify-host-hardening.sh +72 -0
- package/skills/dynamic-thinking-allocation/SKILL.md +105 -0
- package/skills/ebpf-microvm-sandbox/SKILL.md +113 -0
- package/skills/ebpf-sandbox-enforcer/SKILL.md +101 -0
- package/skills/envoy-ai-gateway/SKILL.md +175 -0
- package/skills/ephemeral-swarm-orchestrator/SKILL.md +124 -0
- package/skills/gemini-live-multimodal/SKILL.md +149 -0
- package/skills/gemini-live-screen-vision/SKILL.md +109 -0
- package/skills/genetic-prompt-cross-pollinator/SKILL.md +110 -0
- package/skills/harness3-mutation-testing/SKILL.md +120 -0
- package/skills/instinct-distillation-compiler/SKILL.md +103 -0
- package/skills/opentelemetry-agent-observability/SKILL.md +139 -0
- package/skills/php2shell-version-auditor/SKILL.md +95 -0
- package/skills/phpcheck-server/SKILL.md +102 -0
- package/skills/phpcheck-server/scripts/audit-server.sh +112 -0
- package/skills/phpcheck-url/SKILL.md +72 -0
- package/skills/phpcheck-url/scripts/phpcheck.js +160 -0
- package/skills/quantum-safe-cryptography/SKILL.md +84 -0
- package/skills/spanner-change-streams/SKILL.md +88 -0
- package/skills/speculative-decoding-orchestrator/SKILL.md +108 -0
- package/skills/vertex-ai-feature-store/SKILL.md +110 -0
- package/skills/webrtc-agent-gateway/SKILL.md +199 -0
- package/tests/cli.test.js +253 -14
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cost-oracle-finops
|
|
3
|
+
description: Pre-flight predictive token cost modeling, spend budgeting, and pricing tier optimization for Gemini 2.0 Flash, Pro, and Gemini 3.8 extended reasoning agents.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Cost Oracle & FinOps Agent Modeling
|
|
7
|
+
|
|
8
|
+
Implements pre-flight predictive token cost estimation, model pricing tier arbitrage, and autonomous budget forecasting for multi-agent workflows across Google Gemini 2.0 Flash, Gemini 2.0 Pro, and Gemini 3.8 models.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 1. Architecture: Pre-Flight Financial Oracle
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
16
|
+
│ PRE-FLIGHT COST ORACLE ENGINE │
|
|
17
|
+
│ │
|
|
18
|
+
│ ┌─────────────────────┐ │
|
|
19
|
+
│ │ Proposed Task & │ │
|
|
20
|
+
│ │ Subagent Trajectory │ │
|
|
21
|
+
│ └──────────┬──────────┘ │
|
|
22
|
+
│ │ │
|
|
23
|
+
│ ▼ │
|
|
24
|
+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
|
|
25
|
+
│ │ 1. Token Predictor (Context Caching vs. Dynamic Suffix Heuristics) │ │
|
|
26
|
+
│ │ • System & Skill Frontmatter Tokens │ │
|
|
27
|
+
│ │ • Expected Reasoning Depth (Extended Thinking Tokens) │ │
|
|
28
|
+
│ │ • Tool Call Frequency & Speculative Probing Branches │ │
|
|
29
|
+
│ └──────────────────────────────────┬──────────────────────────────────┘ │
|
|
30
|
+
│ │ │
|
|
31
|
+
│ ▼ │
|
|
32
|
+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
|
|
33
|
+
│ │ 2. FinOps Pricing Engine (Per Model Rates & Discount Tiers) │ │
|
|
34
|
+
│ │ • Gemini 2.0 Flash: $0.075 / 1M input, $0.30 / 1M output │ │
|
|
35
|
+
│ │ • Context Caching: 75% input discount ($0.01875 / 1M input) │ │
|
|
36
|
+
│ │ • Gemini 2.0 Pro: $1.25 / 1M input, $5.00 / 1M output │ │
|
|
37
|
+
│ └──────────────────────────────────┬──────────────────────────────────┘ │
|
|
38
|
+
│ │ │
|
|
39
|
+
│ ▼ │
|
|
40
|
+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
|
|
41
|
+
│ │ 3. Pre-Flight Financial Gating (Pass / Downgrade / Deny) │ │
|
|
42
|
+
│ │ • If Expected Cost > MAX_USD_BUDGET -> Abort or switch to Flash │ │
|
|
43
|
+
│ │ • If Expected Cost <= Budget Ceiling -> Issue Financial Clearance │ │
|
|
44
|
+
│ └─────────────────────────────────────────────────────────────────────┘ │
|
|
45
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 2. Mathematical Cost Modeling Formula
|
|
51
|
+
|
|
52
|
+
Let $T_{in}$ be input tokens, $T_{cache}$ be context-cached prefix tokens, $T_{out}$ be output generation tokens, and $T_{think}$ be internal reasoning tokens:
|
|
53
|
+
|
|
54
|
+
$$\text{Cost} = (T_{cache} \times P_{cache}) + ((T_{in} - T_{cache}) \times P_{in}) + ((T_{out} + T_{think}) \times P_{out})$$
|
|
55
|
+
|
|
56
|
+
Where for **Gemini 2.0 Flash**:
|
|
57
|
+
- $P_{in} = \$0.075 / 10^6$
|
|
58
|
+
- $P_{cache} = \$0.01875 / 10^6$
|
|
59
|
+
- $P_{out} = \$0.30 / 10^6$
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 3. Python Pre-Flight Cost Estimator
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from dataclasses import dataclass
|
|
67
|
+
from typing import Dict, Any
|
|
68
|
+
|
|
69
|
+
@dataclass
|
|
70
|
+
class CostEstimate:
|
|
71
|
+
model: str
|
|
72
|
+
expected_input_tokens: int
|
|
73
|
+
cached_prefix_tokens: int
|
|
74
|
+
expected_output_tokens: int
|
|
75
|
+
expected_thinking_tokens: int
|
|
76
|
+
estimated_usd: float
|
|
77
|
+
confidence_interval: tuple[float, float]
|
|
78
|
+
|
|
79
|
+
class FinOpsCostOracle:
|
|
80
|
+
RATES = {
|
|
81
|
+
"gemini-2.0-flash": {
|
|
82
|
+
"input": 0.075 / 1_000_000,
|
|
83
|
+
"cache": 0.01875 / 1_000_000,
|
|
84
|
+
"output": 0.30 / 1_000_000
|
|
85
|
+
},
|
|
86
|
+
"gemini-2.0-pro": {
|
|
87
|
+
"input": 1.25 / 1_000_000,
|
|
88
|
+
"cache": 0.3125 / 1_000_000,
|
|
89
|
+
"output": 5.00 / 1_000_000
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
def estimate_task_cost(
|
|
94
|
+
self,
|
|
95
|
+
model: str,
|
|
96
|
+
prompt_length: int,
|
|
97
|
+
active_skills_count: int,
|
|
98
|
+
estimated_turns: int = 5,
|
|
99
|
+
uses_extended_thinking: bool = False
|
|
100
|
+
) -> CostEstimate:
|
|
101
|
+
rates = self.RATES.get(model, self.RATES["gemini-2.0-flash"])
|
|
102
|
+
|
|
103
|
+
# Heuristics based on empirical benchmarks
|
|
104
|
+
cached_prefix = 32_768 if active_skills_count > 10 else 0
|
|
105
|
+
input_per_turn = prompt_length + (active_skills_count * 250)
|
|
106
|
+
output_per_turn = 800
|
|
107
|
+
thinking_per_turn = 2048 if uses_extended_thinking else 0
|
|
108
|
+
|
|
109
|
+
total_input = input_per_turn * estimated_turns
|
|
110
|
+
total_output = output_per_turn * estimated_turns
|
|
111
|
+
total_thinking = thinking_per_turn * estimated_turns
|
|
112
|
+
|
|
113
|
+
cost = (
|
|
114
|
+
(cached_prefix * rates["cache"]) +
|
|
115
|
+
(max(0, total_input - cached_prefix) * rates["input"]) +
|
|
116
|
+
((total_output + total_thinking) * rates["output"])
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
# 95% Confidence Interval (+/- 25% due to variable branching)
|
|
120
|
+
ci = (round(cost * 0.75, 4), round(cost * 1.35, 4))
|
|
121
|
+
|
|
122
|
+
return CostEstimate(
|
|
123
|
+
model=model,
|
|
124
|
+
expected_input_tokens=total_input,
|
|
125
|
+
cached_prefix_tokens=cached_prefix,
|
|
126
|
+
expected_output_tokens=total_output,
|
|
127
|
+
expected_thinking_tokens=total_thinking,
|
|
128
|
+
estimated_usd=round(cost, 4),
|
|
129
|
+
confidence_interval=ci
|
|
130
|
+
)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 4. Enterprise FinOps Best Practices
|
|
136
|
+
|
|
137
|
+
| Strategy | Action | Benefit |
|
|
138
|
+
| :--- | :--- | :--- |
|
|
139
|
+
| **Model Cascading** | Use Gemini 2.0 Flash for verification; reserve Pro for system design | Up to 80% cost reduction |
|
|
140
|
+
| **Prefix Freezing** | Maintain minimum 32,768 tokens in static prefix to qualify for context caching | 75% discount on repeated turns |
|
|
141
|
+
| **Budget Ceiling** | Enforce `--max-usd` via `hooks/budget-guard` | Guarantees zero surprise runaway charges |
|
|
142
|
+
| **Thinking Caps** | Constrain `max_thinking_tokens` on speculative probes | Prevents unbounded internal reasoning loops |
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cross-repo-swarm-sync
|
|
3
|
+
description: Coordinates distributed cross-repository multi-agent swarm synchronization, atomic dependency alignment, and cross-boundary git branch PR orchestration via Google Cloud Pub/Sub and Cloud Run.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Cross-Repository Swarm Synchronization (`cross-repo-swarm-sync`)
|
|
7
|
+
|
|
8
|
+
Coordinates distributed multi-repository agent swarm synchronization, atomic dependency alignment, bidirectional contract schema propagation, and orchestrated cross-repository git branch workflows across frontends, backend microservices, and infrastructure-as-code repositories.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 1. Architectural Topology: Cross-Repository Swarm Coordination
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
16
|
+
│ CROSS-REPOSITORY SWARM SYNC TOPOLOGY │
|
|
17
|
+
│ │
|
|
18
|
+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
|
|
19
|
+
│ │ 1. Global Multi-Repo Orchestrator (`cross-repo-orchestrator`) │ │
|
|
20
|
+
│ │ • Scans multi-repository dependency graph & git submodule state │ │
|
|
21
|
+
│ │ • Emits transactional coordination events via Cloud Pub/Sub │ │
|
|
22
|
+
│ └──────────────────────────────────┬──────────────────────────────────┘ │
|
|
23
|
+
│ │ │
|
|
24
|
+
│ ▼ │
|
|
25
|
+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
|
|
26
|
+
│ │ 2. Asynchronous Event Mesh (Google Cloud Pub/Sub & Cloud Tasks) │ │
|
|
27
|
+
│ │ • Topic: `agent-swarm-cross-repo-sync` (ordering keys enabled) │ │
|
|
28
|
+
│ │ • Schema Registry: Protobuf v3 contracts & OpenAPI specifications│ │
|
|
29
|
+
│ └───────────────┬──────────────────┬──────────────────┬───────────────┘ │
|
|
30
|
+
│ │ │ │ │
|
|
31
|
+
│ ▼ ▼ ▼ │
|
|
32
|
+
│ ┌────────────────────────┐ ┌────────────────┐ ┌───────────────────────┐ │
|
|
33
|
+
│ │ Repo A: Core Services │ │ Repo B: UI Web │ │ Repo C: Terraform K8s │ │
|
|
34
|
+
│ │ • Subagent Worker #1 │ │ • Subagent #2 │ │ • Subagent Worker #3 │ │
|
|
35
|
+
│ │ • Generates gRPC types │ │ • Updates SDK │ │ • Configures Ingress │ │
|
|
36
|
+
│ └───────────────┬────────┘ └────────┬───────┘ └───────────┬───────────┘ │
|
|
37
|
+
│ │ │ │ │
|
|
38
|
+
│ └───────────────────┼─────────────────────┘ │
|
|
39
|
+
│ ▼ │
|
|
40
|
+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
|
|
41
|
+
│ │ 3. Atomic Multi-Repo Verification & Branch Synchronization │ │
|
|
42
|
+
│ │ • Two-Phase Commit (2PC) verification across all repository PRs │ │
|
|
43
|
+
│ │ • Matrix E2E integration testing across linked feature branches │ │
|
|
44
|
+
│ │ • Coordinated merge gating & rollback safety snapshots │ │
|
|
45
|
+
│ └─────────────────────────────────────────────────────────────────────┘ │
|
|
46
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 2. Core Operational Capabilities
|
|
52
|
+
|
|
53
|
+
### A. Dynamic Repository Discovery & Dependency Matrix
|
|
54
|
+
1. **Workspace Manifest Registry**:
|
|
55
|
+
- Parses multi-workspace configurations (`workspaces.json` or `.agents/repositories.json`).
|
|
56
|
+
- Identifies upstream/downstream contract dependencies across gRPC, OpenAPI, and shared schemas.
|
|
57
|
+
2. **Topological Order Execution**:
|
|
58
|
+
- Computes topological sort DAG over dependent repositories.
|
|
59
|
+
- Enforces strict sequencing: upstream API definitions -> client SDK generation -> frontend components -> deployment manifests.
|
|
60
|
+
|
|
61
|
+
### B. Two-Phase Commit (2PC) Swarm Gating
|
|
62
|
+
1. **Prepare Phase**:
|
|
63
|
+
- Every repository agent performs isolated git branching, code generation, and local test validation.
|
|
64
|
+
- Posts a signed verification hash (`READY_TO_MERGE`) to the shared coordination ledger.
|
|
65
|
+
2. **Commit / Rollback Phase**:
|
|
66
|
+
- If all repository workers report verification success, the orchestrator issues atomic merge signals.
|
|
67
|
+
- If any repository worker encounters test failures, all linked pull requests are automatically rolled back or held in draft state.
|
|
68
|
+
|
|
69
|
+
### C. Cloud Pub/Sub Event Mesh Integration
|
|
70
|
+
- **Event Envelope**:
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"swarm_id": "swarm-20261023-e2e-sync",
|
|
74
|
+
"phase": "PREPARE",
|
|
75
|
+
"source_repo": "backend-auth-service",
|
|
76
|
+
"target_repos": ["web-frontend", "infrastructure"],
|
|
77
|
+
"schema_checksum": "sha256:4a8f9c...",
|
|
78
|
+
"branch": "feat/gemini-live-duplex-auth",
|
|
79
|
+
"timestamp": 1792764000
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 3. Production Workflow & Recipes
|
|
86
|
+
|
|
87
|
+
### Synchronizing Cross-Repo Pull Requests via CLI
|
|
88
|
+
```bash
|
|
89
|
+
# Analyze multi-repo sync state across active workspaces
|
|
90
|
+
everything-gemini cross-repo status --workspace /path/to/workspaces
|
|
91
|
+
|
|
92
|
+
# Dispatch distributed cross-repo sync with atomic two-phase commit
|
|
93
|
+
everything-gemini cross-repo sync \
|
|
94
|
+
--repos "backend,frontend,infra" \
|
|
95
|
+
--branch "feat/gemini-3.8-migration" \
|
|
96
|
+
--max-usd 3.00 \
|
|
97
|
+
--dry-run
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Python SDK Multi-Repo Coordination Blueprint
|
|
101
|
+
```python
|
|
102
|
+
from google_antigravity.swarm import CrossRepoSwarmCoordinator
|
|
103
|
+
|
|
104
|
+
coordinator = CrossRepoSwarmCoordinator(
|
|
105
|
+
manifest_path="./workspaces.json",
|
|
106
|
+
event_bus="pubsub://projects/enterprise-ai/topics/cross-repo-sync",
|
|
107
|
+
model="gemini-3.8-thinking"
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# Plan and dispatch distributed execution DAG
|
|
111
|
+
plan = coordinator.build_dag(goal="Upgrade Protobuf contracts and regenerate TypeScript client")
|
|
112
|
+
results = coordinator.execute_2pc(plan, timeout_seconds=600)
|
|
113
|
+
assert results.is_successful, f"Cross-repo sync aborted: {results.rollback_reason}"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 4. Verification & Diagnostics
|
|
119
|
+
|
|
120
|
+
- **Integrity Validation**: Run `everything-gemini test-skill cross-repo-swarm-sync`.
|
|
121
|
+
- **Traceparent Linking**: Correlate W3C traceparent headers across all distributed worker logs.
|
|
122
|
+
- **Reference Links**: See [agents/cross-repo-orchestrator.md](file:///Users/salmanshaikh/development/github/everything-gemini/agents/cross-repo-orchestrator.md) and [skills/ephemeral-swarm-orchestrator/SKILL.md](file:///Users/salmanshaikh/development/github/everything-gemini/skills/ephemeral-swarm-orchestrator/SKILL.md).
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cve-remediation-orchestrator
|
|
3
|
+
description: >-
|
|
4
|
+
Orchestrates defense-in-depth vulnerability remediation, virtual patching, kernel hardening, and service restart verification for critical CVEs without relying on exploit tools. Use when mitigating zero-days, evaluating container runtime isolation, or applying emergency WAF/gateway filters.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# CVE Remediation & Hardening Orchestrator (`cve-remediation-orchestrator`)
|
|
8
|
+
|
|
9
|
+
An enterprise security skill that coordinates four-layer defensive mitigations for critical CVEs, neutralizing attack vectors at the architecture, kernel, and gateway levels without referencing or running exploit scripts.
|
|
10
|
+
|
|
11
|
+
## Core Philosophy: Exploit-Agnostic Defense
|
|
12
|
+
|
|
13
|
+
Rather than tracking fragile or dangerous exploit PoCs, this skill enforces **architectural invariants** that render entire vulnerability classes inoperable:
|
|
14
|
+
1. **Virtual Patching**: Block malformed stream headers and buffer boundary exploits at the API gateway or WAF before they reach the runtime.
|
|
15
|
+
2. **Kernel & Host Hardening**: Enforce Full Address Space Layout Randomization (ASLR), Data Execution Prevention (DEP/NX), and strict Seccomp profiles to thwart memory exploitation primitives.
|
|
16
|
+
3. **Container Confinement**: Apply read-only root filesystems and drop all Linux capabilities to prevent post-exploitation persistence.
|
|
17
|
+
4. **Permanent Remediation**: Verify vendor package upgrades and ensure web worker daemons (`php-fpm`, `nginx`, `apache2`) are restarted so no stale vulnerable inodes remain mapped in RAM.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Defense-in-Depth Architecture
|
|
22
|
+
|
|
23
|
+
```mermaid
|
|
24
|
+
graph TD
|
|
25
|
+
CVE[Critical CVE / Zero-Day Disclosed] --> L1[Layer 1: Virtual Patching]
|
|
26
|
+
L1 --> L2[Layer 2: Kernel & ASLR Hardening]
|
|
27
|
+
L2 --> L3[Layer 3: Container Least Privilege]
|
|
28
|
+
L3 --> L4[Layer 4: Package Upgrade & Worker Restart]
|
|
29
|
+
|
|
30
|
+
L1 -->|Gateway Regex / Header Filter| Drop1[Blocked at Perimeter]
|
|
31
|
+
L2 -->|sysctl randomize_va_space=2| Drop2[Exploit Memory Layout Broken]
|
|
32
|
+
L3 -->|readOnlyRootFilesystem| Drop3[Payload Write Denied]
|
|
33
|
+
L4 -->|Clean Inodes in RAM| Secured[Verified Secure]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Remediation Runbook
|
|
39
|
+
|
|
40
|
+
### Layer 1: Ingress Virtual Patching (Envoy / WAF)
|
|
41
|
+
When official runtime packages cannot be deployed immediately, apply an edge filter to drop malicious header boundaries:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
# Envoy Gateway Filter Example
|
|
45
|
+
apiVersion: gateway.envoyproxy.io/v1alpha1
|
|
46
|
+
kind: EnvoyFilter
|
|
47
|
+
metadata:
|
|
48
|
+
name: drop-malformed-boundaries
|
|
49
|
+
spec:
|
|
50
|
+
configPatches:
|
|
51
|
+
- applyTo: HTTP_FILTER
|
|
52
|
+
match:
|
|
53
|
+
context: SIDECAR_INBOUND
|
|
54
|
+
patch:
|
|
55
|
+
operation: INSERT_BEFORE
|
|
56
|
+
value:
|
|
57
|
+
name: envoy.filters.http.lua
|
|
58
|
+
typed_config:
|
|
59
|
+
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
|
|
60
|
+
inlineCode: |
|
|
61
|
+
function envoy_on_request(handle)
|
|
62
|
+
local content_type = handle:headers():get("content-type")
|
|
63
|
+
if content_type and string.find(content_type, "boundary=.*[\r\n\x00]") then
|
|
64
|
+
handle:respond({[":status"] = "400"}, "Malformed stream boundary rejected.")
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Layer 2: Host & Kernel ASLR Hardening
|
|
70
|
+
Ensure the host operating system enforces strict memory space randomization:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Verify kernel ASLR level (2 = Full ASLR)
|
|
74
|
+
cat /proc/sys/kernel/randomize_va_space
|
|
75
|
+
|
|
76
|
+
# Enforce Full ASLR permanently
|
|
77
|
+
sudo sysctl -w kernel.randomize_va_space=2
|
|
78
|
+
echo "kernel.randomize_va_space = 2" | sudo tee -a /etc/sysctl.d/99-aslr-hardening.conf
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Layer 3: Container Runtime Confinement
|
|
82
|
+
Harden Kubernetes deployment manifests against shellcode execution and disk persistence:
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
securityContext:
|
|
86
|
+
allowPrivilegeEscalation: false
|
|
87
|
+
readOnlyRootFilesystem: true
|
|
88
|
+
runAsNonRoot: true
|
|
89
|
+
runAsUser: 10001
|
|
90
|
+
capabilities:
|
|
91
|
+
drop:
|
|
92
|
+
- ALL
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Layer 4: Permanent Patching & Worker Daemon Restart
|
|
96
|
+
Verify that running worker processes are executing the upgraded package:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Run automated defense verification
|
|
100
|
+
bash skills/cve-remediation-orchestrator/scripts/verify-host-hardening.sh
|
|
101
|
+
|
|
102
|
+
# Verify no running workers hold unlinked deleted executables
|
|
103
|
+
ls -l /proc/*/exe 2>/dev/null | grep '(deleted)'
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Related Skills
|
|
109
|
+
- [phpcheck-server](file:///Users/salmanshaikh/development/github/everything-gemini/skills/phpcheck-server/SKILL.md) - Deep server and package backport auditor.
|
|
110
|
+
- [security-audit](file:///Users/salmanshaikh/development/github/everything-gemini/skills/security-audit/SKILL.md) - General code, dependency, and vulnerability analysis.
|
|
111
|
+
- [envoy-ai-gateway](file:///Users/salmanshaikh/development/github/everything-gemini/skills/envoy-ai-gateway/SKILL.md) - Production AI gateway routing, rate limiting, and virtual patching.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Host Hardening & Defense-in-Depth Verification Script
|
|
4
|
+
# Verifies kernel ASLR, container capability constraints, and unlinked worker inodes in RAM.
|
|
5
|
+
|
|
6
|
+
set -eo pipefail
|
|
7
|
+
|
|
8
|
+
JSON_MODE=false
|
|
9
|
+
if [[ "$1" == "--json" ]]; then
|
|
10
|
+
JSON_MODE=true
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
# 1. Check Kernel ASLR
|
|
14
|
+
ASLR_LEVEL="unknown"
|
|
15
|
+
ASLR_STATUS="unknown"
|
|
16
|
+
if [ -f /proc/sys/kernel/randomize_va_space ]; then
|
|
17
|
+
ASLR_LEVEL="$(cat /proc/sys/kernel/randomize_va_space)"
|
|
18
|
+
if [ "$ASLR_LEVEL" -eq 2 ]; then
|
|
19
|
+
ASLR_STATUS="hardened" # Full ASLR (stack, VDSO, mmap, brk)
|
|
20
|
+
elif [ "$ASLR_LEVEL" -eq 1 ]; then
|
|
21
|
+
ASLR_STATUS="partial" # Partial ASLR
|
|
22
|
+
else
|
|
23
|
+
ASLR_STATUS="disabled" # Disabled ASLR (High Risk!)
|
|
24
|
+
fi
|
|
25
|
+
elif command -v sysctl >/dev/null 2>&1; then
|
|
26
|
+
ASLR_VAL="$(sysctl -n vm.aslr 2>/dev/null || echo "unknown")"
|
|
27
|
+
if [ "$ASLR_VAL" != "unknown" ]; then
|
|
28
|
+
ASLR_LEVEL="$ASLR_VAL"
|
|
29
|
+
ASLR_STATUS="active"
|
|
30
|
+
else
|
|
31
|
+
ASLR_STATUS="unsupported_platform"
|
|
32
|
+
fi
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
# 2. Check for unlinked/deleted running binaries (Stale worker trap)
|
|
36
|
+
STALE_WORKERS_COUNT=0
|
|
37
|
+
if [ -d /proc ]; then
|
|
38
|
+
STALE_WORKERS_COUNT="$(ls -l /proc/*/exe 2>/dev/null | grep -c '(deleted)' || true)"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# 3. Overall Verdict
|
|
42
|
+
VERDICT="pass"
|
|
43
|
+
if [ "$ASLR_STATUS" = "disabled" ] || [ "$STALE_WORKERS_COUNT" -gt 0 ]; then
|
|
44
|
+
VERDICT="warn"
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
if [ "$JSON_MODE" = true ]; then
|
|
48
|
+
cat <<EOF
|
|
49
|
+
{
|
|
50
|
+
"defense_in_depth_verdict": "$VERDICT",
|
|
51
|
+
"kernel_aslr": {
|
|
52
|
+
"level": "$ASLR_LEVEL",
|
|
53
|
+
"status": "$ASLR_STATUS"
|
|
54
|
+
},
|
|
55
|
+
"stale_memory_workers_detected": $STALE_WORKERS_COUNT
|
|
56
|
+
}
|
|
57
|
+
EOF
|
|
58
|
+
else
|
|
59
|
+
echo "🛡️ Host Hardening & Defense-in-Depth Verification"
|
|
60
|
+
echo "================================================"
|
|
61
|
+
echo "Kernel ASLR Status: $ASLR_STATUS (level: $ASLR_LEVEL)"
|
|
62
|
+
echo "Stale Memory Workers: $STALE_WORKERS_COUNT deleted process handles"
|
|
63
|
+
if [ "$STALE_WORKERS_COUNT" -gt 0 ]; then
|
|
64
|
+
echo "⚠️ Warning: Daemons were updated on disk but not restarted in RAM."
|
|
65
|
+
fi
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
if [ "$VERDICT" = "pass" ]; then
|
|
69
|
+
exit 0
|
|
70
|
+
else
|
|
71
|
+
exit 1
|
|
72
|
+
fi
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dynamic-thinking-allocation
|
|
3
|
+
description: Profiles cognitive task complexity and dynamically routes between low-latency Gemini Flash and Gemini 3.8 Extended Thinking reasoning budgets.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Dynamic Thinking Allocation & Extended Reasoning Engine
|
|
7
|
+
|
|
8
|
+
Configures, profiles, and orchestrates dynamic "thinking token" budgets for Google Gemini 3.8 models, automatically determining the optimal cognitive depth between high-speed tool plumbing and deep architectural reasoning.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 1. Architecture: Cognitive Complexity Router
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
16
|
+
│ DYNAMIC THINKING ALLOCATION ROUTING MATRIX │
|
|
17
|
+
│ │
|
|
18
|
+
│ ┌────────────────────────┐ │
|
|
19
|
+
│ │ Incoming Agent Turn / │ │
|
|
20
|
+
│ │ Architectural Task │ │
|
|
21
|
+
│ └───────────┬────────────┘ │
|
|
22
|
+
│ │ │
|
|
23
|
+
│ ▼ │
|
|
24
|
+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
|
|
25
|
+
│ │ Cognitive Profiler (Entropy, Dependency Depth, AST Complexity) │ │
|
|
26
|
+
│ └───────────┬─────────────────────────┬───────────────────────────────┘ │
|
|
27
|
+
│ │ │ │
|
|
28
|
+
│ Score < 30 │ 30-70 │ Score > 70 │
|
|
29
|
+
│ ▼ ▼ ▼
|
|
30
|
+
│ ┌──────────────────────┐ ┌──────────────────────┐ ┌───────────────────┐ │
|
|
31
|
+
│ │ Level 1: FLASH │ │ Level 2: BALANCED │ │ Level 3: DEEP │ │
|
|
32
|
+
│ │ (Thinking: 0 tokens) │ │ (Thinking: 2k-4k) │ │ (Thinking: 8k-24k)│ │
|
|
33
|
+
│ │ • Tool plumbing │ │ • Bug diagnosis │ │ • Distributed ref │ │
|
|
34
|
+
│ │ • CLI invocations │ │ • Schema validation │ │ • Concurrency fix │ │
|
|
35
|
+
│ │ • Log grepping │ │ • Test authoring │ │ • Cryptography │ │
|
|
36
|
+
│ └──────────────────────┘ └──────────────────────┘ └───────────────────┘ │
|
|
37
|
+
│ │ │ │ │
|
|
38
|
+
│ └─────────────────────────┼─────────────────────────┘ │
|
|
39
|
+
│ ▼ │
|
|
40
|
+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
|
|
41
|
+
│ │ Model API Execution (Google GenAI SDK / Antigravity Engine) │ │
|
|
42
|
+
│ │ • `config.thinking_config = {"thinking_budget": targetTokens}` │ │
|
|
43
|
+
│ │ • Pre-allocated spend caps monitored via `budget-guard` │ │
|
|
44
|
+
│ └─────────────────────────────────────────────────────────────────────┘ │
|
|
45
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 2. Dynamic Thinking Budget Allocation Rules
|
|
51
|
+
|
|
52
|
+
| Cognitive Tier | Target Complexity | Thinking Token Budget | Model Target | Primary Use Cases |
|
|
53
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
54
|
+
| **Flash / None** | AST depth $\le 2$, single file edit | `0` (Off) | Gemini 2.0 Flash | Mechanical formatting, directory listing, shell command dispatch, docstring typo fixes. |
|
|
55
|
+
| **Balanced** | Moderate AST refactor, multi-file unit tests | `2,048` - `4,096` | Gemini 2.5 Pro / Flash | Function signature refactor, API endpoint mocking, data model migration, SQL query optimization. |
|
|
56
|
+
| **Deep Reasoning** | Distributed race conditions, consensus protocols | `8,192` - `16,384` | Gemini 3.8 Thinking | Concurrency bug root-cause analysis, consensus algorithms, eBPF filter generation, memory leak tracing. |
|
|
57
|
+
| **Exhaustive Frontier** | Novel cryptographic implementations, OS kernels | `24,576` (Max) | Gemini 3.8 Thinking (Max) | Post-quantum cryptographic migration, compiler backend optimization, distributed deadlock resolution. |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 3. Implementation with Google GenAI SDK
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from google import genai
|
|
65
|
+
from google.genai import types
|
|
66
|
+
|
|
67
|
+
def configure_thinking_session(task_complexity_score: float, client: genai.Client) -> genai.Chat:
|
|
68
|
+
"""Configures dynamic thinking token budget based on task entropy."""
|
|
69
|
+
if task_complexity_score > 0.8:
|
|
70
|
+
# Deep architectural reasoning
|
|
71
|
+
model_name = "gemini-3.8-thinking"
|
|
72
|
+
thinking_budget = 16384
|
|
73
|
+
elif task_complexity_score > 0.4:
|
|
74
|
+
# Balanced analytical tasks
|
|
75
|
+
model_name = "gemini-2.5-pro"
|
|
76
|
+
thinking_budget = 4096
|
|
77
|
+
else:
|
|
78
|
+
# Low-latency tool plumbing
|
|
79
|
+
model_name = "gemini-2.0-flash"
|
|
80
|
+
thinking_budget = 0
|
|
81
|
+
|
|
82
|
+
config = types.GenerateContentConfig(
|
|
83
|
+
temperature=0.2 if thinking_budget > 0 else 0.7,
|
|
84
|
+
thinking_config=types.ThinkingConfig(
|
|
85
|
+
thinking_budget=thinking_budget
|
|
86
|
+
) if thinking_budget > 0 else None,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
return client.chats.create(model=model_name, config=config)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 4. CLI Inspection & Profiling
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# 1. Profile a task's cognitive complexity and recommend thinking budget
|
|
98
|
+
everything-gemini thinking profile "Resolve distributed Spanner deadlock across 3 microservices"
|
|
99
|
+
|
|
100
|
+
# 2. Benchmark thinking token expenditure in dry-run mode
|
|
101
|
+
everything-gemini thinking budget --level deep --dry-run
|
|
102
|
+
|
|
103
|
+
# 3. Output structured thinking allocation matrix
|
|
104
|
+
everything-gemini thinking --json
|
|
105
|
+
```
|