Skip to content

Commit 3122a04

Browse files
committed
Temporal Trust Rule Implementation: Enhanced all agile automation scripts to use SystemTimeAuthority for reliable date/timestamp handling, created TemporalComplianceEnforcer, and updated all artifacts with actual system date (2025-09-05) per temporal trust rule
1 parent 866c400 commit 3122a04

12 files changed

+869
-15
lines changed

docs/agile/epics/epic-4-integrated-system-intelligence.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,5 @@ Unifying two critical system capabilities:
308308
**Epic Status**: 🔄 **ONGOING** (Integrated Intelligence + Metabolic System)
309309
**Next Phase**: Intelligence foundation + metabolic foundation development
310310
**Team**: Cognitive Intelligence + System Health Development Team
311-
**Integration**: Complete cognitive and metabolic system unification for optimal agent intelligence
311+
**Integration**: Complete cognitive and metabolic system unification for optimal agent intelligence
312+
**Last Updated**: 2025-09-05

docs/agile/epics/epic-9-integrated-system-intelligence.md

Lines changed: 311 additions & 0 deletions
Large diffs are not rendered by default.

docs/agile/user_stories/US-006-001_refactor_universal_composition_app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
**So that** the codebase becomes maintainable, testable, and allows multiple developers to work on different features simultaneously
77

88
## 🎯 **Epic Link**
9-
Epic: E-006 - Codebase Architecture Excellence
9+
Epic: EPIC-0 - Development Excellence
1010

1111
## 📊 **Story Points**: 13 (Large - Architectural Refactoring)
1212

docs/agile/user_stories/US-007-001_comprehensive_agent_ontological_logging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
**So that** I can understand agent cognition, debug decision-making processes, optimize agent performance, and gain deep insights into the agent perception-action cycle
77

88
## 🎯 **Epic Link**
9-
Epic: E-007 - Agent Intelligence & Observability
9+
Epic: EPIC-4 - Integrated System Intelligence & Organic Metabolic Architecture
1010

1111
## 📊 **Story Points**: 21 (Extra Large - Complex AI System Integration)
1212

docs/agile/user_stories/US-022-prompt-database-reorganization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# User Story US-022: Prompt Database Reorganization and Cleanup
22

33
**Story ID**: US-022
4-
**Epic**: Epic 2 - Agent Development & Integration
4+
**Epic**: EPIC-2 - Intelligent Prompt Engineering
55
**Sprint**: Sprint 2
66
**Priority**: HIGH
77
**Story Points**: 8

docs/agile/user_stories/US-AUTO-001-full-cursor-automation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# US-AUTO-001: Full Cursor Automation with Workflow Composition
22

3-
**Priority**: CRITICAL | **Story Points**: 21 | **Sprint**: Next | **Status**: 📋 **PLANNED**
3+
**Epic**: EPIC-6 - Full Cursor Automation | **Priority**: CRITICAL | **Story Points**: 21 | **Sprint**: Next | **Status**: 📋 **PLANNED**
44

