Skip to content

CTC System Rebuild Dependency Graph


1. Purpose

A future rebuild must preserve authority and dependency order. The goal is not to reproduce the current PHP include graph.

Legacy source
= adapter evidence

Rebuild dependency graph
= intended authority order

The graph answers:

  • what must exist before a capability can read data;
  • what must exist before it can write;
  • what must exist before an external effect can run;
  • what must exist before a deployment is healthy;
  • what must exist before a migration cohort can cut over;
  • what must be restored before traffic, schedulers and providers resume.

2. Top-Level Authority Graph

flowchart TB
    PRODUCT[Product Target / Operating Profiles]
    DEPLOY[Deployment Identity / Environment / Config Release]
    TENANT[Tenant Mapping / Profile / Module / Capability / Config]
    IDENTITY[Identity / Session / Actor / Subject]
    ACCESS[Page / API / Action / Record / State Access]
    PROCESS[Process / State / Handoff / Recovery]
    DATA[Authoritative Data / Identity / Fields / Repository]
    APP[Application Query / Command / Transaction]
    AUDIT[Audit / Correlation / Evidence]
    EFFECT[Provider / File / Device / Worker Effect]
    UI[React / Next.js UI and Adapters]
    KNOW[Runbook / Wiki / Support]
    READY[Readiness / Canary / Observation]
    RECOVERY[Backup / Restore / DR / Failback]
    MIG[One Writer / Rollback / Caller-Zero]

    PRODUCT --> DEPLOY
    PRODUCT --> TENANT
    DEPLOY --> TENANT
    TENANT --> IDENTITY
    IDENTITY --> ACCESS
    TENANT --> ACCESS
    ACCESS --> PROCESS
    PROCESS --> DATA
    DATA --> APP
    PROCESS --> APP
    APP --> AUDIT
    APP --> EFFECT
    AUDIT --> EFFECT
    APP --> UI
    ACCESS --> UI
    PROCESS --> UI
    UI --> KNOW
    AUDIT --> KNOW
    EFFECT --> KNOW
    DEPLOY --> READY
    APP --> READY
    EFFECT --> READY
    KNOW --> READY
    DATA --> RECOVERY
    EFFECT --> RECOVERY
    DEPLOY --> RECOVERY
    READY --> MIG
    RECOVERY --> MIG

2.1 Direction rule

A lower layer may consume an upper-layer decision. It must not manufacture it.

UI may consume AccessDecision.
UI does not define authorization.

Worker may consume EffectIntent.
Worker does not decide business retry policy.

Repository may enforce conditional state predicates.
Repository does not define Product workflow.

Deployment readiness may report Process canary result.
Deployment does not define Process completion.

3. Platform Foundation Dependency Graph

flowchart LR
    D[Deployment / Environment]
    T[Tenant / Profile / Module / Capability / Config]
    I[Identity / Session / Impersonation]
    A[Authorization]
    U[Audit / Correlation / Support Evidence]
    E[Integration / Worker / Provider]
    B[Backup / Restore / DR]

    D --> T
    D --> I
    T --> A
    I --> A
    A --> U
    T --> E
    I --> E
    A --> E
    U --> E
    D --> E
    D --> B
    T --> B
    I --> B
    U --> B
    E --> B

3.1 Minimum platform read dependency

A read-only tenant-scoped query requires:

runtime deployment identity
+ tenant context
+ authenticated actor/subject where required
+ module/capability/page/API decision
+ tenant-scoped repository query
+ safe result/readback

3.2 Minimum platform write dependency

A consequential command additionally requires:

semantic action permission
+ record tenant and state predicate
+ command request identity
+ transaction/conditional write
+ exact result reread
+ audit/correlation reference
+ recovery classification

3.3 Minimum external effect dependency

local business command result
+ approved EffectIntent
+ credential owner/reference
+ provider-specific idempotency/retry policy
+ Attempt identity
+ callback/reconciliation behavior
+ unknown-result manual recovery
+ deployment/worker readiness

4. Current Business Value-Stream Dependencies

4.1 CTC execution

