Skip to content

Releases

v2.1.0: Asynchronous Operations & Job Queue Engine

Choose a tag to compare

@jmrenouard jmrenouard released this 09 Nov 16:38
459295a

API Executor v2.1.0 Release Notes — Asynchronous Operations & Priority Job Engine

Release Tag: v2.1.0
Previous Tag: v2.0.0
Date: 2026-11-09
Repository: go-admin-tool
License: Apache 2.0


Executive Overview

API Executor v2.1.0 introduces a high-performance Asynchronous Action Execution and Priority Queue Subsystem (Milestones 1–5), decoupling long-running infrastructure commands, multi-domain plugin workflows, and database queries from synchronous HTTP server threads.

This release provides non-blocking job submission (POST /api/v1/jobs), priority heap queuing (High, Normal, Low), worker pool management, OS process-group cancellation, concurrency-safe circular log buffering, two-tier RBAC authorization, Prometheus telemetry, SHA-256 tamper-evident audit chaining, and an interactive Web Administration Console (Tab 9: Async Jobs & Queue) with real-time log tailing.

Every feature is backed by a comprehensive 4-Tier End-to-End (E2E) Test Suite (88/88 E2E tests passing, 464 unit/integration tests passing, 100% pass rate, zero race conditions under Go's race detector) and certified across all 11 packages exceeding the >=80% statement coverage standard.


Key Highlights & Architectural Enhancements

HTTP Client / Web Console (Tab 9)
             │
             ▼
┌───────────────────────────────────────────────┐
│              internal/api/                    │
│  POST /api/v1/jobs ──► Two-Tier RBAC Check    │
│  GET  /api/v1/jobs ──► List & Query Filters   │
│  GET  /api/v1/jobs/{id}/logs ──► Chunked Stream│
│  POST /api/v1/jobs/{id}/cancel ──► Cancel Job │
└──────────────────────┬────────────────────────┘
                       │
                       ▼
┌───────────────────────────────────────────────┐
│              internal/jobs/                   │
│                                               │
│  ┌─────────────────────────────────────────┐  │
│  │    JobQueue (container/heap Priority)   │  │
│  │  High > Normal > Low (FIFO Tie-Breaker) │  │
│  │  Capacity Bound: 1000 (ErrQueueFull)    │  │
│  └────────────────────┬────────────────────┘  │
│                       │                       │
│                       ▼                       │
│  ┌─────────────────────────────────────────┐  │
│  │    WorkerPool (Bounded Goroutines)      │  │
│  │  Consumes jobs, passes Context & Buffer │  │
│  └────────────────────┬────────────────────┘  │
│                       │                       │
│        ┌──────────────┴──────────────┐        │
│        ▼                             ▼        │
│  ┌───────────┐                 ┌───────────┐  │
│  │ Core Exec │                 │  Plugins  │  │
│  │ (Process  │                 │ (Native / │  │
│  │  Group)   │                 │ Declarat.)│  │
│  └─────┬─────┘                 └─────┬─────┘  │
│        └──────────────┬──────────────┘        │
│                       ▼                       │
│  ┌─────────────────────────────────────────┐  │
│  │    JobLogBuffer (2 MiB Max, Thread-Safe)│  │
│  │  Simultaneous Subprocess Write & Read   │  │
│  └─────────────────────────────────────────┘  │
└──────────────────────┬────────────────────────┘
                       │
                       ▼
┌───────────────────────────────────────────────┐
│              Persistence & Audit              │
│  JobStore (SQLite / In-Memory Fallback)       │
│  AuditLogger (SHA-256 Chained Hash Log)       │
│  Prometheus Metrics (Normalized Route Labels) │
└───────────────────────────────────────────────┘
  1. Non-Blocking Execution Engine (Milestone 1): Long-running system diagnostics, container operations, and database inspections run asynchronously in a managed worker pool without tying up HTTP server threads.
  2. Prioritized Workload Scheduling (Milestone 1): Three-tier heap priority queue (High, Normal, Low) ensures urgent operational tasks leapfrog normal batches while preserving strict FIFO ordering within each tier.
  3. OS Process-Group Termination (Milestone 1): Subprocess cancellations propagate down the entire OS process hierarchy (SIGKILL to process groups on Unix; taskkill /T /F on Windows), eliminating orphan background processes.
  4. Circular Streaming Log Buffers (Milestone 1): Concurrency-safe memory buffers capture stdout and stderr streams in real time up to 2 MiB per job with offset-based chunked client polling and automatic EOF signaling.
  5. Two-Tier RBAC & Scope Protection (Milestone 2): Callers must possess the specific jobs:* scope AND have authorization for the underlying command or plugin action.
  6. Prometheus Telemetry with DoS Protection (Milestone 2): Dynamic job IDs in routes are normalized to static label templates (/api/v1/jobs/:id), preventing unbounded label cardinality DoS.
  7. Tamper-Evident SHA-256 Audit Trail (Milestone 2): Complete cryptographic hash chaining for every lifecycle transition (job.enqueued, job.started, job.completed, job.failed, job.cancelled, job.timed_out).
  8. Web Administration Console Tab 9 (Milestone 3): Interactive single-page operational dashboard featuring queue telemetry cards, background dispatcher, execution table, and real-time streaming log viewer modal.
  9. 4-Tier E2E Test Suite (Milestone 4): 88 opaque-box end-to-end tests exercising feature workflows, boundary conditions, concurrency races, and real-world multi-tenant scenarios.
  10. Enterprise Governance Compliance (Milestone 5): OpenAPI 3.0 / Swagger 2.0 specifications updated, architecture documentation published, and statement coverage exceeding 80% across all 11 packages.

Detailed Breakdown by Milestone

Milestone 1: Core Asynchronous Job Engine (internal/jobs/)

  • Domain Models & Thread Safety (internal/jobs/job.go):
    • Job struct with fine-grained sync.RWMutex protection.
    • Lifecycle states: queued -> running -> completed | failed | cancelled | timed_out.
    • Immutable terminal state guarantees: once terminal, a job cannot be transitioned or modified (IsTerminal() == true).
    • Thread-safe Snapshot() returning an immutable shallow clone without copying mutexes.
    • Custom MarshalJSON() synchronization preventing data races during concurrent worker mutations.
  • Priority Heap Queue (internal/jobs/queue.go):
    • Max-heap backed by Go standard library container/heap.
    • Priority levels: High (weight 3), Normal (weight 2), Low (weight 1).
    • Monotonic queueSeq tie-breaking guaranteeing strict FIFO ordering within identical priority tiers.
    • Bounded capacity (capacity: 1000, configurable) returning ErrQueueFull when full.
    • Efficient $O(\log N)$ queue-time cancellation via Remove(jobID) and internal lookup hash map.
  • Worker Pool Management (internal/jobs/worker.go):
    • Fixed pool of worker goroutines (default: 4 workers).
    • Per-job execution context with timeout enforcement (DefaultJobTimeout = 30s).
    • Active jobs map (activeJobs map[string]context.CancelFunc) enabling immediate mid-flight cancellation.
    • Panic recovery converting unexpected runtime panics into graceful StatusFailed terminal states.
    • Graceful draining on server shutdown (Shutdown(ctx)), allowing active jobs up to the shutdown context deadline to complete.
  • Process-Tree Execution & Cancellation (internal/core/executor.go):
    • Enhanced ExecuteCommandWithContext accepting context.Context and real-time io.Writer.
    • Unix: SysProcAttr{Setpgid: true} and syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL).
    • Windows: taskkill /T /F /PID <pid> terminates child and grandchild processes.
    • cmd.WaitDelay = 200 * time.Millisecond prevents dangling pipe deadlocks on child exit.
  • Circular In-Memory Log Buffer (internal/jobs/buffer.go):
    • Thread-safe bounded memory buffer (DefaultMaxLogBytes = 2 << 20 / 2 MiB).
    • Implements io.Writer: excess output beyond 2 MiB is dropped, sets truncated = true, and returns len(p), nil to prevent broken pipe errors on child processes.
    • Chunked reading via ReadChunk(offset int) (logs string, nextOffset int, truncated bool, eof bool).
  • Dual Persistence Store (internal/jobs/store.go):
    • SQLiteJobStore: Backed by SQLite table job_history with composite indexes on status, action, actor_id, and created_at DESC.
    • MemoryJobStore: Pure-Go in-memory store using deep-cloning snapshots, providing full functionality when compiled with CGO_ENABLED=0.
    • Automatic background retention pruner running every 10 minutes, pruning terminal jobs older than MaxJobAge (7 days) or exceeding MaxRetainedJobs (10,000).