55
## User Story
66
- **As a** developer working on complex software projects
Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
#!/usr/bin/env python3
2+
"""
3+
User Story Epic Assignment Script
4+
Systematically assigns all user stories to appropriate epics based on content analysis.
5+
6+
Created: 2025-09-05
7+
Last Updated: 2025-09-05
8+
Temporal Authority: Local Machine (Always Trusted)
9+
"""
10+
11+
import os
12+
import re
13+
import json
14+
from pathlib import Path
15+
from typing import Dict, List, Tuple
16+
from datetime import datetime
17+
18+
class UserStoryEpicAssigner:
19+
"""Systematically assign user stories to epics based on content analysis."""
20+
21+
def __init__(self):
22+
self.epic_mappings = {
23+
# EPIC-0: Development Excellence (Foundation)
24+
"EPIC-0": {
25+
"keywords": ["test", "testing", "quality", "code quality", "refactor", "architecture",
26+
"clean code", "technical debt", "foundation", "infrastructure", "build",
27+
"deployment", "CI/CD", "automation pipeline", "development excellence"],
28+
"patterns": [r"US-000", r"test.*fail", r"refactor", r"architecture", r"clean.*code",
29+
r"technical.*debt", r"build.*system", r"deployment", r"infrastructure"]
30+
},
31+
32+
# EPIC-2: Intelligent Prompt Engineering
33+
"EPIC-2": {
34+
"keywords": ["prompt", "engineering", "optimization", "template", "LLM", "model",
35+
"AI interaction", "prompt database", "prompt management", "prompt optimization"],
36+
"patterns": [r"prompt", r"template", r"LLM", r"model.*optimization", r"AI.*interaction"]
37+
},
38+
39+
# EPIC-3: Agent Development & Optimization
40+
"EPIC-3": {
41+
"keywords": ["agent", "swarm", "agent framework", "agent development", "AI agent",
42+
"multi-agent", "agent coordination", "agent architecture", "agent system"],
43+
"patterns": [r"agent(?!.*logging)", r"swarm", r"multi.*agent", r"agent.*framework",
44+
r"agent.*development", r"agent.*coordination"]
45+
},
46+
47+
# EPIC-4: Integrated System Intelligence & Organic Metabolic Architecture
48+
"EPIC-4": {
49+
"keywords": ["intelligence", "cognitive", "learning", "ontological", "reasoning",
50+
"knowledge", "context", "decision making", "pattern recognition",
51+
"self-optimization", "metabolic", "health monitoring", "system vitality",
52+
"agent logging", "agent ontological", "cognitive architecture"],
53+
"patterns": [r"intelligence", r"cognitive", r"learning", r"ontological", r"reasoning",
54+
r"knowledge", r"context.*detection", r"decision.*making", r"pattern.*recognition",
55+
r"self.*optimization", r"health.*monitoring", r"agent.*logging", r"metabolic"]
56+
},
57+
58+
# EPIC-6: Full Cursor Automation
59+
"EPIC-6": {
60+
"keywords": ["cursor", "automation", "workflow", "IDE", "editor", "development tools",
61+
"full automation", "workflow composition", "context switching"],
62+
"patterns": [r"cursor", r"automation", r"workflow", r"IDE", r"editor",
63+
r"development.*tools", r"workflow.*composition"]
64+
},
65+
66+
# EPIC-7: Formal Principles Excellence
67+
"EPIC-7": {
68+
"keywords": ["formal", "principles", "mathematical", "logical", "systematic",
69+
"verification", "validation", "consistency", "formal methods"],
70+
"patterns": [r"formal", r"principles", r"mathematical", r"logical", r"systematic",
71+
r"verification", r"validation", r"consistency", r"formal.*methods"]
72+
},
73+
74+
# EPIC-8: Developer Delight & Maximum Usefulness
75+
"EPIC-8": {
76+
"keywords": ["user experience", "UX", "UI", "interface", "usability", "developer experience",
77+
"user interface", "dashboard", "visualization", "delight", "usefulness"],
78+
"patterns": [r"user.*experience", r"UX", r"UI", r"interface", r"usability",
79+
r"developer.*experience", r"dashboard", r"visualization", r"delight"]
80+
}
81+
}
82+
83+
self.assignment_results = []
84+
self.project_root = Path("C:/Users/pogawal/WorkFolder/Documents/Python/ai-dev-agent")
85+
86+
def analyze_user_story_content(self, file_path: Path) -> Tuple[str, str]:
87+
"""Analyze user story content to determine best epic assignment."""
88+
try:
89+
with open(file_path, 'r', encoding='utf-8') as f:
90+
content = f.read().lower()
91+
92+
# Score each epic based on keyword and pattern matches
93+
epic_scores = {}
94+
95+
for epic_id, criteria in self.epic_mappings.items():
96+
score = 0
97+
matches = []
98+
99+
# Check keywords
100+
for keyword in criteria["keywords"]:
101+
if keyword.lower() in content:
102+
score += 1
103+
matches.append(f"keyword: {keyword}")
104+
105+
# Check patterns
106+
for pattern in criteria["patterns"]:
107+
if re.search(pattern, content, re.IGNORECASE):
108+
score += 2 # Patterns worth more than keywords
109+
matches.append(f"pattern: {pattern}")
110+
111+
epic_scores[epic_id] = {
112+
"score": score,
113+
"matches": matches
114+
}
115+
116+
# Find best match
117+
best_epic = max(epic_scores.keys(), key=lambda x: epic_scores[x]["score"])
118+
best_score = epic_scores[best_epic]["score"]
119+
120+
# If no clear match, assign to EPIC-0 (Development Excellence) as default
121+
if best_score == 0:
122+
best_epic = "EPIC-0"
123+
reasoning = "Default assignment (no specific epic indicators found)"
124+
else:
125+
reasoning = f"Score: {best_score}, Matches: {epic_scores[best_epic]['matches'][:3]}"
126+
127+
return best_epic, reasoning
128+
129+
except Exception as e:
130+
return "EPIC-0", f"Error reading file: {e}"
131+
132+
def find_all_user_stories(self) -> List[Path]:
133+
"""Find all user story files in the project."""
134+
user_story_files = []
135+
136+
# Search in docs/agile directory
137+
agile_dir = self.project_root / "docs" / "agile"
138+
if agile_dir.exists():
139+
for file_path in agile_dir.rglob("US-*.md"):
140+
if file_path.is_file() and not file_path.name.endswith('.backup_20250901_090524') and not file_path.name.endswith('.backup_20250901_090525'):
141+
user_story_files.append(file_path)
142+
143+
return sorted(user_story_files)
144+
145+
def update_user_story_epic_assignment(self, file_path: Path, epic_id: str) -> bool:
146+
"""Update a user story file with the assigned epic."""
147+
try:
148+
with open(file_path, 'r', encoding='utf-8') as f:
149+
content = f.read()
150+
151+
epic_name_map = {
152+
"EPIC-0": "Development Excellence",
153+
"EPIC-2": "Intelligent Prompt Engineering",
154+
"EPIC-3": "Agent Development & Optimization",
155+
"EPIC-4": "Integrated System Intelligence & Organic Metabolic Architecture",
156+
"EPIC-6": "Full Cursor Automation",
157+
"EPIC-7": "Formal Principles Excellence",
158+
"EPIC-8": "Developer Delight & Maximum Usefulness"
159+
}
160+
161+
epic_line = f"**Epic**: {epic_id} - {epic_name_map.get(epic_id, 'Unknown Epic')}"
162+
163+
# Look for existing epic assignment and update it
164+
lines = content.split('\n')
165+
updated_lines = []
166+
epic_found = False
167+
168+
for line in lines:
169+
if re.match(r'\*\*Epic\*\*:', line) or re.match(r'Epic:', line):
170+
updated_lines.append(epic_line)
171+
epic_found = True
172+
elif '## 🎯 **Epic Link**' in line:
173+
updated_lines.append(line)
174+
# Add epic line after Epic Link header if not found elsewhere
175+
if not epic_found:
176+
updated_lines.append(epic_line)
177+
epic_found = True
178+
else:
179+
updated_lines.append(line)
180+
181+
# If no epic assignment found, add it after the title
182+
if not epic_found:
183+
new_lines = []
184+
title_found = False
185+
for i, line in enumerate(updated_lines):
186+
new_lines.append(line)
187+
if line.startswith('# ') and not title_found:
188+
title_found = True
189+
# Add epic line after title and separator
190+
new_lines.append('')
191+
new_lines.append(epic_line)
192+
new_lines.append('')
193+
updated_lines = new_lines
194+
195+
# Write updated content
196+
with open(file_path, 'w', encoding='utf-8') as f:
197+
f.write('\n'.join(updated_lines))
198+
199+
return True
200+
201+
except Exception as e:
202+
print(f"Error updating {file_path}: {e}")
203+
return False
204+
205+
def assign_all_user_stories(self) -> Dict:
206+
"""Assign all user stories to appropriate epics."""
207+
user_story_files = self.find_all_user_stories()
208+
209+
print(f"Found {len(user_story_files)} user story files to process...")
210+
211+
results = {
212+
"total_files": len(user_story_files),
213+
"successful_assignments": 0,
214+
"failed_assignments": 0,
215+
"assignments_by_epic": {},
216+
"assignment_details": []
217+
}
218+
219+
for file_path in user_story_files:
220+
try:
221+
# Analyze content and determine epic
222+
assigned_epic, reasoning = self.analyze_user_story_content(file_path)
223+
224+
# Update the file
225+
success = self.update_user_story_epic_assignment(file_path, assigned_epic)
226+
227+
if success:
228+
results["successful_assignments"] += 1
229+
if assigned_epic not in results["assignments_by_epic"]:
230+
results["assignments_by_epic"][assigned_epic] = []
231+
results["assignments_by_epic"][assigned_epic].append(file_path.name)
232+
else:
233+
results["failed_assignments"] += 1
234+
235+
# Track details
236+
results["assignment_details"].append({
237+
"file": str(file_path.relative_to(self.project_root)),
238+
"assigned_epic": assigned_epic,
239+
"reasoning": reasoning,
240+
"success": success
241+
})
242+
243+
print(f"✅ {file_path.name}{assigned_epic}")
244+
245+
except Exception as e:
246+
results["failed_assignments"] += 1
247+
print(f"❌ Error processing {file_path.name}: {e}")
248+
249+
return results
250+
251+
def main():
252+
"""Main function to run the epic assignment process."""
253+
print("🎯 Starting User Story Epic Assignment Process...")
254+
print("=" * 60)
255+
256+
assigner = UserStoryEpicAssigner()
257+
results = assigner.assign_all_user_stories()
258+
259+
print("\n" + "=" * 60)
260+
print("📊 ASSIGNMENT RESULTS:")
261+
print(f"Total Files Processed: {results['total_files']}")
262+
print(f"Successful Assignments: {results['successful_assignments']}")
263+
print(f"Failed Assignments: {results['failed_assignments']}")
264+
265+
print("\n📋 ASSIGNMENTS BY EPIC:")
266+
for epic_id, files in results["assignments_by_epic"].items():
267+
print(f"{epic_id}: {len(files)} stories")
268+
for file in files[:5]: # Show first 5
269+
print(f" - {file}")
270+
if len(files) > 5:
271+
print(f" ... and {len(files) - 5} more")
272+
273+
# Save detailed results
274+
results_file = Path("epic_assignment_results.json")
275+
with open(results_file, 'w') as f:
276+
json.dump(results, f, indent=2, default=str)
277+
278+
print(f"\n💾 Detailed results saved to: {results_file}")
279+
print("🎉 Epic assignment process completed!")
280+
281+
if __name__ == "__main__":
282+
main()