flowchart LR
    APPT[Appointment / Request]
    PLAN[Inbound Planning]
    ASSIGN[Assignment Queue]
    LOADER[Loader Start / Complete]
    REVIEW[Final Loading Review]
    ADJ[Bale Source / Leftover Adjustment]
    INV[Inventory Lot / Placement]
    YARD[Yard Queue / Move]
    DRIVER[Driver Delivery]
    BILL[Billing / Documents / Providers]

    APPT --> PLAN
    PLAN --> ASSIGN
    ASSIGN --> LOADER
    LOADER --> REVIEW
    REVIEW --> ADJ
    REVIEW --> INV
    ADJ --> INV
    LOADER --> YARD
    INV --> YARD
    YARD --> DRIVER
    DRIVER --> BILL
    REVIEW --> BILL

Required non-implications:

Appointment accepted != planned/assigned
Assignment created != Loader started
Loader complete != Final Review confirmed
Final Review confirmed != inventory adjusted
Inventory ready != Yard move complete
Yard complete != Driver complete
Local billing != QBO/File/Email complete

4.2 MK order-first

flowchart LR
    COMM[Commercial Agreement]
    INB[Inbound Purchase]
    SCALE[Physical Scale]
    LOT[Inventory Lot]
    OUT[Outbound Sales Demand]
    ALLOC[Inventory Allocation]
    BOOK[Booking]
    EXEC[Packing / Scale / Delivery]
    TRADE[Trade / Cost / Rate / Documents]

    COMM --> INB
    COMM --> OUT
    INB --> SCALE
    SCALE --> INB
    INB --> LOT
    LOT --> ALLOC
    OUT --> ALLOC
    OUT --> BOOK
    BOOK --> EXEC
    ALLOC --> EXEC
    COMM --> TRADE
    INB --> TRADE
    OUT --> TRADE
    BOOK --> TRADE
    EXEC --> TRADE

Required non-implications:

Commercial status != execution completion
Scale checkout != receipt finalized
Lot exists != available/allocated
Outbound saved != allocated
Booking saved != child synchronization complete
Document rendered != durable effect
Trade label != accounting close

5. Business Capability Platform Requirements

Capability Tenant/Profile Identity/Access Audit/Evidence Integration/Effect Deployment/Recovery
Appointment email intake tenant/mailbox binding reviewer/action access message/request/process correlation Gmail watch/callback/reply callback/scheduler readiness, mailbox recovery
Planning/Loader tenant/profile/config office/loader own-record planner/staff transition Telegram/QBT optional web/API readiness, staff data recovery
Assign Work/Clock Out tenant/profile/queue policy manager + Loader self assignment/staff events Telegram/QBT current adapter verification and rollback
Final Review tenant/profile/WMS reviewer action + record state review transition + ledger refs normally local DB/schema/readiness/canary
Bale Adjustment tenant/profile/WMS adjustment/reversal action immutable ledger/reversal normally local DB/file backup and restore
Yard/Driver/Street Turn tenant/profile/YMS/TMS office/yard/driver record scope queue/move/delivery/equipment evidence notification optional physical/system reconciliation and restore
Billing/QBO/File/Email tenant/provider/config accounting/operation actions local/provider/file/mail evidence QBO/Gmail/File provider callback/credential/file recovery
MK Core Orders/Booking mk-order profile commercial/receiving/shipping order/receipt/bridge evidence document/provider optional DB/schema/file readiness
Allocation mk-order profile inventory/shipping action allocation/ledger/reversal local concurrent balance and restore
Physical Scale mk-order profile Scale/operator action ticket/event/device evidence device optional device/service and DB recovery
Trade/Cost/Rate/Documents mk-order profile accounting/document action source projection/correction file/email optional source freshness and output recovery

6. Query Dependency Pattern

sequenceDiagram
    participant UI as React/Current UI
    participant WEB as Next.js/PHP Adapter
    participant ID as Identity/Tenant/Access
    participant APP as Query Application
    participant REPO as Repository
    participant DB as MySQL

    UI->>WEB: query request
    WEB->>ID: resolve actor, tenant, capability, record scope
    ID-->>WEB: AccessDecision
    alt denied/unavailable/unknown
        WEB-->>UI: safe decision and reason
    else allowed
        WEB->>APP: typed query + context
        APP->>REPO: tenant-scoped query contract
        REPO->>DB: read
        DB-->>REPO: rows + freshness
        REPO-->>APP: authoritative/derived result
        APP-->>WEB: typed DTO + warnings
        WEB-->>UI: data + request/release identity
    end

