Skip to content

Commit d8dc45a

Browse files
authored
Merge pull request #9 from chittyos/session-20251010-172233
ChittyOS Compliance: Service Deployments & File Organization
2 parents 6ec177a + cfae4df commit d8dc45a

126 files changed

Lines changed: 42541 additions & 6582 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"id": "cf8ba8440633367875ecb50de694692a",
3+
"name": "project-sync-mg4fzg9n",
4+
"pid": 11885,
5+
"hostname": "chitty.local",
6+
"startTime": 1759108840476,
7+
"lastHeartbeat": 1759181387976,
8+
"status": "active",
9+
"metadata": {
10+
"model": "claude",
11+
"type": "project-sync"
12+
},
13+
"tasks": [],
14+
"locks": [],
15+
"lastUpdate": 1759181387978
16+
}

.chittyos/project.id

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHITTY-PROJECT-1759558292-536c4cec
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: ChittyOS Compliance CI
2+
3+
on:
4+
pull_request:
5+
branches: [main, develop]
6+
paths:
7+
- '**/*session*.js'
8+
- '**/*session*.ts'
9+
- 'cross-session-sync/**'
10+
- 'src/session-persistence/**'
11+
push:
12+
branches: [main, develop]
13+
paths:
14+
- '**/*session*.js'
15+
- '**/*session*.ts'
16+
17+
jobs:
18+
chittyid-compliance:
19+
name: ChittyID Session Compliance
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 10
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: '18'
33+
cache: 'npm'
34+
35+
- name: Install dependencies
36+
run: npm ci
37+
38+
- name: Verify ChittyID Client installed
39+
run: |
40+
if ! npm list @chittyos/chittyid-client > /dev/null 2>&1; then
41+
echo "❌ ERROR: @chittyos/chittyid-client not installed"
42+
echo "Required for ChittyOS compliance"
43+
exit 1
44+
fi
45+
echo "✅ ChittyID Client package verified"
46+
47+
- name: Check for rogue session ID patterns
48+
run: |
49+
echo "🔍 Scanning for UUID/crypto session ID generation patterns..."
50+
51+
VIOLATIONS=0
52+
53+
# Pattern 1: crypto.randomBytes in session files
54+
if grep -rn "crypto\.randomBytes" src/ cross-session-sync/ | grep -i "session" | grep -v node_modules; then
55+
echo "❌ Found crypto.randomBytes() in session code"
56+
VIOLATIONS=$((VIOLATIONS + 1))
57+
fi
58+
59+
# Pattern 2: uuid imports in session files
60+
if find src/ cross-session-sync/ -name "*session*.js" -o -name "*session*.ts" | xargs grep -l "import.*uuid\|require.*uuid" 2>/dev/null; then
61+
echo "❌ Found uuid imports in session files"
62+
VIOLATIONS=$((VIOLATIONS + 1))
63+
fi
64+
65+
# Pattern 3: Missing ChittyID client imports
66+
SESSION_FILES=$(find src/ cross-session-sync/ -name "*session*.js" -o -name "*session*.ts" 2>/dev/null || true)
67+
for file in $SESSION_FILES; do
68+
if grep -q "generateSessionId" "$file"; then
69+
if ! grep -q "@chittyos/chittyid-client" "$file"; then
70+
echo "❌ $file has generateSessionId but no @chittyos/chittyid-client"
71+
VIOLATIONS=$((VIOLATIONS + 1))
72+
fi
73+
fi
74+
done
75+
76+
if [ $VIOLATIONS -gt 0 ]; then
77+
echo ""
78+
echo "════════════════════════════════════════"
79+
echo " ❌ ChittyID Compliance Check Failed"
80+
echo "════════════════════════════════════════"
81+
echo "Found $VIOLATIONS policy violations"
82+
echo ""
83+
echo "Session IDs MUST be minted from id.chitty.cc"
84+
echo "Use @chittyos/chittyid-client package"
85+
echo ""
86+
echo "See: chittycheck-session-rules.sh for details"
87+
exit 1
88+
fi
89+
90+
echo "✅ No rogue session ID generation patterns detected"
91+
92+
- name: Validate CHITTY_ID_TOKEN usage
93+
run: |
94+
echo "🔍 Checking CHITTY_ID_TOKEN validation in session code..."
95+
96+
SESSION_FILES=$(find src/ cross-session-sync/ -name "*session*.js" -o -name "*session*.ts" 2>/dev/null || true)
97+
MISSING_VALIDATION=0
98+
99+
for file in $SESSION_FILES; do
100+
if grep -q "generateSessionId" "$file"; then
101+
if ! grep -A 20 "generateSessionId" "$file" | grep -q "CHITTY_ID_TOKEN"; then
102+
echo "⚠️ WARNING: $file should validate CHITTY_ID_TOKEN"
103+
MISSING_VALIDATION=$((MISSING_VALIDATION + 1))
104+
fi
105+
fi
106+
done
107+
108+
if [ $MISSING_VALIDATION -gt 0 ]; then
109+
echo "⚠️ $MISSING_VALIDATION files missing CHITTY_ID_TOKEN validation"
110+
echo "Recommendation: Add token validation before ChittyID minting"
111+
else
112+
echo "✅ CHITTY_ID_TOKEN validation present"
113+
fi
114+
115+
- name: Run ChittyCheck Session Rules
116+
run: |
117+
if [ -f "chittycheck-session-rules.sh" ]; then
118+
chmod +x chittycheck-session-rules.sh
119+
./chittycheck-session-rules.sh || true
120+
else
121+
echo "⚠️ chittycheck-session-rules.sh not found, skipping"
122+
fi
123+
124+
- name: Check session file format in todos
125+
run: |
126+
# This would typically run on the actual machine, not CI
127+
# For CI, we just document the requirement
128+
echo "📋 Session File Format Requirements:"
129+
echo " - All session IDs must use CTXT_ prefix (ChittyID format)"
130+
echo " - UUID-based session files must be migrated"
131+
echo " - Run: scripts/migrate-legacy-session-ids.sh on target system"
132+
133+
- name: Generate Compliance Report
134+
if: always()
135+
run: |
136+
echo "════════════════════════════════════════"
137+
echo " ChittyOS Compliance CI Report"
138+
echo "════════════════════════════════════════"
139+
echo "Branch: ${{ github.ref_name }}"
140+
echo "Commit: ${{ github.sha }}"
141+
echo "Workflow: ${{ github.workflow }}"
142+
echo ""
143+
echo "Validation Status: ${{ job.status }}"
144+
echo "════════════════════════════════════════"
145+
146+
dependency-audit:
147+
name: Audit ChittyID Dependencies
148+
runs-on: ubuntu-latest
149+
150+
steps:
151+
- name: Checkout code
152+
uses: actions/checkout@v4
153+
154+
- name: Setup Node.js
155+
uses: actions/setup-node@v4
156+
with:
157+
node-version: '18'
158+
159+
- name: Verify @chittyos/chittyid-client version
160+
run: |
161+
echo "🔍 Checking @chittyos/chittyid-client package..."
162+
163+
if [ -f "package.json" ]; then
164+
VERSION=$(jq -r '.dependencies."@chittyos/chittyid-client" // empty' package.json)
165+
166+
if [ -z "$VERSION" ]; then
167+
echo "❌ @chittyos/chittyid-client not in dependencies"
168+
echo "Add with: npm install @chittyos/chittyid-client"
169+
exit 1
170+
fi
171+
172+
echo "✅ @chittyos/chittyid-client: $VERSION"
173+
fi
174+
175+
- name: Security audit
176+
run: |
177+
npm audit --audit-level=high || true
178+
echo "✅ Security audit completed"

