Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1182ba0cf2 |
No files matched your search
@@ -9,6 +9,8 @@ Type=simple
|
||||
WorkingDirectory=/srv/hyperstitionstud.io/repos
|
||||
Environment="HYPERSTITIONSTUDIO_CONFIG=/srv/hyperstitionstud.io/repos/workspace.toml"
|
||||
Environment="PYTHONPATH=/srv/hyperstitionstud.io/repos/hyperstitionstudio-core/src"
|
||||
Environment="HYPERSTITION_TELEMETRY_DB_PATH=/tmp/hyperstition-api-telemetry.db"
|
||||
Environment="HYPERSTITION_SQLITE_MAX_MB=100"
|
||||
ExecStart=/srv/hyperstitionstud.io/repos/.venv/bin/python3 /srv/hyperstitionstud.io/repos/hyperstitionstudio-core/src/hyperstitionstud_io/mcp/server.py --transport http --host 127.0.0.1 --port 8095
|
||||
Restart=always
|
||||
RestartSec=2
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# /etc/logrotate.d/hyperstition-sqlite-meta
|
||||
# Quiescent size-based compression & truncation for the hyperstitionstud.io SQLite REST/MCP API metadata DB.
|
||||
#
|
||||
# Why quiescent snapshot compression + in-place SQLite truncation is used:
|
||||
# Raw byte truncation (`copytruncate`) on a live SQLite `.db` or `-wal` file while readers or
|
||||
# writers hold locks corrupts the SQLite B-tree page header and WAL frame index.
|
||||
# Instead, `prerotate` invokes `hyperstitionstud_io.db.sqlite_meta --truncate-quiescent --compress-archive`, which:
|
||||
# 1. Sets `PRAGMA busy_timeout = 30000` (waits up to 30s for in-flight requests to finish),
|
||||
# 2. Acquires `BEGIN EXCLUSIVE` to guarantee 100% SQLite reader/writer quiescence,
|
||||
# 3. Writes a consistent point-in-time SQLite snapshot and compresses it with `gzip -9`
|
||||
# to `<db_path>.1.gz` (rotating `.1.gz` .. `.12.gz` rather than removing history),
|
||||
# 4. Purges the live telemetry tables and commits cleanly,
|
||||
# 5. Executes `PRAGMA wal_checkpoint(TRUNCATE)` + `VACUUM` + `PRAGMA optimize` on the live DB, and
|
||||
# 6. Verifies `PRAGMA integrity_check == 'ok'` on the live DB.
|
||||
#
|
||||
# Configurable threshold:
|
||||
# - Default logrotate trigger: `size 100M` (100 MB)
|
||||
# - Runtime override: export `HYPERSTITION_SQLITE_MAX_MB` (default `100`) or `HYPERSTITION_SQLITE_MAX_BYTES`.
|
||||
|
||||
/tmp/hyperstition-api-telemetry.db /var/lib/hyperstitionstud.io/api-telemetry.db {
|
||||
size 100M
|
||||
rotate 12
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
nocreate
|
||||
sharedscripts
|
||||
prerotate
|
||||
TARGET_DB="${1:-${HYPERSTITION_TELEMETRY_DB_PATH:-/tmp/hyperstition-api-telemetry.db}}"
|
||||
MAX_MB="${HYPERSTITION_SQLITE_MAX_MB:-100}"
|
||||
MAX_BYTES="${HYPERSTITION_SQLITE_MAX_BYTES:-$((MAX_MB * 1024 * 1024))}"
|
||||
ROTATE_KEEP="${HYPERSTITION_SQLITE_ROTATE_KEEP:-12}"
|
||||
PYTHON_BIN="${HYPERSTITION_PYTHON_BIN:-python3}"
|
||||
PYTHONPATH="${PYTHONPATH:-/srv/hyperstitionstud.io/repos/hyperstitionstudio-core/src:/workspace/hyperstitionstudio-core/src}" \
|
||||
"${PYTHON_BIN}" -m hyperstitionstud_io.db.sqlite_meta \
|
||||
--truncate-quiescent \
|
||||
--compress-archive \
|
||||
--rotate-keep "${ROTATE_KEEP}" \
|
||||
--db "${TARGET_DB}" \
|
||||
--max-bytes "${MAX_BYTES}"
|
||||
endscript
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
# Hydrates per-repository install directories from REPOS_ROOT into LIVE_REPOS (tmpfs RAM mount),
|
||||
# supplies untracked haiperdohp-jemaytreeah/.gitignore files (config.js, db.json, db_lite.json),
|
||||
# creates top-level route symlinks, pre-compresses (.br / .gz) static assets, and idempotently
|
||||
# syncs/validates/reloads /etc/caddy/Caddyfile and systemd units by default (negated via --no-caddy).
|
||||
# syncs/validates/reloads /etc/caddy/Caddyfile, systemd units, and /etc/logrotate.d/hyperstition-sqlite-meta
|
||||
# by default (negated via --no-caddy).
|
||||
#
|
||||
# Usage:
|
||||
# ./sync-vps-repos.sh [all|<repo-name>] [--no-pull] [--no-caddy|--no-services]
|
||||
@@ -181,9 +182,21 @@ if [[ -n "$(type -P brotli || true)" ]]; then
|
||||
-exec brotli -q 11 -k -f {} \;
|
||||
fi
|
||||
|
||||
# Step 5: Idempotent systemd unit & /etc/caddy/Caddyfile synchronization (enabled by default; skip with --no-caddy)
|
||||
# Step 5: Idempotent systemd unit, logrotate.d & /etc/caddy/Caddyfile synchronization (enabled by default; skip with --no-caddy)
|
||||
if [[ "${DO_CADDY}" -eq 1 ]]; then
|
||||
DEPLOY_DIR="${REPOS_ROOT}/hyperstitionstudio-core/deploy"
|
||||
SRC_LOGROTATE="${DEPLOY_DIR}/logrotate.d/hyperstition-sqlite-meta"
|
||||
DST_LOGROTATE="/etc/logrotate.d/hyperstition-sqlite-meta"
|
||||
if [[ -f "${SRC_LOGROTATE}" ]] && [[ -d "/etc/logrotate.d" ]] && { [[ -w "/etc/logrotate.d" ]] || [[ -n "${SUDO}" ]]; }; then
|
||||
if [[ -f "${DST_LOGROTATE}" ]] && cmp -s "${SRC_LOGROTATE}" "${DST_LOGROTATE}"; then
|
||||
echo "[5/5] ${DST_LOGROTATE} is already identical to deploy/logrotate.d/hyperstition-sqlite-meta."
|
||||
else
|
||||
echo "[5/5] Installing quiescent SQLite logrotate rule to ${DST_LOGROTATE}..."
|
||||
run_checked "copy hyperstition-sqlite-meta logrotate rule" ${SUDO} cp "${SRC_LOGROTATE}" "${DST_LOGROTATE}"
|
||||
run_checked "chmod 0644 ${DST_LOGROTATE}" ${SUDO} chmod 0644 "${DST_LOGROTATE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "$(type -P systemctl || true)" ]] && [[ -d "/run/systemd/system" ]]; then
|
||||
UNITS_CHANGED=0
|
||||
for unit_name in "hyperstition-tmpfs-sync.service" "hyperstition-mcp.service"; do
|
||||
|
||||
@@ -28,7 +28,8 @@ trap cleanup EXIT
|
||||
|
||||
if [[ -z "${TARGET_BASE_URL}" ]]; then
|
||||
export LIVE_REPOS="${LIVE_REPOS:-/tmp/hyperstition-live-repos}"
|
||||
rm -rf "${LIVE_REPOS}"
|
||||
export HYPERSTITION_TELEMETRY_DB_PATH="${HYPERSTITION_TELEMETRY_DB_PATH:-/tmp/hyperstition-deploy-test-telemetry.db}"
|
||||
rm -rf "${LIVE_REPOS}" "${HYPERSTITION_TELEMETRY_DB_PATH}" "${HYPERSTITION_TELEMETRY_DB_PATH}-wal" "${HYPERSTITION_TELEMETRY_DB_PATH}-shm"
|
||||
echo "[1/4] Hydrating per-repository webroot at ${LIVE_REPOS} via sync-vps-repos.sh --no-pull..."
|
||||
"${SCRIPT_DIR}/sync-vps-repos.sh" --no-pull
|
||||
|
||||
@@ -129,4 +130,22 @@ for api_sub in "/status" "/openapi.json" "/quant/instruments/NVDA" "/zoology/pok
|
||||
echo " [200 OK] GET ${API_V1_URL}${api_sub}"
|
||||
done
|
||||
|
||||
if [[ -n "${HYPERSTITION_TELEMETRY_DB_PATH:-}" ]] && [[ -f "${LIVE_REPOS}/hyperstitionstudio-core/deploy/logrotate.d/hyperstition-sqlite-meta" ]]; then
|
||||
echo "[4c/4] Verifying SQLite REST/MCP metadata DB population & quiescent logrotate.d compression + truncation..."
|
||||
PYTHONPATH="${SCRIPT_DIR}/../src" python3 - <<'PY'
|
||||
import os
|
||||
from pathlib import Path
|
||||
from hyperstitionstud_io.db.sqlite_meta import get_api_telemetry_summary, run_logrotate_directive
|
||||
|
||||
tel_db = Path(os.environ["HYPERSTITION_TELEMETRY_DB_PATH"])
|
||||
conf_p = Path(os.environ["LIVE_REPOS"]) / "hyperstitionstudio-core" / "deploy" / "logrotate.d" / "hyperstition-sqlite-meta"
|
||||
summary = get_api_telemetry_summary(tel_db)
|
||||
assert summary["total_requests"] >= 5, f"Expected >= 5 recorded MCP/REST calls, got {summary['total_requests']}"
|
||||
lr_out = run_logrotate_directive(conf_path=conf_p, telemetry_db_path=tel_db, max_bytes_override=1024)
|
||||
assert lr_out["truncated"] is True and lr_out["quiescent"] is True and lr_out["integrity_check"] == "ok", lr_out
|
||||
assert lr_out["compress_enabled"] is True and lr_out["compressed_archive_bytes"] > 0 and Path(lr_out["compressed_archive_path"]).is_file(), lr_out
|
||||
print(f" [OK] SQLite metadata DB populated ({summary['total_requests']} calls), compressed to {Path(lr_out['compressed_archive_path']).name} ({lr_out['compressed_archive_bytes']} B) & quiescently truncated via {conf_p.name} (default {lr_out['configured_size_directive']}).")
|
||||
PY
|
||||
fi
|
||||
|
||||
echo "[OK] All ${PASS_COUNT}/${#ROUTES[@]} static routes + 2 MCP HTTP endpoints + 4 REST API v1 endpoints verified (HTTP 200 OK)."
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hyperstitionstud.io/workspace-core",
|
||||
"version": "2.0.18",
|
||||
"version": "2.0.19",
|
||||
"private": true,
|
||||
"description": "Offline-first ESM & browser global (@hyperstitionstud.io/* / window.HyperstitionStudio.*) packages for Base-36 AQ ciphers and interactive knowledge graph workbenches.",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hyperstitionstud.io/ciphers-aq",
|
||||
"version": "2.0.18",
|
||||
"version": "2.0.19",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"license": "MIT"
|
||||
|
||||
+2
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "hyperstitionstudio-core"
|
||||
version = "2.0.18"
|
||||
version = "2.0.19"
|
||||
description = "Shared PEP 420 common library (hyperstitionstud_io.*) for Base-36 AQ ciphers, offline CMUdict Ingglish phonetics, ReportLab/Pillow publishing, SHA-256 glossary isolation guards, local-config citation verification, and multi-format knowledge graphs."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
@@ -27,6 +27,7 @@ hs-kg-build = "hyperstitionstud_io.graph.cli:main"
|
||||
hs-quant-harvest = "hyperstitionstud_io.quant.collector:main"
|
||||
hs-mcp = "hyperstitionstud_io.mcp.server:main"
|
||||
hs-sync-version = "hyperstitionstud_io.version_sync:main"
|
||||
hs-db-build = "hyperstitionstud_io.db.sqlite_meta:main"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["src"]
|
||||
|
||||
@@ -144,8 +144,8 @@ def main() -> int:
|
||||
})
|
||||
|
||||
manifest = {
|
||||
"version": "2.0.18",
|
||||
"namespace_urn": "urn:io:hyperstitionstud:gallery:2.0.18",
|
||||
"version": "2.0.19",
|
||||
"namespace_urn": "urn:io:hyperstitionstud:gallery:2.0.19",
|
||||
"total_items": len(items),
|
||||
"items": items,
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@
|
||||
<main class="gallery-grid" id="galleryGrid"></main>
|
||||
|
||||
<footer>
|
||||
<div>hyperstitionstud.io/gallery • Powered by hyperstitionstudio-core (urn:io:hyperstitionstud:gallery:2.0.18)</div>
|
||||
<div>hyperstitionstud.io/gallery • Powered by hyperstitionstudio-core (urn:io:hyperstitionstud:gallery:2.0.19)</div>
|
||||
<div class="hs-lemur-credit">Made with <span class="hs-heart" role="img" aria-label="love">♥</span> by Lemurs.</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
+2
-2
@@ -131,7 +131,7 @@
|
||||
<span class="dot"></span>
|
||||
<h1>HYPERSTITIONSTUD.IO // TECHNOCAPITAL SINGULARITY ZOOLOGY WORKBENCH</h1>
|
||||
</div>
|
||||
<p class="subtitle">100% Offline-Portable & HTTP/3 Edge-Ready Research Corpus • Namespace Authority: urn:io:hyperstitionstud (v2.0.18)</p>
|
||||
<p class="subtitle">100% Offline-Portable & HTTP/3 Edge-Ready Research Corpus • Namespace Authority: urn:io:hyperstitionstud (v2.0.19)</p>
|
||||
</div>
|
||||
<div class="meta-badges">
|
||||
<a class="btn primary" data-route="learn-track" href="/learn/index.html" style="padding:0.35rem 0.75rem;font-size:0.74rem;">Start Learning Track (/learn/)</a>
|
||||
@@ -254,7 +254,7 @@
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<div>hyperstitionstud.io • Powered by hyperstitionstudio-core (hyperstitionstud_io.* / urn:io:hyperstitionstud v2.0.18) • Zero External Network Dependencies</div>
|
||||
<div>hyperstitionstud.io • Powered by hyperstitionstudio-core (hyperstitionstud_io.* / urn:io:hyperstitionstud v2.0.19) • Zero External Network Dependencies</div>
|
||||
<div class="hs-lemur-credit" style="margin-top:0.35rem;color:var(--text-muted);font-size:0.75rem;">Made with <span class="hs-heart" role="img" aria-label="love" style="color:var(--rose);display:inline-block;padding:0 2px;">♥</span> by Lemurs.</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -413,7 +413,7 @@
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<div>hyperstitionstud.io/learn • Powered by hyperstitionstudio-core (urn:io:hyperstitionstud:schema:v1:learn-progress-state v2.0.18)</div>
|
||||
<div>hyperstitionstud.io/learn • Powered by hyperstitionstudio-core (urn:io:hyperstitionstud:schema:v1:learn-progress-state v2.0.19)</div>
|
||||
<div class="hs-lemur-credit">Made with <span class="hs-heart" role="img" aria-label="love">♥</span> by Lemurs.</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -265,7 +265,7 @@
|
||||
const base = {
|
||||
$schema: "../schemas/v1/learn-progress-state.schema.json",
|
||||
$id: SCHEMA_ID,
|
||||
version: "2.0.18",
|
||||
version: "2.0.19",
|
||||
updated_at_utc: new Date().toISOString(),
|
||||
preferred_register: "fund_manager",
|
||||
completed_modules: [],
|
||||
|
||||
@@ -222,7 +222,7 @@
|
||||
<header>
|
||||
<div>
|
||||
<h1>hyperstitionstud.io/quant — Quantitative Finance & Memetic Gematria Time-Series Workbench</h1>
|
||||
<p class="subtitle">Strictly Periodic Telemetry (21:30 UTC US Closing Bell × 00:00 UTC News-Wire Dossiers) • Lens-Neutral Schema (urn:io:hyperstitionstud:quant-timeseries:v2.0.18)</p>
|
||||
<p class="subtitle">Strictly Periodic Telemetry (21:30 UTC US Closing Bell × 00:00 UTC News-Wire Dossiers) • Lens-Neutral Schema (urn:io:hyperstitionstud:quant-timeseries:v2.0.19)</p>
|
||||
</div>
|
||||
<nav class="top-nav">
|
||||
<a class="btn" id="navHome" href="/">Portal Home (/)</a>
|
||||
@@ -307,7 +307,7 @@
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
hyperstitionstud.io/quant v2.0.18 • Made with <span class="hs-heart" style="color:#ff4d4d;">♥</span> by Lemurs.
|
||||
hyperstitionstud.io/quant v2.0.19 • Made with <span class="hs-heart" style="color:#ff4d4d;">♥</span> by Lemurs.
|
||||
</footer>
|
||||
</div>
|
||||
<script src="quant-app.js"></script>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// /workspace/hyperstitionstudio-core/site/quant/quant-app.js
|
||||
// Interactive Quantitative Finance & Memetic Gematria Time-Series Workbench (v2.0.18)
|
||||
// Interactive Quantitative Finance & Memetic Gematria Time-Series Workbench (v2.0.19)
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// Auto-generated synchronous time-series bundle for file:// and https:// portability
|
||||
window.HyperstitionStudio = window.HyperstitionStudio || {};
|
||||
window.HyperstitionStudio.QuantTimeSeries = {"$schema": "./schemas/v1/quant-timeseries.schema.json", "$id": "urn:io:hyperstitionstud:schema:v1:quant-timeseries", "version": "2.0.18", "namespace_urn": "urn:io:hyperstitionstud:quant-timeseries:2.0.18", "generated_at_utc": "2026-11-30T05:40:45Z", "periodicity_gate": {"enforced": true, "allowed_cadences": ["1d-us-closing-bell-2130-utc", "24h-news-wire-rollover-0000-utc"], "dated_news_dossiers_ingested": 21, "excluded_non_periodic_sources": ["01-ingglish-aq-lexicon.md", "10-19-ledger-*.md", "20-24-dossier-*.md", "26-45-dossier-*.md", "65-69-dossier-technocapital-singularity-*.md", "technocapital-singularity-zoology/encyclopedia/*", "proposal-*.md", "lecture-*.md", "podcast-ep*.md", "haiperdohp-jemaytreeah/db.json"], "non_periodic_records_ingested": 0}, "enabled_lenses": ["fund_manager", "neutral_math", "corporate_board", "tierzoo_ecology", "fantasy_sabermetrics", "pokedex_scanner"], "default_lens": "fund_manager", "lens_registry_meta": {"fund_manager": {"lens_id": "fund_manager", "title": "Quantitative Hedge Fund & Factor Risk", "short_label": "Quant Factor", "structural_labels": {"struct_isometric_armor": "Chokepoint Moat", "struct_drift_velocity": "Signal Velocity", "struct_variance_collapse": "Convergence Power", "struct_trophic_capture": "Institutional Coupling", "struct_prime_density": "Idiosyncratic Asymmetry", "struct_repricing_resilience": "Regime Robustness"}, "timeseries_labels": {"ts_duty_cycle_pct": "Signal Duty Cycle / Hit Rate (%)", "ts_weighted_resonance": "Conviction-Weighted Exposure (0-100)", "ts_excess_over_replacement": "Information Ratio / Alpha Over Benchmark", "ts_quantile_profile": "Downside VaR_20 / Upside P90 / Convexity CV", "ts_optimal_lag_days": "Granger Lead-Lag Horizon τ* (Days)", "ts_regime_splits": "Regime-Conditional Beta Split (M1/M2/M3)"}}, "neutral_math": {"lens_id": "neutral_math", "title": "Neutral Mathematical & Statistical Invariants", "short_label": "Neutral Math", "structural_labels": {"struct_isometric_armor": "G4 Isometric Ratio (Δ=0)", "struct_drift_velocity": "G3 Inverse Phonemic Drift", "struct_variance_collapse": "G1 Log Variance Collapse", "struct_trophic_capture": "Bipartite S×S6 Coupling Degree", "struct_prime_density": "G5 Prime & Twin-Prime Density", "struct_repricing_resilience": "Repricing Counter-Swap Closure"}, "timeseries_labels": {"ts_duty_cycle_pct": "Active Duty Cycle Pr[X_t > 0] (%)", "ts_weighted_resonance": "Weighted Resonance Index (0-100)", "ts_excess_over_replacement": "Excess Value Over Baseline (σ-Units)", "ts_quantile_profile": "Quantile Spread (P20 / P90 / CV)", "ts_optimal_lag_days": "Peak Cross-Correlation Lag τ* (Days)", "ts_regime_splits": "Conditional Regime Delta E[X|S_t] - μ"}}, "corporate_board": {"lens_id": "corporate_board", "title": "Corporate Strategy & Balance-Sheet Governance", "short_label": "Corporate Board", "structural_labels": {"struct_isometric_armor": "Supply-Chain Moat", "struct_drift_velocity": "Execution Agility", "struct_variance_collapse": "Cross-Unit Synergy", "struct_trophic_capture": "Governance & Balance-Sheet Integration", "struct_prime_density": "Proprietary IP Density", "struct_repricing_resilience": "Stress-Test Resilience"}, "timeseries_labels": {"ts_duty_cycle_pct": "Operational Utilization Cadence (%)", "ts_weighted_resonance": "Strategic Capital Share (0-100)", "ts_excess_over_replacement": "Net Economic Value Added (EVA)", "ts_quantile_profile": "Base-Case Floor / Upside Case / Variance", "ts_optimal_lag_days": "Guidance-to-Market Lead Time τ* (Days)", "ts_regime_splits": "Macro Stress-Scenario Delta (Halt/Surge/Cap)"}}, "tierzoo_ecology": {"lens_id": "tierzoo_ecology", "title": "TierZoo Ecological Trophic Index (ETI)", "short_label": "TierZoo (ETI)", "structural_labels": {"struct_isometric_armor": "ARM (G4 Isometric Chokepoint Armor)", "struct_drift_velocity": "VEL (Teleoplexic Escape Velocity)", "struct_variance_collapse": "COL (G1 Variance-Collapse Compression)", "struct_trophic_capture": "CAP (S×S6 Double-Articulation & Capture)", "struct_prime_density": "PRM (Prime & G5 Twin-Prime Mutation IQ)", "struct_repricing_resilience": "RES (Tri-Modal Repricing & State Resilience)"}, "timeseries_labels": {"ts_duty_cycle_pct": "Foraging Activity Duty Cycle (%)", "ts_weighted_resonance": "Trophic Dominance Rating (0-100)", "ts_excess_over_replacement": "Apex Surplus Over Extinction Floor", "ts_quantile_profile": "Metabolic Floor / Burst Ceiling / Niche CV", "ts_optimal_lag_days": "Predator-Prey Phase Lead τ* (Days)", "ts_regime_splits": "Biome Weather Adaptation Split (M1/M2/M3)"}}, "fantasy_sabermetrics": {"lens_id": "fantasy_sabermetrics", "title": "Fantasy Football & Sabermetric Roster Engine", "short_label": "Fantasy Sabermetrics", "structural_labels": {"struct_isometric_armor": "Pass Protection (OL Chokepoint Block)", "struct_drift_velocity": "Breakaway Speed (Open-Field Velocity)", "struct_variance_collapse": "Stack Power (Multi-Asset CorrelatiLine truncated
|
||||
window.HyperstitionStudio.QuantTimeSeries = {"$schema": "./schemas/v1/quant-timeseries.schema.json", "$id": "urn:io:hyperstitionstud:schema:v1:quant-timeseries", "version": "2.0.19", "namespace_urn": "urn:io:hyperstitionstud:quant-timeseries:2.0.19", "generated_at_utc": "2026-11-30T06:43:54Z", "periodicity_gate": {"enforced": true, "allowed_cadences": ["1d-us-closing-bell-2130-utc", "24h-news-wire-rollover-0000-utc"], "dated_news_dossiers_ingested": 21, "excluded_non_periodic_sources": ["01-ingglish-aq-lexicon.md", "10-19-ledger-*.md", "20-24-dossier-*.md", "26-45-dossier-*.md", "65-69-dossier-technocapital-singularity-*.md", "technocapital-singularity-zoology/encyclopedia/*", "proposal-*.md", "lecture-*.md", "podcast-ep*.md", "haiperdohp-jemaytreeah/db.json"], "non_periodic_records_ingested": 0}, "enabled_lenses": ["fund_manager", "neutral_math", "corporate_board", "tierzoo_ecology", "fantasy_sabermetrics", "pokedex_scanner"], "default_lens": "fund_manager", "lens_registry_meta": {"fund_manager": {"lens_id": "fund_manager", "title": "Quantitative Hedge Fund & Factor Risk", "short_label": "Quant Factor", "structural_labels": {"struct_isometric_armor": "Chokepoint Moat", "struct_drift_velocity": "Signal Velocity", "struct_variance_collapse": "Convergence Power", "struct_trophic_capture": "Institutional Coupling", "struct_prime_density": "Idiosyncratic Asymmetry", "struct_repricing_resilience": "Regime Robustness"}, "timeseries_labels": {"ts_duty_cycle_pct": "Signal Duty Cycle / Hit Rate (%)", "ts_weighted_resonance": "Conviction-Weighted Exposure (0-100)", "ts_excess_over_replacement": "Information Ratio / Alpha Over Benchmark", "ts_quantile_profile": "Downside VaR_20 / Upside P90 / Convexity CV", "ts_optimal_lag_days": "Granger Lead-Lag Horizon τ* (Days)", "ts_regime_splits": "Regime-Conditional Beta Split (M1/M2/M3)"}}, "neutral_math": {"lens_id": "neutral_math", "title": "Neutral Mathematical & Statistical Invariants", "short_label": "Neutral Math", "structural_labels": {"struct_isometric_armor": "G4 Isometric Ratio (Δ=0)", "struct_drift_velocity": "G3 Inverse Phonemic Drift", "struct_variance_collapse": "G1 Log Variance Collapse", "struct_trophic_capture": "Bipartite S×S6 Coupling Degree", "struct_prime_density": "G5 Prime & Twin-Prime Density", "struct_repricing_resilience": "Repricing Counter-Swap Closure"}, "timeseries_labels": {"ts_duty_cycle_pct": "Active Duty Cycle Pr[X_t > 0] (%)", "ts_weighted_resonance": "Weighted Resonance Index (0-100)", "ts_excess_over_replacement": "Excess Value Over Baseline (σ-Units)", "ts_quantile_profile": "Quantile Spread (P20 / P90 / CV)", "ts_optimal_lag_days": "Peak Cross-Correlation Lag τ* (Days)", "ts_regime_splits": "Conditional Regime Delta E[X|S_t] - μ"}}, "corporate_board": {"lens_id": "corporate_board", "title": "Corporate Strategy & Balance-Sheet Governance", "short_label": "Corporate Board", "structural_labels": {"struct_isometric_armor": "Supply-Chain Moat", "struct_drift_velocity": "Execution Agility", "struct_variance_collapse": "Cross-Unit Synergy", "struct_trophic_capture": "Governance & Balance-Sheet Integration", "struct_prime_density": "Proprietary IP Density", "struct_repricing_resilience": "Stress-Test Resilience"}, "timeseries_labels": {"ts_duty_cycle_pct": "Operational Utilization Cadence (%)", "ts_weighted_resonance": "Strategic Capital Share (0-100)", "ts_excess_over_replacement": "Net Economic Value Added (EVA)", "ts_quantile_profile": "Base-Case Floor / Upside Case / Variance", "ts_optimal_lag_days": "Guidance-to-Market Lead Time τ* (Days)", "ts_regime_splits": "Macro Stress-Scenario Delta (Halt/Surge/Cap)"}}, "tierzoo_ecology": {"lens_id": "tierzoo_ecology", "title": "TierZoo Ecological Trophic Index (ETI)", "short_label": "TierZoo (ETI)", "structural_labels": {"struct_isometric_armor": "ARM (G4 Isometric Chokepoint Armor)", "struct_drift_velocity": "VEL (Teleoplexic Escape Velocity)", "struct_variance_collapse": "COL (G1 Variance-Collapse Compression)", "struct_trophic_capture": "CAP (S×S6 Double-Articulation & Capture)", "struct_prime_density": "PRM (Prime & G5 Twin-Prime Mutation IQ)", "struct_repricing_resilience": "RES (Tri-Modal Repricing & State Resilience)"}, "timeseries_labels": {"ts_duty_cycle_pct": "Foraging Activity Duty Cycle (%)", "ts_weighted_resonance": "Trophic Dominance Rating (0-100)", "ts_excess_over_replacement": "Apex Surplus Over Extinction Floor", "ts_quantile_profile": "Metabolic Floor / Burst Ceiling / Niche CV", "ts_optimal_lag_days": "Predator-Prey Phase Lead τ* (Days)", "ts_regime_splits": "Biome Weather Adaptation Split (M1/M2/M3)"}}, "fantasy_sabermetrics": {"lens_id": "fantasy_sabermetrics", "title": "Fantasy Football & Sabermetric Roster Engine", "short_label": "Fantasy Sabermetrics", "structural_labels": {"struct_isometric_armor": "Pass Protection (OL Chokepoint Block)", "struct_drift_velocity": "Breakaway Speed (Open-Field Velocity)", "struct_variance_collapse": "Stack Power (Multi-Asset CorrelatiLine truncated
|
||||
@@ -5434,7 +5434,7 @@
|
||||
"fantasy_sabermetrics",
|
||||
"pokedex_scanner"
|
||||
],
|
||||
"generated_at_utc": "2026-11-30T05:40:45Z",
|
||||
"generated_at_utc": "2026-11-30T06:43:54Z",
|
||||
"instruments": [
|
||||
{
|
||||
"bars": [
|
||||
@@ -28362,7 +28362,7 @@
|
||||
}
|
||||
],
|
||||
"ipld_dag_json_cidv1": {
|
||||
"/": "baguqeera3y2rxvu4gu62diceobs26of2conaizpuuahl32czapq2go6j365a"
|
||||
"/": "baguqeera3hjouivo7ys5vkyyzl4rokbpj5zvyrehn65muw7u2tkx4y4gkbga"
|
||||
},
|
||||
"isolation_receipt": {
|
||||
"all_unchanged": true,
|
||||
@@ -28508,7 +28508,7 @@
|
||||
"title": "TierZoo Ecological Trophic Index (ETI)"
|
||||
}
|
||||
},
|
||||
"namespace_urn": "urn:io:hyperstitionstud:quant-timeseries:2.0.18",
|
||||
"namespace_urn": "urn:io:hyperstitionstud:quant-timeseries:2.0.19",
|
||||
"periodicity_gate": {
|
||||
"allowed_cadences": [
|
||||
"1d-us-closing-bell-2130-utc",
|
||||
@@ -28530,5 +28530,5 @@
|
||||
],
|
||||
"non_periodic_records_ingested": 0
|
||||
},
|
||||
"version": "2.0.18"
|
||||
"version": "2.0.19"
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
"""hyperstitionstud_io — Shared Common Library for the hyperstitionstud.io workspace (v2.0.18)."""
|
||||
__version__ = "2.0.18"
|
||||
"""hyperstitionstud_io — Shared Common Library for the hyperstitionstud.io workspace (v2.0.19)."""
|
||||
__version__ = "2.0.19"
|
||||
NAMESPACE_URN = "urn:io:hyperstitionstud"
|
||||
@@ -57,11 +57,25 @@ def run_diagnostics(workspace_root: str | Path | None = None) -> dict[str, Any]:
|
||||
fb_path = Path(__file__).resolve().parent.parent / "phonetics" / "cmudict_fallback.json"
|
||||
fb_count = len(json.loads(fb_path.read_text(encoding="utf-8"))) if fb_path.is_file() else 0
|
||||
|
||||
lr_path = cfg.core_dir / "deploy" / "logrotate.d" / "hyperstition-sqlite-meta"
|
||||
lr_txt = lr_path.read_text(encoding="utf-8") if lr_path.is_file() else ""
|
||||
lr_ok = (
|
||||
lr_path.is_file()
|
||||
and "size 100M" in lr_txt
|
||||
and "compress" in lr_txt
|
||||
and "nocompress" not in lr_txt
|
||||
and "rotate 0" not in lr_txt
|
||||
and "--truncate-quiescent" in lr_txt
|
||||
and "--compress-archive" in lr_txt
|
||||
and "prerotate" in lr_txt
|
||||
)
|
||||
|
||||
all_ok = (
|
||||
pkgs.get("Pillow") is not None
|
||||
and all(dirs_ok.values())
|
||||
and all(v["matches_baseline"] for v in isolation_checks.values())
|
||||
and fb_count >= 190
|
||||
and lr_ok
|
||||
)
|
||||
|
||||
return {
|
||||
@@ -74,6 +88,12 @@ def run_diagnostics(workspace_root: str | Path | None = None) -> dict[str, Any]:
|
||||
"truetype_fonts": fonts_resolved,
|
||||
"workspace_directories": dirs_ok,
|
||||
"offline_cmudict_fallback_entries": fb_count,
|
||||
"sqlite_logrotate_config": {
|
||||
"path": str(lr_path),
|
||||
"exists": lr_path.is_file(),
|
||||
"default_size_limit": "100M",
|
||||
"quiescent_truncation_configured": lr_ok,
|
||||
},
|
||||
"citation_path_mounts": cfg.citation_path_mounts,
|
||||
"isolation_locks": isolation_checks,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
hyperstitionstud_io.db — Standalone SQLite + FTS5 Catalog & REST/MCP Telemetry Database Engine.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from hyperstitionstud_io.db.sqlite_meta import (
|
||||
DEFAULT_MAX_TELEMETRY_BYTES,
|
||||
DEFAULT_MAX_TELEMETRY_MB,
|
||||
build_catalog_sqlite_db,
|
||||
ensure_catalog_sqlite_db,
|
||||
get_api_telemetry_summary,
|
||||
get_default_catalog_db_path,
|
||||
get_default_telemetry_db_path,
|
||||
parse_size_spec_bytes,
|
||||
query_coordinate_join,
|
||||
query_fts_catalog,
|
||||
query_registry_manifests,
|
||||
query_timeseries_bars,
|
||||
record_api_telemetry,
|
||||
run_logrotate_directive,
|
||||
truncate_telemetry_db_quiescent,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"DEFAULT_MAX_TELEMETRY_BYTES",
|
||||
"DEFAULT_MAX_TELEMETRY_MB",
|
||||
"build_catalog_sqlite_db",
|
||||
"ensure_catalog_sqlite_db",
|
||||
"get_api_telemetry_summary",
|
||||
"get_default_catalog_db_path",
|
||||
"get_default_telemetry_db_path",
|
||||
"parse_size_spec_bytes",
|
||||
"query_coordinate_join",
|
||||
"query_fts_catalog",
|
||||
"query_registry_manifests",
|
||||
"query_timeseries_bars",
|
||||
"record_api_telemetry",
|
||||
"run_logrotate_directive",
|
||||
"truncate_telemetry_db_quiescent",
|
||||
]
|
||||
File diff suppressed because it is too large.
Load diff
@@ -10,11 +10,13 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import time
|
||||
import urllib.parse
|
||||
from typing import Any
|
||||
|
||||
from hyperstitionstud_io import __version__ as CURRENT_VERSION
|
||||
from hyperstitionstud_io.config import load_workspace_config
|
||||
from hyperstitionstud_io.db.sqlite_meta import record_api_telemetry
|
||||
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard
|
||||
from hyperstitionstud_io.mcp.prompts import MCP_PROMPTS, get_mcp_prompt
|
||||
from hyperstitionstud_io.mcp.resources import (
|
||||
@@ -193,19 +195,30 @@ def _error_response(status: int, code: str, message: str) -> tuple[int, str, dic
|
||||
)
|
||||
|
||||
|
||||
def dispatch_rest_v1(
|
||||
def _normalize_rest_endpoint_pattern(path: str) -> str:
|
||||
if re.match(r"^/api/v1/graph/nodes/.+$", path):
|
||||
return "/api/v1/graph/nodes/{node_id}"
|
||||
if re.match(r"^/api/v1/quant/instruments/[^/]+$", path):
|
||||
return "/api/v1/quant/instruments/{symbol}"
|
||||
if re.match(r"^/api/v1/zoology/pokedex/[^/]+$", path):
|
||||
return "/api/v1/zoology/pokedex/{symbol}"
|
||||
if re.match(r"^/api/v1/resources/[a-z0-9-]+$", path):
|
||||
return "/api/v1/resources/{slug}"
|
||||
if re.match(r"^/api/v1/dossiers/\d+$", path):
|
||||
return "/api/v1/dossiers/{number}"
|
||||
if re.match(r"^/api/v1/schemas/[a-z0-9-]+$", path):
|
||||
return "/api/v1/schemas/{schema_slug}"
|
||||
if re.match(r"^/api/v1/prompts/[a-z0-9_]+$", path):
|
||||
return "/api/v1/prompts/{prompt_name}"
|
||||
return path
|
||||
|
||||
|
||||
def _dispatch_rest_v1_inner(
|
||||
method: str,
|
||||
raw_path: str,
|
||||
path: str,
|
||||
query_str: str,
|
||||
body_bytes: bytes = b"",
|
||||
) -> tuple[int, str, Any]:
|
||||
"""
|
||||
Dispatch an HTTP GET or POST request under `/api/v1/*`.
|
||||
Returns `(http_status_code, content_type, response_payload_or_text)`.
|
||||
"""
|
||||
parsed_url = urllib.parse.urlsplit(raw_path)
|
||||
path = parsed_url.path.rstrip("/") or "/api/v1"
|
||||
query_str = parsed_url.query
|
||||
|
||||
cfg = load_workspace_config()
|
||||
try:
|
||||
with ReadOnlyIsolationGuard(cfg.read_only_files) as guard:
|
||||
@@ -363,3 +376,30 @@ def dispatch_rest_v1(
|
||||
return _error_response(status, "VALIDATION_ERROR", msg)
|
||||
except Exception as exc:
|
||||
return _error_response(500, "INTERNAL_ERROR", str(exc))
|
||||
|
||||
|
||||
def dispatch_rest_v1(
|
||||
method: str,
|
||||
raw_path: str,
|
||||
body_bytes: bytes = b"",
|
||||
) -> tuple[int, str, Any]:
|
||||
"""
|
||||
Dispatch an HTTP GET or POST request under `/api/v1/*` and automatically record
|
||||
the request metadata and latency in the SQLite REST API metadata database (`api-telemetry.db`).
|
||||
Returns `(http_status_code, content_type, response_payload_or_text)`.
|
||||
"""
|
||||
parsed_url = urllib.parse.urlsplit(raw_path)
|
||||
path = parsed_url.path.rstrip("/") or "/api/v1"
|
||||
query_str = parsed_url.query
|
||||
t0_ns = time.perf_counter_ns()
|
||||
status, ctype, payload = _dispatch_rest_v1_inner(method, path, query_str, body_bytes)
|
||||
elapsed_us = max(1, (time.perf_counter_ns() - t0_ns) // 1000)
|
||||
record_api_telemetry(
|
||||
protocol="rest_v1",
|
||||
method=method.upper(),
|
||||
endpoint_pattern=_normalize_rest_endpoint_pattern(path),
|
||||
status_code=status,
|
||||
latency_us=elapsed_us,
|
||||
isolation_ok=True,
|
||||
)
|
||||
return status, ctype, payload
|
||||
@@ -12,6 +12,7 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
@@ -21,6 +22,7 @@ if _SRC_DIR.is_dir() and str(_SRC_DIR) not in sys.path:
|
||||
sys.path.insert(0, str(_SRC_DIR))
|
||||
|
||||
from hyperstitionstud_io.config import load_workspace_config # noqa: E402
|
||||
from hyperstitionstud_io.db.sqlite_meta import record_api_telemetry # noqa: E402
|
||||
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard # noqa: E402
|
||||
from hyperstitionstud_io.mcp.prompts import MCP_PROMPTS, get_mcp_prompt # noqa: E402
|
||||
from hyperstitionstud_io.mcp.resources import ( # noqa: E402
|
||||
@@ -33,8 +35,8 @@ from hyperstitionstud_io.mcp.tools import MCP_TOOLS_SCHEMA, call_mcp_tool # noq
|
||||
|
||||
SERVER_INFO = {
|
||||
"name": "hyperstitionstudio-mcp",
|
||||
"version": "2.0.18",
|
||||
"namespace_urn": "urn:io:hyperstitionstud:mcp:2.0.18",
|
||||
"version": "2.0.19",
|
||||
"namespace_urn": "urn:io:hyperstitionstud:mcp:2.0.19",
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +52,14 @@ def dispatch_jsonrpc(req: dict[str, Any]) -> dict[str, Any] | None:
|
||||
if method.startswith("notifications/"):
|
||||
return None
|
||||
|
||||
t0_ns = time.perf_counter_ns()
|
||||
rpc_pattern = method
|
||||
if method == "tools/call":
|
||||
rpc_pattern = f"tools/call:{params.get('name', '')}"
|
||||
elif method == "prompts/get":
|
||||
rpc_pattern = f"prompts/get:{params.get('name', '')}"
|
||||
status_code = 200
|
||||
|
||||
cfg = load_workspace_config()
|
||||
try:
|
||||
with ReadOnlyIsolationGuard(cfg.read_only_files):
|
||||
@@ -96,12 +106,14 @@ def dispatch_jsonrpc(req: dict[str, Any]) -> dict[str, Any] | None:
|
||||
p_args = params.get("arguments") or {}
|
||||
result = get_mcp_prompt(p_name, p_args)
|
||||
else:
|
||||
status_code = 404
|
||||
return {
|
||||
"jsonrpc": "2.0",
|
||||
"id": req_id,
|
||||
"error": {"code": -32601, "message": f"Method not found: {method}"},
|
||||
}
|
||||
except Exception as exc:
|
||||
status_code = 422
|
||||
if method == "tools/call":
|
||||
return {
|
||||
"jsonrpc": "2.0",
|
||||
@@ -116,6 +128,16 @@ def dispatch_jsonrpc(req: dict[str, Any]) -> dict[str, Any] | None:
|
||||
"id": req_id,
|
||||
"error": {"code": -32602, "message": str(exc)},
|
||||
}
|
||||
finally:
|
||||
elapsed_us = max(1, (time.perf_counter_ns() - t0_ns) // 1000)
|
||||
record_api_telemetry(
|
||||
protocol="mcp_jsonrpc",
|
||||
method="POST",
|
||||
endpoint_pattern=rpc_pattern or "unknown",
|
||||
status_code=status_code,
|
||||
latency_us=elapsed_us,
|
||||
isolation_ok=True,
|
||||
)
|
||||
|
||||
return {"jsonrpc": "2.0", "id": req_id, "result": result}
|
||||
|
||||
|
||||
@@ -496,7 +496,7 @@ def build_financial_quant_harvest(
|
||||
payload: dict[str, Any] = {
|
||||
"$schema": "./schemas/v1/financial-aq-harvest.schema.json",
|
||||
"$id": "urn:io:hyperstitionstud:schema:v1:financial-aq-harvest",
|
||||
"version": "2.0.18",
|
||||
"version": "2.0.19",
|
||||
"target_date_utc": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d"),
|
||||
"harvest_mode": harvest_mode,
|
||||
"regime_summary": {
|
||||
|
||||
@@ -275,6 +275,135 @@ def test_ipld_quant_and_mcp_server() -> None:
|
||||
err_code, _, err_body = dispatch_rest_v1("GET", "/api/v1/ciphers/evaluate")
|
||||
assert err_code == 422 and err_body["ok"] is False
|
||||
|
||||
# 5. SQLite + FTS5 Catalog, Automatic REST/MCP Telemetry Population, Inactive Plan Isolation & Quiescent Logrotate Truncation
|
||||
import os
|
||||
import sqlite3
|
||||
import tempfile
|
||||
|
||||
from hyperstitionstud_io.db.sqlite_meta import (
|
||||
DEFAULT_MAX_TELEMETRY_BYTES,
|
||||
build_catalog_sqlite_db,
|
||||
get_api_telemetry_summary,
|
||||
parse_size_spec_bytes,
|
||||
query_coordinate_join,
|
||||
query_fts_catalog,
|
||||
query_registry_manifests,
|
||||
query_timeseries_bars,
|
||||
run_logrotate_directive,
|
||||
truncate_telemetry_db_quiescent,
|
||||
)
|
||||
|
||||
assert DEFAULT_MAX_TELEMETRY_BYTES == 100 * 1024 * 1024
|
||||
assert parse_size_spec_bytes("100M") == 100 * 1024 * 1024
|
||||
assert parse_size_spec_bytes("100MB") == 100 * 1024 * 1024
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
tmp_path = Path(tmp_dir)
|
||||
cat_db = tmp_path / "test-catalog.db"
|
||||
tel_db = tmp_path / "test-telemetry.db"
|
||||
|
||||
cat_res = build_catalog_sqlite_db(cat_db)
|
||||
assert cat_res["isolation_receipt"]["all_unchanged"] is True
|
||||
assert cat_res["counts"]["registry_manifests"] >= 7
|
||||
assert cat_res["counts"]["glossary_entries"] >= 282
|
||||
assert cat_res["counts"]["kg_nodes"] == 388
|
||||
assert cat_res["counts"]["kg_edges"] == 1282
|
||||
assert cat_res["counts"]["dossiers"] >= 71
|
||||
assert cat_res["counts"]["quant_timeseries_bars"] == 720
|
||||
|
||||
manifests = query_registry_manifests(cat_db)
|
||||
assert any(m["registry_slug"] == "encyclopedia-graph" and m["dag_json_cidv1"].startswith("baguqeera") for m in manifests)
|
||||
|
||||
fts_res = query_fts_catalog("envideea", db_path=cat_db)
|
||||
assert fts_res["match_count"] >= 1
|
||||
|
||||
coord_137 = query_coordinate_join(137, db_path=cat_db)
|
||||
assert coord_137["coordinate_aq"] == 137
|
||||
assert len(coord_137["kg_nodes"]) >= 1
|
||||
assert len(coord_137["quant_timeseries_bars"]) >= 1
|
||||
|
||||
nvda_bars = query_timeseries_bars(symbol="NVDA", min_points=1.0, db_path=cat_db)
|
||||
assert len(nvda_bars) >= 1 and all(b["symbol"] == "NVDA" for b in nvda_bars)
|
||||
|
||||
# Verify MCP and REST API calls automatically populate the SQLite REST API metadata database
|
||||
prev_tel_env = os.environ.get("HYPERSTITION_TELEMETRY_DB_PATH")
|
||||
os.environ["HYPERSTITION_TELEMETRY_DB_PATH"] = str(tel_db)
|
||||
try:
|
||||
s1, _, _ = dispatch_rest_v1("GET", "/api/v1/status")
|
||||
s2, _, _ = dispatch_rest_v1("GET", "/api/v1/quant/instruments/NVDA")
|
||||
m1 = dispatch_jsonrpc({"jsonrpc": "2.0", "id": 99, "method": "tools/list"})
|
||||
assert s1 == 200 and s2 == 200 and m1 is not None
|
||||
|
||||
# Verify inactive plan routes (/api/v1/meta/*, hs_query_sqlite_catalog) remain unexposed (404)
|
||||
inact_meta_code, _, _ = dispatch_rest_v1("GET", "/api/v1/meta/manifests")
|
||||
inact_tool_code, _, _ = dispatch_rest_v1("GET", "/api/v1/tools/hs_query_sqlite_catalog")
|
||||
assert inact_meta_code == 404
|
||||
assert inact_tool_code == 404
|
||||
|
||||
summary_before = get_api_telemetry_summary(tel_db)
|
||||
assert summary_before["total_requests"] == 5
|
||||
assert summary_before["ringbuffer_count"] == 5
|
||||
protocols_seen = {ep["protocol"] for ep in summary_before["endpoints"]}
|
||||
assert protocols_seen == {"rest_v1", "mcp_jsonrpc"}
|
||||
patterns_seen = {ep["endpoint_pattern"] for ep in summary_before["endpoints"]}
|
||||
assert "/api/v1/status" in patterns_seen
|
||||
assert "/api/v1/quant/instruments/{symbol}" in patterns_seen
|
||||
assert "tools/list" in patterns_seen
|
||||
assert all(ev["isolation_ok"] == 1 for ev in summary_before["recent_audit_events"])
|
||||
|
||||
# Verify logrotate.d file configuration (default 100M = 100MB, compress enabled, rotate >= 12) & no-op when below limit
|
||||
import gzip
|
||||
|
||||
lr_noop = run_logrotate_directive(telemetry_db_path=tel_db)
|
||||
assert lr_noop["configured_size_directive"].upper() == "100M"
|
||||
assert lr_noop["configured_default_bytes"] == 100 * 1024 * 1024
|
||||
assert lr_noop["compress_enabled"] is True
|
||||
assert lr_noop["rotate_count"] >= 12
|
||||
assert lr_noop["truncated"] is False
|
||||
assert get_api_telemetry_summary(tel_db)["total_requests"] == 5
|
||||
|
||||
# Verify logrotate.d quiescent compression + truncation when DB size >= configured limit
|
||||
lr_trunc = run_logrotate_directive(telemetry_db_path=tel_db, max_bytes_override=1024)
|
||||
assert lr_trunc["truncated"] is True
|
||||
assert lr_trunc["quiescent"] is True
|
||||
assert lr_trunc["integrity_check"] == "ok"
|
||||
assert lr_trunc["compressed_archive_path"] == f"{tel_db}.1.gz"
|
||||
assert lr_trunc["compressed_archive_bytes"] > 0
|
||||
assert Path(lr_trunc["compressed_archive_path"]).is_file()
|
||||
|
||||
# Verify the compressed .1.gz archive preserved all 5 pre-truncation requests & passes SQLite integrity_check
|
||||
restored_db = tmp_path / "restored-from-gz.db"
|
||||
with gzip.open(lr_trunc["compressed_archive_path"], "rb") as f_gz:
|
||||
restored_db.write_bytes(f_gz.read())
|
||||
with sqlite3.connect(str(restored_db)) as r_conn:
|
||||
assert r_conn.execute("PRAGMA integrity_check;").fetchone()[0] == "ok"
|
||||
assert get_api_telemetry_summary(restored_db)["total_requests"] == 5
|
||||
|
||||
summary_after = get_api_telemetry_summary(tel_db)
|
||||
assert summary_after["total_requests"] == 0
|
||||
assert summary_after["ringbuffer_count"] == 0
|
||||
|
||||
# Verify SQLite integrity_check == 'ok' and continued automatic population after quiescent truncation
|
||||
with sqlite3.connect(str(tel_db)) as check_conn:
|
||||
assert check_conn.execute("PRAGMA integrity_check;").fetchone()[0] == "ok"
|
||||
|
||||
s_post, _, _ = dispatch_rest_v1("GET", "/api/v1/status")
|
||||
assert s_post == 200
|
||||
assert get_api_telemetry_summary(tel_db)["total_requests"] == 1
|
||||
|
||||
# Also verify second rotation shifts .1.gz -> .2.gz and writes new .1.gz
|
||||
direct_trunc = truncate_telemetry_db_quiescent(tel_db, max_bytes=512, force=False)
|
||||
assert direct_trunc["truncated"] is True
|
||||
assert direct_trunc["quiescent"] is True
|
||||
assert direct_trunc["integrity_check"] == "ok"
|
||||
assert Path(f"{tel_db}.1.gz").is_file()
|
||||
assert Path(f"{tel_db}.2.gz").is_file()
|
||||
finally:
|
||||
if prev_tel_env is None:
|
||||
os.environ.pop("HYPERSTITION_TELEMETRY_DB_PATH", None)
|
||||
else:
|
||||
os.environ["HYPERSTITION_TELEMETRY_DB_PATH"] = prev_tel_env
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_offline_urn_namespaces_and_no_external_https_fonts()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# workspace.example.toml — Location-Independent Workspace Configuration Template (v1.2.0)
|
||||
# Copy to your parent workspace folder: cp hyperstitionstudio-core/workspace.example.toml ./workspace.toml
|
||||
schema_version = "2.0.18"
|
||||
schema_version = "2.0.19"
|
||||
namespace_urn = "urn:io:hyperstitionstud"
|
||||
|
||||
[paths]
|
||||
|
||||
Reference in new issue
Block a user