Research and earlier design
Last changed 2026-05-22. This page records research, planning, or an earlier architecture and may not describe the current product. For current behaviour, start at Start here.
Company OS Continual Harness implementation plan
This is the implementation roadmap for bringing HSM-II Company OS closer to Continual Harness (paper PDF) while preserving the Company OS safety contract: observe first, write artifacts, review deltas, re-test, then promote.
1. Current state
Company OS now has the first safe slice:
meta_harness.py / evaluate_turn.py
-> results.json + results/*.ndjson
-> company_os_refiner_pass.py
-> refiner/company_os_turns.jsonl
-> refiner/company_os_harness_delta_<n>.jsonImplemented files:
scripts/meta-harness/evaluate_turn.py— live Next +hsm_consoleturn observation and scoring.scripts/meta-harness/meta_harness.py— candidate evaluation and frontier logging.scripts/meta-harness/company_os_refiner_pass.py— normalizes live agent-chat observations and emits review-only deltas.scripts/meta-harness/test_company_os_refiner_pass.py— tests the trace-to-delta path.scripts/meta-harness/harness_delta_filled.py— shared validation for filled deltas and applier.scripts/meta-harness/test_company_os_llm_refiner.py/test_company_os_delta_apply.py— M1/M2 smoke tests.scripts/meta-harness/company_os_llm_refiner.py— filled delta generation (mock or OpenRouter).scripts/meta-harness/company_os_delta_apply.py— versionedhsm.company_os_harness_policy.v1JSON.scripts/meta-harness/company_os_promote_delta.py— promotion dry-run gate.
This gives Company OS observe -> artifact -> detect -> structured candidate. An LLM Refiner (company_os_llm_refiner.py) and policy applier (company_os_delta_apply.py + optional HSM_COMPANY_OS_HARNESS_POLICY_PATH) are in-tree; operators still gate activation and re-test. It does not yet run task-local online overlays (M4) or model training (M5).
2. Target architecture
Map the paper's H = (p, G, K, M) to Company OS surfaces:
| Paper component | Company OS target | Apply mode |
|---|---|---|
p prompt | web/company-console/app/lib/agent-chat-prompt-policy.mjs, worker companion prompt, operator ethos copy | Feature-flagged patch or policy JSON |
G sub-agents | company_agents, persona/agent templates, task spawn policy | Postgres row changes or reviewed bundle import |
K skills/tools | capability_refs, skill detector rules, tool allowlists, skills catalog | Reviewed JSON patch + task-scoped allowlist |
M memory | company_memory_entries, llm-context retrieval policy, broadcast/shared/agent scopes | Memory rows + retrieval config |
trajectory τ | company_os_turns.jsonl, NDJSON stream logs, agent runs, governance events | Append-only artifacts |
delta Δ | company_os_harness_delta_<n>.json | Review-only until promoted |
The invariant: no refiner output becomes runtime behavior until it has a provenance path, a bounded target, a re-test, and a rollback.
3. Milestones
M1 — LLM Refiner that fills deltas
Goal: turn deterministic placeholder deltas into concrete but still review-only proposals.
Implementation:
scripts/meta-harness/company_os_llm_refiner.py— mock-by-default; OpenRouter whenOPENROUTER_API_KEYis set.- Input:
company_os_turns.jsonl,company_os_harness_delta_<n>.json, relevant code/doc excerpts. - Output:
company_os_harness_delta_<n>.filled.json. - Use a strict JSON schema with these top-level sections:
prompt_policy_patchskill_dispatch_patchruntime_guard_patchmemory_policy_patchsub_agent_patchrisk_notesverification_plan
- Require
apply_policy: review_only. - Reject any patch that targets a file/path/API outside the allowlist.
Verification:
python3 scripts/meta-harness/test_company_os_refiner_pass.py
python3 scripts/meta-harness/test_company_os_llm_refiner.py
PYTHONPYCACHEPREFIX=/private/tmp/hsm-refiner-pyc python3 -m py_compile scripts/meta-harness/*.pyAcceptance:
- Given a weak-turn artifact, the LLM Refiner produces valid JSON.
- Invalid target paths are rejected.
- Missing verification plan fails validation.
M2 — Approval-gated applier
Goal: safely map reviewed deltas into runtime behavior behind flags.
Implementation:
scripts/meta-harness/company_os_delta_apply.py— versioned policy JSON + optional--activate.- Supported apply targets only:
- policy JSON under a new
config/company_os_harness/directory, - generated review patch files under candidate directories,
- optional Postgres memory/task suggestions exported as JSON, not directly written by default.
- policy JSON under a new
- Do not edit TypeScript/Rust source directly in the first applier.
- Add
HSM_COMPANY_OS_HARNESS_POLICY_PATHconsumed by agent-chat server code after review. - Add rollback by preserving prior policy JSON and candidate metadata.
Verification:
python3 scripts/meta-harness/test_company_os_delta_apply.py
npm --prefix web/company-console run test -- --runInBand
npm --prefix docs-site run buildAcceptance:
- Applying a valid policy delta creates a versioned policy file.
- Reverting restores the previous policy.
- Agent-chat reads the policy only when explicitly configured.
M3 — Re-test and promotion loop
Goal: close the safe loop: delta -> apply candidate policy -> re-run meta-harness -> promote if improved.
Implementation:
scripts/meta-harness/company_os_promote_delta.py—--dry-runmetrics gate (full promote TBD).- Promotion requires:
- source candidate ID,
- filled delta,
- applied policy path,
- before/after metrics,
- no regression on
finalize_rate, - explicit operator approval or
--approved-by.
- Write promotion record to candidate dir and optionally Company OS governance event when API credentials are present.
Verification:
bash scripts/company-os-agent-chat-meta-harness-smoke.sh
python3 scripts/meta-harness/company_os_promote_delta.py --dry-run ...
python3 scripts/meta-harness/test_company_os_promote_and_m5.pyAcceptance:
- Promotion refuses deltas without after-metrics.
- Promotion refuses lower
finalize_rateunless--allow-regressionis explicit.
M4 — Online in-run refinement
Goal: approximate the paper's H <- H ⊕ Δ during long agent-chat/operator sessions, still with gates.
Implementation:
POST /api/company/tasks/{task_id}/harness-overlay— apply{ "apply": { "text": "..." } }or clear{ "clear": true }; logged togovernance_events.scripts/meta-harness/company_os_task_overlay.py— operator CLI wrapping the same API.src/company_os/agents.rs—llm-contextrenders Task-local harness overlay (reversible) separately from stigmergic handoff notes.Keep refinements task-scoped first.
Allow runtime to load a task-local policy overlay between turns, not mid-token.
Record overlay IDs in task
context_notesand run metadata.Expose active overlay in
llm-context.
Safety:
- Only reversible overlays.
- No source-file mutation.
- Human approval required for shared/company-wide overlays.
Acceptance:
- A long-running task can adopt a task-local overlay after a weak turn.
- The overlay appears in
llm-context. - Removing the overlay restores baseline behavior.
CLI (shipped): scripts/meta-harness/company_os_overlay_from_delta.py applies a validated *.filled.json to POST .../harness-overlay. Meta-harness: --apply-overlay-task-id <uuid> (or HSM_COMPANY_OS_OVERLAY_TASK_ID).
M5 — PRM / teacher relabel / SFT lane
Goal: separate training lane for model co-learning, not part of live production control.
Implementation:
schemas/company_os_rollout_shard.v1.json— shard contract.scripts/meta-harness/company_os_training_export.py— JSONL turns → shard files underruns/company_os_training/.scripts/meta-harness/company_os_prm_score.py— heuristic PRM scores per window row.scripts/meta-harness/company_os_training_dry_run.py— token/label stats without training.Define rollout shard schema under
schemas/company_os_rollout_shard.v1.json.Export
company_os_turns.jsonlwindows into teacher-label jobs.Add PRM scoring interface:
- start with heuristic/process scores from
evaluate_turn.py, - later allow frontier teacher labels.
- start with heuristic/process scores from
Store training data under
runs/company_os_training/.Add a dry-run trainer command before real SFT:
- validates data,
- computes label distributions,
- estimates token/compute cost.
Acceptance:
- Can export shards without training.
- Can score/relabel shards without touching production.
- Any SFT adapter requires a held-out Company OS meta-harness eval before use.
4. Safety gates
Every stage must preserve these gates:
- Allowlist gate: refiner/applier can only target known policy surfaces.
- Schema gate: all deltas validate before apply.
- Review gate: runtime changes are not automatic.
- Re-test gate: candidate policy must be evaluated after apply.
- Rollback gate: every promoted policy has a previous version.
- Ledger gate: promotions are recorded in artifacts and, when online, Company OS governance events.
5. Near-term implementation order
- Implement
company_os_llm_refiner.pywith schema validation and tests. - Add policy file target under
config/company_os_harness/. - Implement
company_os_delta_apply.pyin dry-run/versioned-policy mode. - Teach agent-chat to optionally read
HSM_COMPANY_OS_HARNESS_POLICY_PATH. - Add promotion command and smoke workflow.
- Only then consider task-local online overlays.