feat(corporate): add dormant manual source runtime and independent QA adapter

This commit is contained in:
Canina Automation committed 2026-10-28 12:48:29 +00:00
1 parent cc365bcda2
commit d80845af0d
10 files changed
+567

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
# Manual Hermes terminal adapter (dormant)
Python 3.9+ stdlib; no install or runtime configuration. Run explicitly from Hermes's terminal tool or an operator terminal:
```
python3 scripts/corporate_runtime.py --store /private/corporate-artifacts status
python3 scripts/corporate_runtime.py --store /private/corporate-artifacts --key research-unique ingest research.json --hosts hermes-agent.nousresearch.com
python3 scripts/corporate_runtime.py --store /private/corporate-artifacts --key research-unique replay-ingest REQUEST_DIGEST
python3 scripts/corporate_runtime.py --store /private/corporate-artifacts --key roadmap-unique roadmap roadmap.json
python3 scripts/corporate_runtime.py --store /private/corporate-artifacts --key fanout-unique fanout ROADMAP_UUID
python3 scripts/corporate_runtime.py --store /private/corporate-artifacts --key execution-unique execute --department CONTENT_SEO
python3 scripts/corporate_runtime.py --store /private/corporate-artifacts --key unused-required replay-evidence CHECKPOINT_DIGEST
python3 scripts/corporate_runtime.py --store /private/corporate-artifacts --key review-unique qa TASK_UUID EVIDENCE_UUID
python3 scripts/corporate_runtime.py --store /private/corporate-artifacts --key effect-unique effect TASK_UUID effect.json
python3 scripts/corporate_runtime.py --store /private/corporate-artifacts --key report-unique report report.json
```
Credentials must already be provisioned securely in environment: CORPORATE_API_KEY for execution/operator; CORPORATE_QA_API_KEY for QA under a distinct authenticated subject. Do not paste secrets into chat, command arguments, manifests or source. QA command reads only QA env. Backend rejects self-review. Private store (directory 0700/files 0600) includes lease-bearing replay checkpoint; transfer only source/artifact bytes required by a reviewer securely. Avoid shared writable or symlinked stores. No credentials are stored in the artifact store.
Default API http://127.0.0.1:3000/api/admin/hermes. An authorized stage endpoint requires both `--api https://STAGE/api/admin/hermes` and explicit `--allow-stage-https`; this is not a production-target detector or authorization to use production. No gateway/config/cron/plugin modifications. Do not schedule this adapter. No automatic retries.
Research JSON: API market-insights fields except sources, replaced by fetchSources `[ {"url":"https://...","title":"..."} ]`; provenance and interpretation are attributed operator text, not automatically validated scientific claims. Hash/excerpt/retrievedAt are obtained from actual fetched bytes. Source text is untrusted inert data. Only public allowlisted HTTPS hosts, pinned IP/TLS hostname verification, no redirect/proxy, port443, 2MB cap, bounded timeouts. Downloaded excerpt may be raw HTML/index text; adapter does not invent research conclusions. Keep source set small (API 1..30).
Roadmap JSON follows API contract, must set isActive:false; goals should target source_inventory_v1 research acceptance. Fanout creates one deterministic goal-linked RESEARCH task per goal, description exactly `{"operation":"source_inventory_v1","researchId":"UUID"}`. No other operation, prompt execution or arbitrary commands supported. Dedicated department/queue recommended: claim API cannot filter actionType/goal, so unsupported claimed task is rejected locally and remains leased until 300s expiry; adapter never marks it successful. Never re-use a claim operation key for a new execution attempt.
Retain mutation keys. On ingest network uncertainty, replay exact saved request via emitted request digest with original key (do not refetch/re-ingest with same key: retrieval timestamp changes). On evidence uncertainty replay emitted checkpoint; it carries original claim/evidence key, bytes and timing, so no fabricated new receipt. Re-running execute with same claim key after submission is NOT recovery; use replay-evidence. Roadmap/effect/report require unchanged manifests for retry. Fanout uses stable goal keys, safely resumes partial fanout. API conflict fails closed.
QA reopens exact original source bytes and content-addressed artifact, recomputes inventory using persisted API provenance, then posts verification for exact evidence ID/digest/URI. Does not prove clinical validity, network source immutability or independent human review. Tampered/missing bytes fail without QA submission; backend permits manual explicit rejection via contract, adapter has no automatic rejection command. Effects follow API availability semantics; do not use zero as unavailable. Report summary is attributed operator text; snapshot is server-built from persisted records.
See scripts/corporate_pilot.py for executable manifest examples and disposable test-auth Nest host. Pilot requires local private backend node_modules with ts-node/Prisma generated from current schema, migrated corporate_test on loopback :55441, and CORPORATE_PILOT_DIR under scratch; it spawns/stops its own feature host on :55442, never the full production app. Run once per empty disposable DB (daily report day is unique). Unit checks: `python3 scripts/corporate_runtime_test.py`. No cron or Hermes CLI installed/configured by these scripts.
@@ -0,0 +1,30 @@
{
"persistedReadback": {
"taskId": "618a6800-d241-41e2-b093-969164c83cfa",
"status": "DONE",
"logs": [
"CREATED",
"CLAIMED",
"EVIDENCE_SUBMITTED",
"QA_PASSED",
"EFFECT_RECORDED"
],
"effects": [
{
"id": "3c460ee4-9fb5-45e9-845f-f00abde2a796",
"taskId": "618a6800-d241-41e2-b093-969164c83cfa",
"metric": "production_engagement",
"availability": "UNINSTRUMENTED",
"baseline": null,
"observed": null,
"source": "Local pilot has no production analytics instrumentation",
"observedAt": "2026-10-28T12:21:29.732Z",
"recordedBy": "apikey:pilot-executor",
"createdAt": "2026-10-28T12:21:30.966Z"
}
],
"sha256": "cd8527d3e9b2812e15b60af0a80bba3255a52d739ec431dab1b6fa296e74d2b2",
"independentSubjects": true,
"selfReviewDenied": true
}
}
+4
View File
@@ -0,0 +1,4 @@
# Plan
Use Python stdlib explicit subcommands as a manual Hermes terminal adapter, not a model subprocess or background agent. API contract specs/corporate-backend/api.md; existing JwtAuthGuard/RolesGuard remain unchanged. Content-addressed private store outside repo. Default API loopback only; stage HTTPS requires explicit opt-in; source host allowlist plus public IP pinning, no proxy/redirect, bounded fetch. All mutations require caller operation key; fanout derives stable per-goal keys. QA requires its own env credential; backend enforces different authenticated subject. Deterministic source-inventory operation only; task description is structured untrusted data, never a command/prompt.
Graphify query at base returned unrelated preexisting graph (4304 nodes); graph binding unknown, navigation only. Direct controller/service/policy and integration test inspected as authoritative. No frontend/backend edits. Record graph SHA256 in verification. Existing spec baseline not copied/overwritten; scoped artifacts authored explicitly, specify 1.2.3 checked. Hermes CLI absent on PATH: document adapter invocation, do not claim native tool registration.
+6
View File
@@ -0,0 +1,6 @@
# Manual corporate runtime
Base cc365bcda265c7b86bd495d8428f85eea2b72081. Dormant opt-in CLI, never scheduler/config/restart/publish/deploy.
An authenticated operator ingests real public HTTPS bytes with SHA256 and retrieval time, creates a research-backed roadmap and retry-safe goal task fanout, manually claims one read-only RESEARCH task and produces an immutable local artifact and actual tool receipt. A separate authenticated reviewer reopens exact artifact and source bytes, verifies against persisted research and submits independent QA. Effects must distinguish unavailable from measured zero; reports use persisted state.
Acceptance: unsafe URLs/commands/unknown operations and changed artifacts fail closed; secrets only env and never output; stable idempotency keys; real Nest HTTP + disposable PostgreSQL pilot using actually fetched source; no production data or automation claims. Authentication pilot boundaries explicit.
+5
View File
@@ -0,0 +1,5 @@
# Tasks
- [x] RED unit safety/operation/digest contract
- [x] Implement explicit manual API/source/artifact adapter
- [x] GREEN unit tests and real fetched-source PostgreSQL/Nest pilot
- [x] Document commands, boundaries, verification and commit (no push)
+10
View File
@@ -0,0 +1,10 @@
# Verification
Base cc365bcda265c7b86bd495d8428f85eea2b72081; isolated branch corporate-runtime. Only scripts/corporate* and specs/corporate-runtime committed. No push, deployment, cron/config edits, Hermes restart or production mutation.
- RED: python3 scripts/corporate_runtime_test.py failed FileNotFoundError before adapter implementation.
- GREEN: same command PASS 6 tests (URL/API restrictions, unknown operation rejection, tamper detection, exact deterministic inventory and immutable evidence checkpoint replay). Replay test added after implementation, not claimed RED-first. Python py_compile and git diff --check also PASS. These unit checks do not prove network behavior.
- Real manual pilot PASS: CORPORATE_PILOT_DIR=/opt/data/cache/scratch/corporate-runtime-pilot-final python3 scripts/corporate_pilot.py. Actually fetched https://hermes-agent.nousresearch.com/docs/llms.txt via pinned public HTTPS/TLS, no proxy or redirect. Real PostgreSQL port 55441 database corporate_test initialized under scratch; schema applied using Prisma db push, private generated Prisma client. Real Nest controller/service/shared guards over loopback port 55442 (global /api prefix), not a fake receiver. Test API-key validator accepts two ephemeral random credentials, mapped to separate authenticated subjects; not production credential validation or full AdminModule boot.
- Actual CLI subprocesses: dormant status, ingest + immutable idempotent replay, inactive roadmap, goal task fanout + idempotent repeat, claim/read-only artifact/evidence, independent QA, explicit UNINSTRUMENTED effect, daily snapshot. Executor self-QA rejected HTTP 409. API detail readback DONE with persisted events/evidence/review/effect; receipt in pilot-receipt.json. Full scratch transcript contains source digest, actual retrieval timestamps, raw fetched excerpt, request digest and tool timestamps; private store retains source/artifact/checkpoint bytes. Not fabricated market/clinical research or measured production impact.
- Graphify existing graph SHA256 6a73473cee9e207543fdeeb668bea544f766200a1b16b8a3a9ce18d4e42e51af; binding to base unknown and query irrelevant to new backend. Verified direct controller/service/policy/tests instead. Query cache stamp restored before commit. specify 1.2.3 checked; scoped SDD authored without replacing project config.
- Hermes executable absent from PATH (`hermes chat --help` exit 127). This is an executable manual terminal adapter suitable for a Hermes terminal tool invocation, not a registered native Hermes plugin/tool, model execution or proof of autonomous runtime. CLI reference loaded; no unsupported Hermes commands invented.
- No full backend/frontend regression/build, production auth, stage acceptance, scheduler, native Hermes tool registration, publishing or deployment claimed. PostgreSQL stopped after verification; data retained only in isolated scratch cluster. Unsupported claimed tasks remain leased until expiry (no backend release route). No source redirection or refresh-based QA: QA validates retained original bytes against original persisted provenance, not current network content. QA credentials prove separate subjects, not independent people.