Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
86 changes: 86 additions & 0 deletions aiox-sop/ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# SOP Factory Architecture

## Intent

`aiox-sop` turns operational knowledge into structured SOP artifacts for humans and AI systems. It is enterprise-aware locally, but it must remain safe when copied into a less capable repository.

## Architecture Layers

1. Orchestrator layer: `sop-chief` routes requests and enforces quality.
2. Specialist layer: analyst, creator, extractor, ML architect, auditor.
3. Workflow layer: creation, audit, and extraction pipelines.
4. Runtime contract layer: environment detection decides which context surfaces may be used.

## Environment Contract

The squad resolves a shared contract with these fields:

- `access_tier`: `opensource|pro|enterprise`
- `runtime_mode`: `portable_docs_mode|full_workspace_mode`
- `source_of_truth`: `docs_projection|workspace_canonical`
- `reason`
- `evidence_paths`

Decision rules:

- `enterprise` requires explicit proof.
- `pro` is allowed when the Pro pack exists and enterprise is not proven.
- `portable_docs_mode` remains the default when explicit business context is absent or readiness is not proven.
- `full_workspace_mode` is allowed only when explicit runtime context and canonical COO readiness are both proven.

## Optional Workspace Business Context

When `full_workspace_mode` is proven for an explicit `business`, `aiox-sop`
may load a business-aware context snapshot before analysis, extraction, or
audit work that needs real `L0-identity`/`L1-strategy` data.

Canonical business context surfaces:

- `workspace/businesses/{business}/L0-identity/company-dna.yaml`
- `workspace/businesses/{business}/L1-strategy/icp.yaml`
- `workspace/businesses/{business}/L1-strategy/offerbook.yaml` when present
- `workspace/businesses/{business}/L1-strategy/team-structure.yaml`
- `workspace/businesses/{business}/L1-strategy/pricing-strategy.yaml`
- `workspace/businesses/{business}/L1-strategy/kpi-scorecards.yaml`
- `workspace/businesses/{business}/L1-strategy/commission-design.yaml` when present
- `workspace/_templates/business-template/L1-strategy/`

Loader surface:

- `squads/aiox-sop/scripts/load-workspace-context.cjs`
- `squads/aiox-sop/tasks/load-workspace-context.md`

This context remains read-first, but the same readiness gate also unlocks the
canonical machine-readable publish surface at
`workspace/businesses/{business}/sops/`.

## Non-Sensitive Projection

Portable mode consumes:

- `docs/squad/aiox-sop/operational-projection.yaml`

This projection may describe safe outputs, mode rules, and evidence surfaces, but it must not embed private workspace topology.

## Output Zones

- `docs/sops/`: canonical shared-safe markdown SOPs and draft SOPs
- `workspace/businesses/{business}/sops/`: canonical machine-readable SOPs for an explicit business in `full_workspace_mode`
- `outputs/aiox-sop/`: auxiliary generated artifacts
- `outputs/aiox-sop/extractions/`: extraction reports, confidence maps, and review aids
- `outputs/aiox-sop/audits/`: audit reports and dashboards
- `outputs/aiox-sop/analysis/`: analysis and benchmark reports
- `outputs/aiox-sop/converted/`: conversion validation reports and non-canonical byproducts
- `outputs/aiox-sop/checklists/`: generated checklists
- `outputs/aiox-sop/certificates/`: certification artifacts
- `squads/aiox-sop/outputs/`: retained reference packages; not a canonical runtime output zone

## Current Constraint

`aiox-sop` now has canonical readiness support in the COO resolver through the `operations` context. The correct runtime behavior is:

- without explicit `business`, runtime remains `portable_docs_mode`
- with explicit `business` and ready operations namespace, runtime may become `full_workspace_mode`
- shared-safe docs projection remains the default fallback source of truth
- markdown SOP publication does not require workspace write access
- YAML/JSON SOP publication requires explicit `business` and the canonical workspace gate
27 changes: 27 additions & 0 deletions aiox-sop/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Changelog

## 2026-03-18

- Migrated markdown SOP publication to root `docs/sops/`.
- Migrated machine-readable SOP publication to `workspace/businesses/{business}/sops/` behind the existing business-aware workspace gate.
- Kept `outputs/aiox-sop/` as the auxiliary root for audits, analysis, checklists, and operational reports.
- Realigned extraction workflow ownership so `sop-extractor` owns raw capture, decomposition, and role mapping, while `sop-chief` coordinates structure formation.
- Converted `convert-sop-format` to a worker-first hybrid contract and documented the deterministic CLI runner.
- Classified `squads/aiox-sop/outputs/` as retained reference packages instead of canonical runtime output surfaces.
- Recorded the `*optimize-yolo aiox-sop` execution evidence under `squads/aiox-sop/docs/`.
- Added optional workspace business-context loading via `load-workspace-context` for business-aware analysis in `full_workspace_mode`.