A read query must not mutate for cleanup, expiry or reconciliation unless it is explicitly an owner command.


7. Command Dependency Pattern

sequenceDiagram
    participant UI as React/Current UI
    participant WEB as Next.js/PHP Adapter
    participant ACCESS as Access/Record Policy
    participant APP as Application Command
    participant REPO as Repository
    participant DB as MySQL
    participant AUD as Transition Audit
    participant EFF as Optional Effect Owner

    UI->>WEB: command + requestToken + expectedVersion
    WEB->>ACCESS: actor/tenant/action/record/state
    ACCESS-->>WEB: decision
    WEB->>APP: typed command
    APP->>REPO: validate current state
    REPO->>DB: conditional transaction
    DB-->>REPO: affected rows/result
    REPO->>AUD: append transition/evidence in owner boundary
    REPO-->>APP: exact readback
    APP-->>WEB: business result + effect disposition
    WEB-->>UI: committed/denied/conflict/partial/unknown
    opt approved external effect
        APP->>EFF: provider-scoped intent
    end

Required one-writer rule:

one business request/cohort
-> one authoritative command writer

8. Provider/Worker Dependency Pattern

flowchart LR
    CMD[Committed Business Command]
    INTENT[Provider-Scoped Effect Intent]
    ATTEMPT[Effect Attempt / Lease]
    PROVIDER[External Provider]
    CALLBACK[Callback Receipt]
    RECON[Reconciliation]
    LOCAL[Local Result Reference]
    SUPPORT[Support Timeline]

    CMD --> INTENT
    INTENT --> ATTEMPT
    ATTEMPT --> PROVIDER
    PROVIDER --> CALLBACK
    PROVIDER --> RECON
    CALLBACK --> RECON
    RECON --> LOCAL
    INTENT --> SUPPORT
    ATTEMPT --> SUPPORT
    CALLBACK --> SUPPORT
    LOCAL --> SUPPORT
Generic worker runtime
!= generic business outbox

Each effect family owns its payload, idempotency, retry and compensation.


9. UI Dependency Pattern

9.1 React responsibility

  • current context and state presentation;
  • typed form input;
  • loading/empty/denied/conflict/partial/unknown/success states;
  • accessible/mobile interaction;
  • authoritative reread after command;
  • next-process handoff;
  • safe recovery actions.

9.2 React non-responsibility

  • tenant or role policy;
  • business transition eligibility;
  • SQL/repository behavior;
  • provider retry policy;
  • audit meaning;
  • source-of-truth state;
  • backup/restore decision.

9.3 Next.js responsibility

  • route/rendering boundary;
  • session/tenant adapter;
  • validated transport;
  • safe error mapping;
  • no-store operational reads where required;
  • request/correlation propagation.

9.4 Next.js non-responsibility

  • core domain/process policy;
  • transaction ownership;
  • direct provider replay;
  • generic mutation authority.

10. Deployment Dependency Graph

flowchart TB
    SRC[Source Release]
    CFG[Config Release]
    SCH[Schema Release]
    MAN[Deployment Manifest]
    WEB[PHP / Next.js Web]
    API[PHP / Next.js API]
    WORK[Approved Worker]
    GATE[Voice Gateway]
    DB[(Runtime DB)]
    FILE[(Object/File Storage)]
    PROV[Providers]
    OBS[Logs/Metrics/Traces]
    CAN[Business Canary]
    BAK[Backup Set]

    SRC --> MAN
    CFG --> MAN
    SCH --> MAN
    MAN --> WEB
    MAN --> API
    MAN --> WORK
    MAN --> GATE
    WEB --> DB
    API --> DB
    WORK --> DB
    WEB --> FILE
    API --> FILE
    WORK --> PROV
    GATE --> PROV
    WEB --> OBS
    API --> OBS
    WORK --> OBS
    GATE --> OBS
    DB --> BAK
    FILE --> BAK
    CFG --> BAK
    MAN --> BAK
    WEB --> CAN
    API --> CAN
    WORK --> CAN
remote master
-> deployed source
-> service live
-> service ready
-> business canary
-> field accepted
-> stabilized

