Skip to main content

Multi-Tenant Command Scope Audit Report

Task: H.12.1 - Audit All Commands for Project/Team/Tenant Gaps Date: 2026-02-08 Author: Claude (Opus 4.6) Data Source: gap-matrix.json (366 commands classified)


Executive Summary

Audited 366 commands across the CODITECT framework. 25 commands (6.8%) have scope gaps requiring enhancement for proper multi-tenant operation. All gaps are at the project level (no tenant-level gaps identified beyond the 2 commands already tenant-scoped).

Key Finding: The framework is already well-architected for single-project use (76.2% project-scoped). The gaps are concentrated in commands that touch shared databases or perform git operations without explicit project routing.


Scope Distribution

Scope LevelCountPercentage
Global5214.2%
Machine133.6%
Session205.5%
Project27976.2%
Tenant20.5%
Total366100%

Scope Hierarchy

Tenant (2)          License management
Project (279) Most commands - project-scoped by design
Machine (13) Installation, config, env management
Session (20) Context, handoff, session lifecycle
Global (52) Stateless utilities, analyzers

Gap Analysis: 25 Commands Requiring Enhancement

Gap Categories

CategoryCountDescription
DB-touching without --project8Query/write to shared DBs without project filter
Git operations without project routing12Git push/pull/sync without project-specific remote
Log operations without project scoping5Log output/search without project boundaries

Priority Ranking (H.12.1.5)

Tier 1: High Impact, Low Effort (Quick Wins)

These commands touch shared databases and need a simple --project filter parameter.

#CommandGapImpactEffortFix
1session-statusDB query unscopedHighLowAdd WHERE project_id = ? filter
2session-conflictsDB query unscopedHighLowAdd project filter to conflict detection
3summariesDB query unscopedHighLowScope summary queries by project
4trajectoryDB query unscopedHighLowAdd project filter to trajectory data

Estimated Total Effort: 2-3 hours Multi-Tenant Risk: Data leakage between projects in shared database queries

Tier 2: High Impact, Medium Effort

These commands perform significant operations that cross project boundaries.

#CommandGapImpactEffortFix
5sync-logsGit push to single repoHighMediumProject-specific repo routing (H.12.2)
6db-backupBacks up all project dataHighMediumAdd --project flag for scoped backup
7commitNo project-specific hooksHighMediumProject-aware commit routing
8git-syncSingle remote assumptionHighMediumMulti-remote project routing
9session-log-codexLogs unscopedHighLowAdd project path scoping

Estimated Total Effort: 6-8 hours Multi-Tenant Risk: Customer data mixed in shared repos, backups crossing project boundaries

Tier 3: Medium Impact, Low-Medium Effort

These commands would benefit from project awareness but don't pose immediate data isolation risks.

#CommandGapImpactEffortFix
10biDB query unscopedMediumLowAdd project filter
11component-activateDB write unscopedMediumLowAdd project context to activation
12pluginDB operations unscopedMediumLowScope plugin registry by project
13search-scriptsResults unscopedMediumLowFilter results by project
14quality-gateGit checks unscopedMediumMediumProject-aware gate checks
15weekly-digestData aggregation unscopedMediumMediumScope digest to project
16updateGit operations unscopedMediumMediumProject-aware update routing
17update-planGit operations unscopedMediumMediumProject-scoped plan updates
18project-plan-updateGit operations unscopedMediumMediumProject-scoped plan updates

Estimated Total Effort: 6-8 hours

Tier 4: Low Impact, Low Effort

These commands have minor scope gaps with low multi-tenant risk.

#CommandGapImpactEffortFix
19markdown-cleanupFile operations unscopedLowLowPath-based project scoping
20pilotLog output unscopedLowLowAlready project-specific in nature
21aliasGit operationsLowLowMinor git scoping
22audit-trailGit operationsLowLowProject-scoped trail
23component-lifecycleGit operationsLowMediumProject-aware lifecycle
24lowercase-migrationFile operationsLowLowPath-based scoping
25submodule-initGit operationsLowMediumProject-scoped submodule config

Estimated Total Effort: 3-4 hours


Implementation Roadmap

Phase 1: Database Query Isolation (Tier 1) - Week 1

  • Add --project parameter to session-status, session-conflicts, summaries, trajectory
  • Pattern: Use discover_project() from scripts/core/paths.py as default
  • All DB queries get WHERE project_id = ? clause

Phase 2: Git Operation Routing (Tier 2) - Week 2-3

  • Implement config/session-log-repos.json for repo routing (H.12.2)
  • Add project-aware remote detection to git-sync, commit, sync-logs
  • Create db-backup --project flag

Phase 3: Secondary Enhancements (Tier 3) - Week 3-4

  • Add project context to component-activate, plugin, bi
  • Scope quality-gate, weekly-digest, update operations
  • Pattern: Inherit from ADR-159 multi-tenant command architecture

Phase 4: Cleanup (Tier 4) - Opportunistic

  • Address low-impact gaps during related feature work
  • No dedicated sprint needed

Commands Already Well-Scoped (No Action Needed)

341 of 366 commands (93.2%) require no changes:

  • 279 project-scoped: Already operate within project boundaries
  • 52 global: Stateless utilities (explain, translate, uuid, etc.)
  • 13 machine-scoped: Installation/config (onboard, verify-installation, etc.)
  • 20 session-scoped: Context/session lifecycle (cx, continue, handoff, etc.)
  • 2 tenant-scoped: License management (license-activate, license-status)

Minus the 25 identified gaps.


Risk Assessment

RiskSeverityMitigation
Data leakage via DB queriesHighTier 1 fixes (add project filters)
Customer code in shared reposHighTier 2 fixes (project repo routing)
Mixed backup dataMediumdb-backup --project flag
Incorrect analyticsMediumScope bi, summaries, trajectory
Noisy log outputLowTier 3/4 scoping

Recommendations

  1. Immediate (P1): Fix Tier 1 database query isolation - 4 commands, ~2 hours
  2. Short-term (P2): Implement H.12.2 (sync-logs routing) and H.12.3 (ADR-159) to establish the architectural pattern
  3. Medium-term (P2): Apply ADR-159 pattern to Tier 2-3 commands
  4. Ongoing: Address Tier 4 opportunistically during related feature work
  5. Standard: All new commands MUST declare scope level in frontmatter and follow ADR-159

Data Files

FileDescription
gap-matrix.jsonFull classification data (366 commands, 25 gaps)
COMMAND-SCOPE-AUDIT.mdThis report

Total Estimated Effort: 17-23 hours across all tiers Critical Path: Tier 1 (2-3 hrs) + ADR-159 (3-4 hrs) = 5-7 hours for core multi-tenant safety