utils/agile/agile_story_automation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import json
1818
import re
1919
from datetime import datetime
20+
from .temporal_authority import get_temporal_authority, temporal_compliance_decorator
2021
from pathlib import Path
2122
from typing import Dict, List, Any, Optional, Tuple
2223
from dataclasses import dataclass, asdict
@@ -542,7 +543,7 @@ def _generate_story_markdown(self, story: UserStory) -> str:
542543
- **ARTIFACT INTEGRATION**: All agile artifacts automatically updated
543544
- **PROGRESS TRACKING**: Status changes automatically reflected across project
544545
545-
**Last Updated**: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
546+
**Last Updated**: {get_temporal_authority().timestamp()}
546547
**Story Status**: {story.status.value}
547548
**Next Action**: Begin task execution and progress tracking
548549
"""

utils/agile/artifacts_automation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import threading
1414
from pathlib import Path
1515
from datetime import datetime
16+
from .temporal_authority import get_temporal_authority, temporal_compliance_decorator
1617
from dataclasses import dataclass, field
1718
from typing import Dict, List, Any, Optional
1819
import logging
@@ -335,7 +336,7 @@ def _update_all_artifacts_internal(self, completion: StoryCompletion, include_ti
335336
result.backup_location = backup_location
336337

337338
# Set timestamp (always for tracking)
338-
result.timestamp = datetime.now().strftime(self.timestamp_format)
339+
result.timestamp = get_temporal_authority().timestamp()
339340
if include_timestamps:
340341
result.timestamp_format = "Automated Update"
341342

@@ -434,7 +435,7 @@ def validate_artifact_consistency(self, completion: StoryCompletion) -> Artifact
434435

435436
def _create_backup(self) -> Path:
436437
"""Create backup of all artifact files."""
437-
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
438+
timestamp = get_temporal_authority().file_timestamp()
438439
backup_dir = self.docs_dir.parent / "backups" / f"agile_backup_{timestamp}"
439440
backup_dir.mkdir(parents=True, exist_ok=True)
440441

@@ -534,7 +535,7 @@ def update_agile_artifacts_for_story(story_id: str, title: str, story_points: in
534535
AllArtifactsUpdateResult with comprehensive update status
535536
"""
536537
if completion_date is None:
537-
completion_date = datetime.now().strftime("%Y-%m-%d")
538+
completion_date = get_temporal_authority().today()
538539

539540
# Create story completion object
540541
completion = StoryCompletion(

0 commit comments

Comments
 (0)