Milestone 2: REST API Endpoints, Security & Telemetry

  • 6 New REST API Endpoints (internal/api/job_handlers.go, router.go):
    • POST /api/v1/jobs: Submit asynchronous command or plugin job (returns HTTP 202 Accepted).
    • GET /api/v1/jobs: Query and list background jobs with status/type/action/actor filtering and pagination.
    • GET /api/v1/jobs/{id}: Retrieve detailed job execution metadata, timestamps, and results.
    • GET /api/v1/jobs/{id}/logs: Stream real-time chunked execution logs with byte offset tracking.
    • POST /api/v1/jobs/{id}/cancel: Abort an active queued or running job.
    • GET /api/v1/jobs/queue: Retrieve live queue depth, capacity, and active worker metrics.
  • Two-Tier RBAC Scopes (internal/auth/manager.go):
    • New scopes: jobs:submit, jobs:read, jobs:cancel.
    • Role inheritance: admin (*), operator (jobs:submit, jobs:read, jobs:cancel), viewer (jobs:read), service (jobs:submit, jobs:read).
    • Two-tier validation: Job submission requires jobs:submit scope AND commands:execute or plugins:execute for the underlying action.
    • Machine-to-machine service accounts are additionally checked against their allowed_actions allowlist.
  • Prometheus Metric Collectors (internal/api/job_metrics.go):
    ...
