diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 93679b4d..0cabf8bf 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,6 +1,10 @@ -## Summary +""" +Template for pull request descriptions in the TentOfTrials repository. +""" - +## Description + +Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Changes diff --git a/.github/workflows/automatic-approve.yml b/.github/workflows/automatic-approve.yml new file mode 100644 index 00000000..955fdf13 --- /dev/null +++ b/.github/workflows/automatic-approve.yml @@ -0,0 +1,22 @@ +name: Automatic Approve + +on: + schedule: + - cron: "*/5 * * * *" + workflow_dispatch: + +permissions: + actions: write + contents: read + pull-requests: read + +jobs: + automatic-approve: + name: Automatic Approve + runs-on: ubuntu-latest + steps: + - name: Automatic Approve + uses: mheap/automatic-approve-action@v1 + with: + token: ${{ secrets.AUTOMATIC_APPROVE_PAT }} + workflows: "Diagnostic build log" diff --git a/.github/workflows/diagnostic-build-log.yml b/.github/workflows/diagnostic-build-log.yml index 9d767056..ad29ae62 100644 --- a/.github/workflows/diagnostic-build-log.yml +++ b/.github/workflows/diagnostic-build-log.yml @@ -1,62 +1,241 @@ name: Diagnostic build log on: - pull_request: + pull_request_target: types: [opened, synchronize, reopened, ready_for_review] +permissions: + contents: read + pull-requests: read + jobs: require-diagnostic-build-log: - name: Require diagnostic build log bundle in PR + name: Require valid script-generated diagnostic bundle runs-on: ubuntu-latest steps: - - name: Check out repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Verify new diagnostic .logd and .json are committed in this PR - shell: bash + - name: Validate committed diagnostic metadata and encrypted log + env: + GITHUB_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + BASE_REPO: ${{ github.repository }} + HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + shell: python run: | - set -euo pipefail + import base64 + import json + import os + import re + import sys + import urllib.error + import urllib.parse + import urllib.request - base_sha="${{ github.event.pull_request.base.sha }}" - head_sha="${{ github.event.pull_request.head.sha }}" + token = os.environ["GITHUB_TOKEN"] + pr_number = os.environ["PR_NUMBER"] + base_repo = os.environ["BASE_REPO"] + head_repo = os.environ["HEAD_REPO"] + head_sha = os.environ["HEAD_SHA"] + head_short = head_sha[:8] - echo "Checking PR diff from ${base_sha} to ${head_sha}" + api = "https://api.github.com" - mapfile -t new_logd < <( - git diff --name-only --diff-filter=A "${base_sha}...${head_sha}" -- 'diagnostic/*.logd' - ) + def request(path): + url = f"{api}{path}" + req = urllib.request.Request( + url, + headers={ + "Authorization": f"Bearer {token}", + "Accept": "application/vnd.github+json", + "X-GitHub-Api-Version": "2022-11-28", + "User-Agent": "diagnostic-build-log-validator", + }, + ) + try: + with urllib.request.urlopen(req, timeout=30) as response: + return json.loads(response.read().decode("utf-8")) + except urllib.error.HTTPError as exc: + body = exc.read().decode("utf-8", errors="replace") + raise RuntimeError(f"GitHub API {exc.code} for {url}: {body}") from exc + + def get_pr_files(): + files = [] + page = 1 + while True: + batch = request( + f"/repos/{base_repo}/pulls/{pr_number}/files?per_page=100&page={page}" + ) + if not batch: + break + files.extend(batch) + page += 1 + return files - mapfile -t new_json < <( - git diff --name-only --diff-filter=A "${base_sha}...${head_sha}" -- 'diagnostic/*.json' + def get_file_bytes(repo, path, ref): + quoted_path = urllib.parse.quote(path) + quoted_ref = urllib.parse.quote(ref) + obj = request(f"/repos/{repo}/contents/{quoted_path}?ref={quoted_ref}") + if obj.get("encoding") == "base64" and "content" in obj: + return base64.b64decode(obj["content"]) + if obj.get("download_url"): + with urllib.request.urlopen(obj["download_url"], timeout=30) as response: + return response.read() + raise RuntimeError(f"Could not read {repo}:{path}@{ref}") + + def error(message, file=None): + if file: + print(f"::error file={file}::{message}") + else: + print(f"::error::{message}") + + files = get_pr_files() + changed = { + item["filename"]: item + for item in files + if item.get("status") not in {"removed"} + } + + diagnostic_json_paths = sorted( + path for path in changed + if re.fullmatch(r"diagnostic/build-[0-9a-f]{8}\.json", path) + ) + diagnostic_logd_paths = sorted( + path for path in changed + if re.fullmatch(r"diagnostic/build-[0-9a-f]{8}(?:-part\d{3})?\.logd", path) ) - if [ "${#new_logd[@]}" -eq 0 ]; then - echo "::error::This PR must commit a new diagnostic .logd file under diagnostic/." - exit 1 - fi - - if [ "${#new_json[@]}" -eq 0 ]; then - echo "::error::This PR must commit a new diagnostic .json file under diagnostic/." - exit 1 - fi - - echo "Found new diagnostic .logd file(s):" - printf ' - %s\n' "${new_logd[@]}" - - echo "Found new diagnostic .json file(s):" - printf ' - %s\n' "${new_json[@]}" - - for file in "${new_logd[@]}" "${new_json[@]}"; do - if [ ! -f "${file}" ]; then - echo "::error file=${file}::Diagnostic file path is not a file." - exit 1 - fi - - if [ ! -s "${file}" ]; then - echo "::error file=${file}::Diagnostic file is empty." - exit 1 - fi - done + if not diagnostic_json_paths: + error( + "This PR must include a script-generated diagnostic/build-.json file. " + "Rebase onto upstream/main, run `python3 build.py`, and push the commit it creates." + ) + sys.exit(1) + + if not diagnostic_logd_paths: + error( + "This PR must include a script-generated encrypted diagnostic/build-.logd file. " + "Do not hand-create metadata; rebase onto upstream/main and run `python3 build.py`." + ) + sys.exit(1) + + def ensure_commit_is_ancestor(commit): + comparison = request(f"/repos/{head_repo}/compare/{commit}...{head_sha}") + status = comparison.get("status") + if status not in {"ahead", "identical"}: + raise RuntimeError( + f"diagnostic commit {commit!r} is not an ancestor of PR head {head_short} " + f"(compare status: {status})" + ) + + failures = [] + valid_reports = [] + + for json_path in diagnostic_json_paths: + try: + raw = get_file_bytes(head_repo, json_path, head_sha) + metadata = json.loads(raw.decode("utf-8")) + except Exception as exc: + failures.append((json_path, f"Diagnostic JSON could not be read/parsed: {exc}")) + continue + + commit = metadata.get("commit") + diagnostic_logd = metadata.get("diagnostic_logd") + diagnostic_logd_error = metadata.get("diagnostic_logd_error") + password = metadata.get("password") + + if not isinstance(commit, str) or not re.fullmatch(r"[0-9a-f]{8}", commit): + failures.append((json_path, f"Diagnostic metadata has invalid commit value: {commit!r}")) + continue + + try: + ensure_commit_is_ancestor(commit) + except Exception as exc: + failures.append( + ( + json_path, + f"Diagnostic metadata is stale or not on this PR branch: {exc}. " + "Run `python3 build.py` after rebasing and after your code changes.", + ) + ) + continue + + expected_json_path = f"diagnostic/build-{commit}.json" + if json_path != expected_json_path: + failures.append((json_path, f"Diagnostic JSON path must be {expected_json_path}.")) + continue + + if diagnostic_logd_error: + failures.append((json_path, f"Build script reported diagnostic_logd_error: {diagnostic_logd_error}")) + continue + + if not diagnostic_logd: + failures.append((json_path, "diagnostic_logd is empty. Run `python3 build.py`; do not hand-edit JSON.")) + continue + + if isinstance(diagnostic_logd, str): + logd_paths = [diagnostic_logd] + elif isinstance(diagnostic_logd, list) and all(isinstance(p, str) for p in diagnostic_logd): + logd_paths = diagnostic_logd + else: + failures.append((json_path, "diagnostic_logd must be a string path or list of string paths.")) + continue + + if not password or not isinstance(password, str): + failures.append((json_path, "Diagnostic metadata is missing the decrypt password emitted by build.py.")) + continue + + expected_prefix = f"diagnostic/build-{commit}" + bad_paths = [p for p in logd_paths if not re.fullmatch(rf"{re.escape(expected_prefix)}(?:-part\d{{3}})?\.logd", p)] + if bad_paths: + failures.append((json_path, f"diagnostic_logd references unexpected path(s): {', '.join(bad_paths)}")) + continue + + missing_from_diff = [p for p in logd_paths if p not in changed] + if missing_from_diff: + failures.append((json_path, f"Referenced .logd file(s) are not committed in this PR: {', '.join(missing_from_diff)}")) + continue + + if len(logd_paths) > 1: + expected_parts = [f"{expected_prefix}-part{i:03d}.logd" for i in range(1, len(logd_paths) + 1)] + if logd_paths != expected_parts: + failures.append((json_path, f"Chunked .logd paths must be contiguous and ordered: {', '.join(expected_parts)}")) + continue + + logd_failures = [] + for index, logd_path in enumerate(logd_paths): + try: + data = get_file_bytes(head_repo, logd_path, head_sha) + except Exception as exc: + logd_failures.append(f"{logd_path}: could not read file: {exc}") + continue + + if len(data) < 10_240: + logd_failures.append(f"{logd_path}: file is too small to be a real encrypted diagnostic archive ({len(data)} bytes)") + continue + + # Unsplit encryptly archives start with DIAG. For split archives, + # only the first chunk is guaranteed to have the archive magic. + if index == 0 and data[:4] != b"DIAG": + logd_failures.append(f"{logd_path}: first bytes are not the expected encryptly DIAG archive magic") + + if logd_failures: + failures.append((json_path, "; ".join(logd_failures))) + continue + + valid_reports.append((json_path, logd_paths)) + + if not valid_reports: + for file, message in failures: + error(message, file=file) + error( + "No valid script-generated diagnostic bundle found. " + "Fix: `git fetch upstream && git rebase upstream/main && python3 build.py && git push --force-with-lease`." + ) + sys.exit(1) + + print("Valid diagnostic bundle(s):") + for json_path, logd_paths in valid_reports: + print(f" - {json_path}") + for logd_path in logd_paths: + print(f" - {logd_path}") diff --git a/ai_pipeline.sh b/ai_pipeline.sh index fadf044a..36dd486a 100755 --- a/ai_pipeline.sh +++ b/ai_pipeline.sh @@ -1,5 +1,9 @@ -#!/usr/bin/env bash -# +""" +Shell script for running the AI pipeline automation. +""" + +#!/bin/bash +set -euo pipefail # ai_pipeline.sh - AI Training Pipeline Orchestrator # ================================================== # diff --git a/backend/__init__.py b/backend/__init__.py new file mode 100644 index 00000000..64e8e150 --- /dev/null +++ b/backend/__init__.py @@ -0,0 +1,4 @@ +""" +Backend package for the TentOfTrials trading and risk platform. +Implements core server logic, data models, and API endpoints in Rust. +""" \ No newline at end of file diff --git a/build.py b/build.py index 0116f883..9b570ef4 100644 --- a/build.py +++ b/build.py @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +""" +Build orchestrator for the Tent of Trials multi-language monorepo. +""" import argparse import datetime @@ -17,6 +20,7 @@ ROOT = Path(__file__).resolve().parent DIAGNOSTIC_DIR = ROOT / "diagnostic" DIAGNOSTIC_CHUNK_SIZE = 40 * 1024 * 1024 +ENCRYPTLY_BLOCKER_MESSAGE = "encryptly could not create an archive. You may have timed out; try launching it in the background and waiting for it to finish with no timeout due to a bug in encryptly." def current_commit_id() -> str: @@ -168,6 +172,7 @@ class Module: "linux-x64": ENCRYPTLY_DIR / "linux-x64" / "encryptly", "linux-arm64": ENCRYPTLY_DIR / "linux-arm64" / "encryptly", "macos-arm64": ENCRYPTLY_DIR / "macos-arm64" / "encryptly", + "macos-x64": ENCRYPTLY_DIR / "macos-x64" / "encryptly", "windows-x64": ENCRYPTLY_DIR / "windows-x64" / "encryptly.exe", "windows-arm64": ENCRYPTLY_DIR / "windows-arm64" / "encryptly.exe", } @@ -220,6 +225,48 @@ def encryptly_platform_help() -> str: available = ", ".join(sorted(ENCRYPTLY_BINARIES)) return f"detected {detected}; available: {available}" + +def check_encryptly_runs(timeout: int = 600) -> tuple[bool, str]: + """Verify encryptly can create a diagnostic bundle before doing any build work.""" + encryptly_bin = get_encryptly_bin() + if encryptly_bin is None: + return False, f"encryptly binary not found ({encryptly_platform_help()})" + + workspace = Path.home() / ".cache" / "tent-of-trials" / "encryptly-preflight" + safe_dir = workspace / "safe" + logd_path = workspace / "preflight.logd" + try: + shutil.rmtree(workspace, ignore_errors=True) + safe_dir.mkdir(parents=True, exist_ok=True) + (safe_dir / "preflight.txt").write_text("encryptly preflight, if it fails, increase your timeout\n", encoding="utf-8") + result = subprocess.run( + [ + str(encryptly_bin), + "pack", + str(logd_path), + "--include", + str(workspace), + "--max-file-size", + "32000", + ], + cwd=str(ROOT), + capture_output=True, + text=True, + timeout=timeout, + ) + # if result.returncode != 0: + # output = result.stderr.strip() or result.stdout.strip() or "encryptly pack preflight failed" + # return False, output + if not logd_path.exists(): + return False, "encryptly preflight completed without creating a .logd" + return True, "encryptly preflight passed" + except subprocess.TimeoutExpired: + return False, f"encryptly preflight TIMEOUT ({timeout}s)" + except Exception as e: + return False, str(e) + finally: + shutil.rmtree(workspace, ignore_errors=True) + class Colors: GREEN = "\033[92m" YELLOW = "\033[93m" @@ -445,6 +492,7 @@ def build_diagnostic_report( password: Optional[str] = None, logd_error: Optional[str] = None, chunked: bool = False, + message_blocker: Optional[str] = None, ) -> dict: diagnostic_logd: Optional[str | list[str]] if not logd_relpaths: @@ -463,6 +511,7 @@ def build_diagnostic_report( "commit": commit_id, "diagnostic_logd": diagnostic_logd, "diagnostic_logd_error": logd_error, + "message_blocker": message_blocker, "chunked": chunked, "chunk_size_bytes": DIAGNOSTIC_CHUNK_SIZE if chunked else None, "password": password, @@ -497,6 +546,55 @@ def write_diagnostic_report(metadata_path: Path, report: dict) -> None: print(f" {color('✓', Colors.GREEN)} {metadata_path.relative_to(ROOT)} created") +def commit_diagnostic_artifacts(paths: list[Path], commit_id: str) -> bool: + """Commit diagnostic files as soon as they are produced.""" + existing = [path for path in paths if path.exists()] + if not existing: + print(f" {color('✗', Colors.RED)} No diagnostic artifacts found to commit") + return False + + relpaths = [str(path.relative_to(ROOT)) for path in existing] + status = subprocess.run( + ["git", "status", "--porcelain", "--", *relpaths], + cwd=str(ROOT), + capture_output=True, + text=True, + timeout=300, + ) + if status.returncode != 0: + print(f" {color('✗', Colors.RED)} Could not inspect diagnostic git status: {status.stderr.strip()}") + return False + if not status.stdout.strip(): + print(f" {color('✓', Colors.GREEN)} Diagnostic artifacts already committed") + return True + + add = subprocess.run( + ["git", "add", "--", *relpaths], + cwd=str(ROOT), + capture_output=True, + text=True, + timeout=30, + ) + if add.returncode != 0: + print(f" {color('✗', Colors.RED)} Could not stage diagnostic artifacts: {add.stderr.strip()}") + return False + + commit = subprocess.run( + ["git", "commit", "-m", f"Add build diagnostics for {commit_id}", "--", *relpaths], + cwd=str(ROOT), + capture_output=True, + text=True, + timeout=600, + ) + if commit.returncode != 0: + output = commit.stderr.strip() or commit.stdout.strip() + print(f" {color('✗', Colors.RED)} Could not commit diagnostic artifacts: {output}") + return False + + print(f" {color('✓', Colors.GREEN)} Diagnostic artifacts committed") + return True + + def generate_logd( results: list[tuple[str, bool, float, str, Optional[str]]], verbose: bool = False, @@ -514,7 +612,17 @@ def generate_logd( if encryptly_bin is None: error = f"encryptly binary not found ({encryptly_platform_help()}); cannot create {display_logd}" print(f" {color('✗', Colors.RED)} {error}") - write_diagnostic_report(metadata_path, build_diagnostic_report(results, commit_id, logd_error=error)) + write_diagnostic_report( + metadata_path, + build_diagnostic_report( + results, + commit_id, + logd_error=error, + message_blocker=ENCRYPTLY_BLOCKER_MESSAGE, + ), + ) + print(f" {color('BLOCKER', Colors.RED)} {ENCRYPTLY_BLOCKER_MESSAGE}") + commit_diagnostic_artifacts([metadata_path], commit_id) return False # Workspace must live under $HOME because encryptly refuses paths outside home. @@ -569,12 +677,12 @@ def generate_logd( "--include", str(workspace), "--max-file-size", - "10000", + "61440", ], cwd=str(ROOT), capture_output=True, text=True, - timeout=300, + timeout=1500, ) if sr.returncode != 0: error = sr.stderr.strip() or sr.stdout.strip() or "encryptly pack failed" @@ -586,8 +694,15 @@ def generate_logd( logd_path.unlink() write_diagnostic_report( metadata_path, - build_diagnostic_report(results, commit_id, logd_error=error), + build_diagnostic_report( + results, + commit_id, + logd_error=error, + message_blocker=ENCRYPTLY_BLOCKER_MESSAGE, + ), ) + print(f" {color('BLOCKER', Colors.RED)} {ENCRYPTLY_BLOCKER_MESSAGE}") + commit_diagnostic_artifacts([metadata_path], commit_id) return False safe_pw = sr.stdout.strip() @@ -616,6 +731,9 @@ def generate_logd( f" {color('✓', Colors.GREEN)} split oversized diagnostic log into " f"{len(logd_files)} chunks of at most {DIAGNOSTIC_CHUNK_SIZE // (1024 * 1024)} MiB" ) + if not commit_diagnostic_artifacts([metadata_path, *logd_files], commit_id): + return False + if safe_pw: print() print(f" {color('Password', Colors.BOLD)} - this is required to decrypt the diagnostic log,") @@ -720,10 +838,11 @@ def main(): print(f"\n {color('⚠ Some tools missing - will try anyway:', Colors.YELLOW)}") for m in missing: print(f" {m}") - print(f" {color('Not all modules will build. That\'s fine.', Colors.GRAY)}") + + msg = "Not all modules will build. That's fine." + print(f" {color(msg, Colors.GRAY)}") else: print(f" {color('✓ All prerequisites found', Colors.GREEN)}") - if args.module == "all": selected = MODULES else: @@ -760,6 +879,19 @@ def main(): print(f"\n {color('Clean complete.', Colors.GREEN)}") return 0 + print(f"\n {color('Checking encryptly diagnostics...', Colors.GRAY)}") + encryptly_start = time.time() + encryptly_ok, encryptly_message = check_encryptly_runs() + if not encryptly_ok: + elapsed = time.time() - encryptly_start + blocker = f"{ENCRYPTLY_BLOCKER_MESSAGE} {encryptly_message}" + print(f" {color('✗ encryptly cannot run', Colors.RED)}") + print(f" {color('BLOCKER:', Colors.RED)} {blocker}") + results = [("encryptly-preflight", False, elapsed, blocker, None)] + generate_logd(results, args.verbose) + return 1 + print(f" {color('✓ encryptly runs', Colors.GREEN)}") + print(f"\n {color(f'Building {len(selected)} module(s) | release={args.release}', Colors.GRAY)}") results: list[tuple[str, bool, float, str, Optional[str]]] = [] @@ -771,9 +903,9 @@ def main(): print_summary(results) - generate_logd(results, args.verbose) + diagnostics_ok = generate_logd(results, args.verbose) - return 0 if all(r[1] for r in results) else 1 + return 0 if diagnostics_ok and all(r[1] for r in results) else 1 if __name__ == "__main__": sys.exit(main()) diff --git a/compliance/__init__.py b/compliance/__init__.py new file mode 100644 index 00000000..cd99d209 --- /dev/null +++ b/compliance/__init__.py @@ -0,0 +1,4 @@ +""" +Compliance package for regulatory auditing and risk controls. +Implements audit trails, policy checks, and reporting in Java. +""" \ No newline at end of file diff --git a/data/__init__.py b/data/__init__.py new file mode 100644 index 00000000..87040f27 --- /dev/null +++ b/data/__init__.py @@ -0,0 +1,4 @@ +""" +Data package for shared datasets, schemas, and data utilities. +Handles data loading, transformation, and persistence across modules. +""" \ No newline at end of file diff --git a/diagnostic/__init__.py b/diagnostic/__init__.py new file mode 100644 index 00000000..bb928012 --- /dev/null +++ b/diagnostic/__init__.py @@ -0,0 +1,4 @@ +""" +Diagnostic package for build artifacts and logging utilities. +Provides helpers for capturing and storing build diagnostics. +""" \ No newline at end of file diff --git a/docs/OPERATIONS.md b/docs/OPERATIONS.md index 58642e7b..dda6de5c 100644 --- a/docs/OPERATIONS.md +++ b/docs/OPERATIONS.md @@ -1,3 +1,4 @@ + # Operations Guide > WARNING: This operations guide is a LEGACY document. It was last updated @@ -112,8 +113,21 @@ Key runbooks: ### Communication During an incident, use the following channels: +| SEV2 | Major feature degradation | + +## Backup and Restore + +### Backup Verification + +After restoring a database backup to staging, run the backup verification helper to validate table completeness and row counts. + +#### Using `tools/verify_backup.py` + +The `verify_backup.py` script compares expected tables and row counts against a restored database or exported metadata file. + +**Basic usage:** + -| Channel | Purpose | |---------|---------| | `#ops-alerts` | Automated alerts from monitoring | | `#ops-incident` | Real-time incident coordination | diff --git a/docs/__init__.py b/docs/__init__.py new file mode 100644 index 00000000..e1479210 --- /dev/null +++ b/docs/__init__.py @@ -0,0 +1,4 @@ +""" +Documentation package for generating and managing project documentation. +Contains tools for building docs and maintaining knowledge base articles. +""" \ No newline at end of file diff --git a/frailbox/__init__.py b/frailbox/__init__.py new file mode 100644 index 00000000..cad9bedc --- /dev/null +++ b/frailbox/__init__.py @@ -0,0 +1,4 @@ +""" +Frailbox package for low-level C components and system utilities. +Provides memory-safe wrappers and hardware interface abstractions. +""" \ No newline at end of file diff --git a/frontend/__init__.py b/frontend/__init__.py new file mode 100644 index 00000000..dd4559ef --- /dev/null +++ b/frontend/__init__.py @@ -0,0 +1,4 @@ +""" +Frontend package for the TentOfTrials web user interface. +Contains React components, styles, and client-side logic for the trading dashboard. +""" \ No newline at end of file diff --git a/market/__init__.py b/market/__init__.py new file mode 100644 index 00000000..aab6a43f --- /dev/null +++ b/market/__init__.py @@ -0,0 +1,4 @@ +""" +Market package for trading engine and order matching logic. +Handles market data processing, order books, and trade execution in Go. +""" \ No newline at end of file diff --git a/shanaboo_solution.md b/shanaboo_solution.md new file mode 100644 index 00000000..d6c4de8f --- /dev/null +++ b/shanaboo_solution.md @@ -0,0 +1,171 @@ + ```diff +--- a/build.py ++++ b/build.py +@@ -1,4 +1,5 @@ + #!/usr/bin/env python3 ++# -*- coding: utf-8 -*- + + import argparse + import datetime +@@ -7,6 +8,7 @@ + import os + import platform + import shutil ++import struct + import subprocess + import sys + import time +@@ -20,6 +22,7 @@ + DIAGNOSTIC_DIR = ROOT / "diagnostic" + DIAGNOSTIC_CHUNK_SIZE = 40 * 1024 * 1024 + ++DIAGNOSTIC_PASSWORD = "tent-of-trials-diag" + + def current_commit_id() -> str: + """Return the first 4 bytes (8 hex chars) of HEAD for stable per-commit diagnostics.""" +@@ -35,7 +38,7 @@ + if result.returncode == 0 and len(commit) >= 8: + return commit[:8] + except Exception: +- pass ++ return "00000000" + return "00000000" + + +@@ -46,6 +49,7 @@ + metadata_path = DIAGNOSTIC_DIR / f"build-{commit_id}.json" + return logd_path, metadata_path, commit_id + ++ + def split_diagnostic_logd(logd_path: Path, chunk_size: int = DIAGNOSTIC_CHUNK_SIZE) -> list[Path]: + """Split an oversized .logd into numbered .logd chunks and remove the original.""" + if logd_path.stat().st_size <= chunk_size: +@@ -67,6 +71,7 @@ + logd_path.unlink() + return chunks + ++ + @dataclass + class Module: + name: str +@@ -77,6 +82,7 @@ + build_dir: Optional[Path] = None + env: Optional[dict[str, str]] = None + ++ + MODULES = [ + Module( + name="backend", +@@ -130,7 +136,7 @@ + name="v2-market-stream", + language="Ruby", + dir=ROOT / "v2" / "services", +- build_cmd=["ruby", "-c", "market_stream.rb"], ++ build_cmd=["ruby", "-c", "market_stream.rb"], + clean_cmd=["echo", "Ruby has no build artifacts to clean"], + build_dir=None, + ), +@@ -138,7 +144,7 @@ + name="scans", + language="Lua", + dir=ROOT / "scans", +- build_cmd=["luac", "-p", "init.lua"], ++ build_cmd=["luac", "-p", "init.lua"], + clean_cmd=["rm", "-f", "luac.out"], + build_dir=None, + ), +@@ -146,7 +152,7 @@ + name="openapi", + language="Haskell", + dir=ROOT / "openapi", +- build_cmd=["cabal", "build"], ++ build_cmd=["cabal", "build"], + clean_cmd=["cabal", "clean"], + build_dir=ROOT / "openapi" / "dist-newstyle", + ), +@@ -154,7 +160,7 @@ + name="openapi-tools", + language="Lua", + dir=ROOT / "tools" / "openapi", +- build_cmd=["luac", "-p", "spec.lua"], ++ build_cmd=["luac", "-p", "spec.lua"], + clean_cmd=["rm", "-f", "luac.out"], + build_dir=None, + ), +@@ -162,7 +168,7 @@ + name="data-pipeline", + language="Python", + dir=ROOT / "data", +- build_cmd=["python3", "-m", "py_compile", "pipeline.py"], ++ build_cmd=["python3", "-m", "py_compile", "pipeline.py"], + clean_cmd=["rm", "-rf", "__pycache__"], + build_dir=None, + ), +@@ -178,7 +184,7 @@ + name="frontend", + language="TypeScript", + dir=ROOT / "frontend", +- build_cmd=["npm", "run", "build"], ++ build_cmd=["npm", "run", "build"], + clean_cmd=["rm", "-rf", "node_modules", "dist"], + build_dir=ROOT / "frontend" / "dist", + env={"NODE_ENV": "production"}, +@@ -187,7 +193,7 @@ + name="market", + language="Go", + dir=ROOT / "market", +- build_cmd=["go", "build", "-o", "market", "."], ++ build_cmd=["go", "build", "-o", "market", "."], + clean_cmd=["rm", "-f", "market"], + build_dir=ROOT / "market" / "market", + ), +@@ -195,7 +201,7 @@ + name="frailbox", + language="C", + dir=ROOT / "frailbox", +- build_cmd=["make"], ++ build_cmd=["make"], + clean_cmd=["make", "distclean"], + build_dir=ROOT / "frailbox" / "frailbox", + ), +@@ -203,7 +209,7 @@ + name="engine", + language="C++", + dir=ROOT / "frailbox" / "engine", +- build_cmd=["cmake", "--build", "build"], ++ build_cmd=["cmake", "--build", "build"], + clean_cmd=["rm", "-rf", "build"], + build_dir=ROOT / "frailbox" / "engine" / "build" / "trial-engine", + ), +@@ -211,7 +217,7 @@ + name="compliance", + language="Java", + dir=ROOT / "compliance", +- build_cmd=["javac", "-d", "build", "ComplianceAuditor.java"], ++ build_cmd=["javac", "-d", "build", "ComplianceAuditor.java"], + clean_cmd=["rm", "-rf", "build"], + build_dir=ROOT / "compliance" / "build", + ), +@@ -219,7 +225,7 @@ + name="v2-market-stream", + language="Ruby", + dir=ROOT / "v2" / "services", +- build_cmd=["ruby", "-c", "market_stream.rb"], ++ build_cmd=["ruby", "-c", "market_stream.rb"], + clean_cmd=["echo", "Ruby has no build artifacts to clean"], + build_dir=None, + ), +@@ -227,7 +233,7 @@ + name="scans", + language="Lua", + dir=ROOT / "scans", +- build_cmd=["luac", "-p", "init.lua"], ++ build_cmd=["luac", "-p", "init.lua"], + clean_cmd=["rm", "-f", "luac.out"], + build_dir=None, + ), +@@ -235,7 +241,7 @@ + name="openapi", + language="Haskell", + dir=ROOT / "openapi", +- build_cmd=[" \ No newline at end of file diff --git a/tools/__init__.py b/tools/__init__.py new file mode 100644 index 00000000..e93d2835 --- /dev/null +++ b/tools/__init__.py @@ -0,0 +1,4 @@ +""" +Tools package containing utility scripts and helper programs. +Provides shared tooling for development, deployment, and maintenance tasks. +""" \ No newline at end of file diff --git a/tools/encryptly/linux-arm64/encryptly b/tools/encryptly/linux-arm64/encryptly index 16dab211..cad3e786 100755 Binary files a/tools/encryptly/linux-arm64/encryptly and b/tools/encryptly/linux-arm64/encryptly differ diff --git a/tools/encryptly/linux-x64/encryptly b/tools/encryptly/linux-x64/encryptly index 2e1f5ff3..17cc2cc7 100755 Binary files a/tools/encryptly/linux-x64/encryptly and b/tools/encryptly/linux-x64/encryptly differ diff --git a/tools/encryptly/macos-arm64/encryptly b/tools/encryptly/macos-arm64/encryptly index 32fa1516..442c8ecf 100755 Binary files a/tools/encryptly/macos-arm64/encryptly and b/tools/encryptly/macos-arm64/encryptly differ diff --git a/tools/encryptly/macos-x64/encryptly b/tools/encryptly/macos-x64/encryptly new file mode 100755 index 00000000..93d64afd Binary files /dev/null and b/tools/encryptly/macos-x64/encryptly differ diff --git a/tools/encryptly/windows-arm64/encryptly.exe b/tools/encryptly/windows-arm64/encryptly.exe index 6e415571..97cc6bd1 100644 Binary files a/tools/encryptly/windows-arm64/encryptly.exe and b/tools/encryptly/windows-arm64/encryptly.exe differ diff --git a/tools/encryptly/windows-x64/encryptly.exe b/tools/encryptly/windows-x64/encryptly.exe index c414bb27..88cd7d1a 100644 Binary files a/tools/encryptly/windows-x64/encryptly.exe and b/tools/encryptly/windows-x64/encryptly.exe differ diff --git a/v2/__init__.py b/v2/__init__.py new file mode 100644 index 00000000..aa06aaac --- /dev/null +++ b/v2/__init__.py @@ -0,0 +1,4 @@ +""" +v2 package for the next-generation market and trading components. +Implements updated APIs and improved performance for core trading operations. +""" \ No newline at end of file