.github/workflows/ecosystem-cicd.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,19 @@ jobs:
118118
echo "Running ChittyID compliance validation..."
119119
./chittycheck-enhanced.sh --ci-mode
120120
121-
# Ensure no local ID generation
122-
if grep -r "CHITTY-.*-.*-.*" . --exclude-dir=node_modules --exclude="*.json" --exclude="*.md"; then
123-
echo "❌ Found hardcoded ChittyIDs - all IDs must come from id.chitty.cc"
121+
# Ensure no local ID generation (exclude submodules and build artifacts)
122+
if grep -r "CHITTY-.*-.*-.*" . \
123+
--exclude-dir=node_modules \
124+
--exclude-dir=.git \
125+
--exclude-dir=chittychronicle \
126+
--exclude-dir=chittychain \
127+
--exclude-dir=chittyforce \
128+
--exclude-dir=nevershitty-github \
129+
--exclude-dir=dist \
130+
--exclude-dir=build \
131+
--exclude="*.json" \
132+
--exclude="*.md"; then
133+
echo "❌ Found hardcoded ChittyIDs in source code - all IDs must come from id.chitty.cc"
124134
exit 1
125135
fi
126136

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ build/
99
coverage/
1010
.vscode/
1111
.idea/
12+
.chittycheck/