Each arrow requires independent evidence.


11. Restore Dependency Graph

flowchart TB
    SET[Verified Backup Set]
    ISO[Isolated Recovery Target]
    DBR[Database Restore]
    AR[Archive Reconcile]
    FR[File/Object Restore]
    CFGR[Config/Credential Recovery]
    SR[Compatible Source/Schema]
    PR[Provider/Callback Reconcile]
    RR[Restricted Readiness]
    RC[Read-Only Canary]
    WC[Transactional Canary]
    EN[Schedulers/Workers/Providers Enable]
    TRAFFIC[Traffic Cutover]
    OBS[Observation / RPO / RTO]

    SET --> ISO
    ISO --> DBR
    DBR --> AR
    AR --> FR
    FR --> CFGR
    CFGR --> SR
    SR --> PR
    PR --> RR
    RR --> RC
    RC --> WC
    WC --> EN
    EN --> TRAFFIC
    TRAFFIC --> OBS

Do not enable callbacks/schedulers/provider sends immediately after DB restore.


12. Migration Dependency Graph

flowchart LR
    CUR[Current PHP Capability]
    PACK[Accepted M4 Packet]
    READ[TypeScript Read Shadow]
    UI[React + Next.js Read-Only]
    CMD[Target Command Shadow/Parity]
    CUT[One-Writer Cohort Cutover]
    OBS[Role/Field Observation]
    ROLL[Rollback/Fail-Forward]
    ZERO[PHP Caller-Zero]
    STAB[React + Next.js + MySQL Stabilized]
    PG[PostgreSQL Later]

    CUR --> PACK
    PACK --> READ
    READ --> UI
    UI --> CMD
    CMD --> CUT
    CUT --> OBS
    OBS --> ZERO
    CUT --> ROLL
    ZERO --> STAB
    STAB --> PG

A detailed M1/M2 packet cannot skip the accepted M4 gate.


13. Bootstrap Layer Dependencies

Layer Requires Produces Blocks if missing
Product/Profile user-approved outcome profile/process applicability all later design
Deployment identity source/config/schema/deployment refs trusted runtime context safe support/release
Tenant/config portable mapping and applied state effective tenant/profile/capability tenant-scoped reads/writes
Identity/access session/actor/subject and policy command/record authorization consequential action
Data/schema authoritative entities/constraints repository contracts all business state
Process/application accepted states/commands deterministic behavior UI/automation/migration
Audit/evidence request/process IDs and references support/reconciliation unknown-result safety
Integration/worker approved effect contract provider result/recovery external effects
UI/knowledge accepted query/command semantics operator workflow field acceptance
Deployment/recovery manifest/readiness/backup safe release/restore cutover/stabilization

14. Prohibited Cycles

UI decides business state
-> prohibited

Provider callback bypasses tenant/access/application owner
-> prohibited

Worker creates business commands without owning Process policy
-> prohibited

Deployment health modifies business records
-> prohibited

Wiki procedure becomes source of truth for state
-> prohibited

Archive eligibility becomes backup policy
-> prohibited

Customer ID selects application architecture
-> prohibited

15. Current Dependency Gaps

  • explicit Runtime operating-profile assignment;
  • semantic action/record matrix;
  • current Loader adapter reconciliation;
  • current Street Turn compensation packet;
  • current Final Review read DTO/average policy;
  • accepted Scale flow policy;
  • provider search/reconciliation for QBO/Gmail unknown results;
  • complete deployment/service inventory;
  • complete backup set and isolated restore;
  • accepted RPO/RTO;
  • current Wiki content and target-role review;
  • no accepted M4 capability.

These are tracked in REBUILD_READINESS_GAP_REGISTER.md.


16. Maintenance

Update this graph when:

  • a Process owner changes;
  • a source delta changes state/data/interface/effect authority;
  • a provider or worker is introduced/retired;
  • React/Next.js migration activates;
  • deployment or recovery topology changes;
  • a capability reaches M3/M4/M5;
  • current Wiki/operator entry changes.

---

Source: docs/reconstruction/SYSTEM_REBUILD_DEPENDENCY_GRAPH.md — ctc repository · This page is an English translation of the source document. Identifiers, file paths and code symbols are unchanged.