## 2026-03-10

- Registered `aiox-sop` in COO workspace readiness with canonical `operations` context.
- Upgraded `workspace_integration.level` from `none` to `controlled_runtime_consumer`.
- Enabled `full_workspace_mode` when explicit business context and COO readiness are both proven.
- Updated runtime and architecture docs to describe canonical operations readiness.
- Updated tests that previously assumed `aiox-sop` was unsupported by the COO.
- Added enterprise-aware `environment_contract` detection for `aiox-sop`.
- Aligned enterprise proof with the canonical marker `workspace/license/enterprise-runtime.capability.yaml`.
- Added structural squad docs: `README.md`, `ARCHITECTURE.md`, and `CHANGELOG.md`.
- Added maintenance tasks for update and delete flows.
- Added portable operational projection under `docs/squad/aiox-sop/`.
- Corrected output path drift between extraction/audit tasks and workflows.
- Corrected `HEADLINE.md` identity for SOP Factory.
3 changes: 3 additions & 0 deletions aiox-sop/HEADLINE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SOP FACTORY -- HEADLINE v1

Eu vou transformar os processos da sua operacao em SOPs de classe mundial -- para humanos e para IAs -- usando Deming, Gawande, Toyota e ISO 9001, com contrato portavel por padrao e sem assumir acesso privilegiado ao seu workspace interno.
77 changes: 77 additions & 0 deletions aiox-sop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# SOP Factory

Enterprise-aware SOP creation and audit squad that remains portable when shared.

## Operating Contract

- Shared default is fail-closed. The squad must not assume `enterprise` just because `workspace/`, `c-level`, or `pro` exist.
- The runtime source of truth is resolved by `scripts/resolve-environment-contract.cjs`.
- When canonical readiness is not proven, the squad stays in `portable_docs_mode` and uses `docs/squad/aiox-sop/operational-projection.yaml`.
- When an explicit `--business=<slug>` is provided and the COO resolves `operations` readiness, the squad may enter `full_workspace_mode`.
- Human-readable SOPs and draft markdown SOPs publish under `docs/sops/`.
- Machine-readable SOPs publish under `workspace/businesses/{business}/sops/` when `business` is explicit and `full_workspace_mode` is proven.
- Auxiliary reports remain under `outputs/aiox-sop/`.
- `squads/aiox-sop/outputs/` stores retained reference packages only; it is not the canonical publish root for new runtime artifacts.

## Optional Business Context

`aiox-sop` can preload canonical business context when the user wants the
analysis to be grounded in the real company and operations data for a specific
business.

Run:

```bash
node squads/aiox-sop/scripts/load-workspace-context.cjs --business=aiox --format=yaml
```

For full parsed payload:

```bash
node squads/aiox-sop/scripts/load-workspace-context.cjs --business=aiox --include-raw --format=json
```

Business-aware context is optional and only valid when:

- `--business=<slug>` is explicit
- the `COO` resolves `operations` readiness as `ready`
- the environment contract switches to `full_workspace_mode`

The loader pulls canonical sources from:

- `workspace/businesses/{slug}/L0-identity/`
- `workspace/businesses/{slug}/L1-strategy/`
- `workspace/businesses/{slug}/L2-tactical/brand/`
- `workspace/_templates/business-template/L1-strategy/`

## Core Surfaces

- `config.yaml`: squad manifest and distribution contract
- `agents/`: orchestrator and specialists
- `tasks/`: creation, extraction, audit, and maintenance tasks
- `workflows/`: end-to-end SOP pipelines
- `docs/`: root shared documentation surface; `docs/sops/` is the publish root for markdown SOPs
- `outputs/`: retained in-repo reference packages kept for historical/support context
- `../docs/squad/aiox-sop/operational-projection.yaml`: non-sensitive portable projection
- `scripts/load-workspace-context.cjs`: optional business-context loader for full workspace mode

## Runtime Modes

- `portable_docs_mode`: default. Use docs projection, root `docs/sops/`, and auxiliary shared-safe outputs only.
- `full_workspace_mode`: only allowed after explicit business context plus canonical `operations` readiness from the COO, enabling canonical `workspace/businesses/{business}/sops/` publication.

## Environment Detection

Run:

```bash
node squads/aiox-sop/scripts/resolve-environment-contract.cjs --format=yaml
```

To check workspace-backed readiness for a real business:

```bash
node squads/aiox-sop/scripts/resolve-environment-contract.cjs --business=aiox --format=yaml
```

`enterprise` is only proven by the canonical marker `workspace/license/enterprise-runtime.capability.yaml`. Without that proof, the access tier stays fail-closed.
Loading