.husky/pre-commit

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/usr/bin/env bash
2+
# ChittyOS Pre-Commit Hook
3+
# Prevents commits with rogue session ID generation patterns
4+
5+
set -e
6+
7+
RED='\033[0;31m'
8+
YELLOW='\033[1;33m'
9+
GREEN='\033[0;32m'
10+
NC='\033[0m'
11+
12+
echo "🔍 ChittyOS Pre-Commit Validation..."
13+
14+
# Get list of staged files
15+
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)
16+
17+
# Check for session-related files
18+
SESSION_FILES=$(echo "$STAGED_FILES" | grep -E "session.*\.(js|ts)$" || true)
19+
20+
if [[ -z "$SESSION_FILES" ]]; then
21+
echo -e "${GREEN}✅ No session files modified${NC}"
22+
exit 0
23+
fi
24+
25+
echo -e "${YELLOW}⚠️ Session files detected, running ChittyID validation...${NC}"
26+
27+
VIOLATIONS=0
28+
29+
# Pattern 1: crypto.randomBytes in session files
30+
for file in $SESSION_FILES; do
31+
if git diff --cached "$file" | grep -E "^\+.*crypto\.randomBytes.*session|^\+.*generateSessionId.*crypto\.randomBytes" > /dev/null; then
32+
echo -e "${RED}❌ BLOCKED: crypto.randomBytes() usage in session file: $file${NC}"
33+
echo -e "${RED} Session IDs must come from id.chitty.cc via @chittyos/chittyid-client${NC}"
34+
((VIOLATIONS++))
35+
fi
36+
done
37+
38+
# Pattern 2: uuid/nanoid imports in session files
39+
for file in $SESSION_FILES; do
40+
if git diff --cached "$file" | grep -E "^\+.*import.*['\"]uuid['\"]|^\+.*require.*['\"]uuid['\"]|^\+.*import.*['\"]nanoid['\"]" > /dev/null; then
41+
echo -e "${RED}❌ BLOCKED: uuid/nanoid import in session file: $file${NC}"
42+
echo -e "${RED} Use @chittyos/chittyid-client instead${NC}"
43+
((VIOLATIONS++))
44+
fi
45+
done
46+
47+
# Pattern 3: Direct session ID string generation
48+
for file in $SESSION_FILES; do
49+
if git diff --cached "$file" | grep -E "^\+.*['\"]session-.*Date\.now|^\+.*session_.*Date\.now" | grep -v "CTXT_" > /dev/null; then
50+
echo -e "${RED}❌ BLOCKED: Direct session ID generation in: $file${NC}"
51+
echo -e "${RED} Session IDs must be minted from id.chitty.cc${NC}"
52+
((VIOLATIONS++))
53+
fi
54+
done
55+
56+
# Pattern 4: Missing ChittyID client import
57+
for file in $SESSION_FILES; do
58+
if git show ":$file" 2>/dev/null | grep -q "generateSessionId"; then
59+
if ! git show ":$file" 2>/dev/null | grep -q "@chittyos/chittyid-client"; then
60+
echo -e "${YELLOW}⚠️ WARNING: $file has generateSessionId but no @chittyos/chittyid-client import${NC}"
61+
# Don't block, just warn
62+
fi
63+
fi
64+
done
65+
66+
# Check CHITTY_ID_TOKEN validation in generateSessionId functions
67+
for file in $SESSION_FILES; do
68+
if git diff --cached "$file" | grep -E "^\+.*async generateSessionId|^\+.*generateSessionId.*async" > /dev/null; then
69+
# Check if the function validates CHITTY_ID_TOKEN
70+
if ! git show ":$file" | grep -A 10 "generateSessionId" | grep -q "CHITTY_ID_TOKEN"; then
71+
echo -e "${YELLOW}⚠️ WARNING: generateSessionId in $file should validate CHITTY_ID_TOKEN${NC}"
72+
fi
73+
fi
74+
done
75+
76+
if [[ $VIOLATIONS -gt 0 ]]; then
77+
echo ""
78+
echo -e "${RED}════════════════════════════════════════${NC}"
79+
echo -e "${RED} COMMIT BLOCKED - ChittyID Violations${NC}"
80+
echo -e "${RED}════════════════════════════════════════${NC}"
81+
echo -e "${RED}Found $VIOLATIONS ChittyID policy violations${NC}"
82+
echo ""
83+
echo -e "${YELLOW}Required actions:${NC}"
84+
echo "1. Replace crypto.randomBytes() with @chittyos/chittyid-client"
85+
echo "2. Remove uuid/nanoid dependencies for session IDs"
86+
echo "3. Import ChittyIDClient and call mint() method"
87+
echo ""
88+
echo -e "${YELLOW}Example correct implementation:${NC}"
89+
echo ""
90+
echo " import ChittyIDClient from '@chittyos/chittyid-client';"
91+
echo ""
92+
echo " async generateSessionId() {"
93+
echo " if (!process.env.CHITTY_ID_TOKEN) {"
94+
echo " throw new Error('CHITTY_ID_TOKEN required');"
95+
echo " }"
96+
echo " const client = new ChittyIDClient({"
97+
echo " apiKey: process.env.CHITTY_ID_TOKEN"
98+
echo " });"
99+
echo " return await client.mint({"
100+
echo " entity: 'CONTEXT',"
101+
echo " name: 'Session',"
102+
echo " metadata: { type: 'session' }"
103+
echo " });"
104+
echo " }"
105+
echo ""
106+
echo -e "${YELLOW}To bypass this check (NOT RECOMMENDED):${NC}"
107+
echo " git commit --no-verify"
108+
echo ""
109+
exit 1
110+
fi
111+
112+
echo -e "${GREEN}✅ ChittyID validation passed${NC}"
113+
exit 0

0 commit comments

Comments
 (0)