Read more

v2.0.0 — Zero-Trust Remote Command & MCP Platform with High-Scale Optimizations

Choose a tag to compare

@jmrenouard jmrenouard released this 08 Nov 23:05

Overview

API Executor (go-admin-tool v2.0.0) is an enterprise zero-trust administration and Model Context Protocol (MCP) platform designed for secure remote command execution, container-testable OS preset management, and high-throughput AI agent orchestration.

This release consolidates comprehensive security hardening, a 305+ plugin ecosystem across 10 operational domains, and four major performance optimizations eliminating hot-path lock contention, memory bloat, and syscall overhead.


🚀 Key Performance Optimizations

  1. O(1) Credential Authentication Indexing (PR #77, Closes #76)

    • Replaced linear O(N) credential scans under exclusive memory locks with O(1) secondary hash lookup maps (tokenByHash and serviceAccountByHash).
    • Maintains constant-time verification (crypto/subtle.ConstantTimeCompare) and synchronized lifecycle across user deletion, token revocation, and key rotation.
  2. Pre-Compiled Regexes & Sorted Plugin Catalog Caching (PR #79, Closes #78)

    • Pre-compiles all declarative parameter validation regular expressions at initialization.
    • Caches the sorted []PluginInfo catalog snapshot in Registry across 305 plugins, eliminating O(N log N) sorting overhead on catalog queries.
    • Rejects non-scalar composite parameter types and fixes character class ranges.
  3. Subprocess Output Buffer Bounding (PR #81, Closes #80)

    • Replaced unbounded cmd.CombinedOutput() with a bounded limitedOutputBuffer capped at MaxCommandOutputBytes = 1 << 20 (1 MiB).
    • Drains excess bytes safely without triggering SIGPIPE or broken pipe failures on child processes, preventing heap exhaustion (OOM) on runaway commands.
  4. Persistent File Handles, Lock Decoupling & Direct db.Exec (PR #83, Closes #82)

    • Persists open file descriptors (*os.File) in AuditLogger and mcp.Server, eliminating per-event os.OpenFile/Close syscall storms.
    • Decoupled disk and SQLite I/O from the in-memory ring-buffer lock (al.mu), ensuring non-blocking reads for audit queries and chain verification.
    • Replaced per-insert db.Prepare with direct db.Exec.

🛡️ Core Capabilities

  • Zero-Trust Security: HTTPS/TLS 1.3 by default with automatic ECDSA P-256 certificate generation, live zero-downtime certificate rotation (POST /api/v1/tls/renew), and optional mTLS client authentication.
  • Model Context Protocol (MCP): Full JSON-RPC 2.0 MCP server (POST /api/v1/mcp) implementing the Meta-Tool pattern (execute_plugin and executor://plugins/catalog) with immutable trace retention.
  • 305+ Plugins Across 10 Domains: 24 native pure-Go plugins + 281 declarative YAML plugins spanning SysAdmin, NetOps, SecOps, ContainerOps, Kubernetes, DataOps, DevOps, SRE, AIOps, and WebUtils.
  • Tamper-Evident Audit Trail: Cryptographic SHA-256 hash chaining (prev_hash -> entry_hash from GENESIS) with verifiable integrity (GET /api/v1/audit/verify).
  • OS Task Presets: Ready-to-run container-safe system inspection catalogs for Ubuntu 24.04 and RedHat UBI 9.
  • Web Administration Console: Single-page 8-tab dark console with instant client-side catalog filtering, dynamic parameter forms, and telemetry monitoring.

🧪 Verification & Test Coverage

  • 100% Test Pass Rate: 339 unit and integration tests passing across all 10 packages.
  • Zero-CGO Pure-Go Fallback: Tested and validated under both CGO-enabled SQLite and pure-Go in-memory modes.
  • Docker Hygiene: Multi-stage builds for Ubuntu and RedHat UBI9 with optimal layer caching.