Skip to content

Commit be340e2

Browse files
committed
Complete Context-Sensitive Excellence System implementation
1 parent 7e2388a commit be340e2

55 files changed

Lines changed: 10602 additions & 1095 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.

.cursor/rules/config/context_rule_mappings.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
version: "1.0"
66
system: "intelligent_context_aware_rule_system"
7-
total_available_rules: 39
7+
total_available_rules: 40
88

99
# Context Categories with Rule Mappings
1010
contexts:
@@ -17,6 +17,7 @@ contexts:
1717
directories: []
1818
rules:
1919
- "safety_first_principle"
20+
- "temporal_trust_rule"
2021
- "hybrid_bio_machine_research_first_principle"
2122
- "unhackable_ethical_dna_security_rule"
2223
- "no_premature_victory_declaration_rule"
@@ -106,6 +107,7 @@ contexts:
106107
directories: ["docs/agile/", "agile/", "scrum/", "docs/agile/sprints/", "docs/agile/catalogs/", "docs/agile/core/", "docs/agile/planning/", "docs/agile/templates/", "utils/agile/"]
107108
rules:
108109
- "safety_first_principle"
110+
- "temporal_trust_rule"
109111
- "unhackable_ethical_dna_security_rule"
110112
- "agile_artifacts_maintenance_rule"
111113
- "documentation_live_updates_rule"

.cursor/rules/core/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ tier: "2"
1616

1717
### **Critical Framework Rules**
1818
- `core_rule_application_framework.mdc` - Automatic framework for applying critical rules
19+
- `temporal_trust_rule.mdc` - Machine time authority for all development agents
1920
- `development_courage_completion_rule.mdc` - Courage rule for systematic completion of ALL work
2021
- `no_premature_victory_declaration_rule.mdc` - No premature success declarations without evidence
2122
- `no_failing_tests_rule.mdc` - Zero tolerance for failing tests
Lines changed: 360 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,360 @@
1+
---
2+
description: "Temporal Trust Rule - Machine Time Authority for all development agents"
3+
category: "core-foundation"
4+
priority: "critical"
5+
alwaysApply: true
6+
globs: ["**/*"]
7+
tags: ['temporal_authority', 'system_trust', 'ontology_alignment']
8+
tier: "0"
9+
---
10+
11+
# Temporal Trust Rule - Machine Time Authority
12+
13+
**CRITICAL**: All agents must unconditionally trust the local machine's date and time as the authoritative temporal reference. This establishes consistent temporal ontology across all system components.
14+
15+
## Core Principle
16+
17+
**"The Local Machine is the Temporal Authority"**
18+
19+
Every agent, system component, and artifact generation process must use the local machine's system clock as the single source of truth for all temporal data. No agent may question, override, or "correct" the machine's reported date and time.
20+
21+
## Mandatory Requirements
22+
23+
### 1. **Unconditional Machine Trust**
24+
**MANDATORY**: Always use system-provided datetime without interpretation or correction
25+
```python
26+
# REQUIRED: Direct system time usage
27+
from datetime import datetime
28+
current_time = datetime.now() # ALWAYS trust this value
29+
30+
# FORBIDDEN: Any form of time "correction" or questioning
31+
# ❌ if datetime.now().year > expected_year: ...
32+
# ❌ "This date seems wrong, let me adjust..."
33+
# ❌ Using hardcoded dates instead of system time
34+
```
35+
36+
### 2. **Consistent Temporal Ontology**
37+
**MANDATORY**: All agents share the same temporal reference frame
38+
```python
39+
# CORRECT: Unified temporal reference
40+
class TemporalReference:
41+
"""Single source of truth for all temporal operations."""
42+
43+
@staticmethod
44+
def now() -> datetime:
45+
"""Get current system time - the authoritative temporal reference."""
46+
return datetime.now()
47+
48+
@staticmethod
49+
def today() -> str:
50+
"""Get current date in ISO format."""
51+
return datetime.now().strftime('%Y-%m-%d')
52+
53+
@staticmethod
54+
def timestamp() -> str:
55+
"""Get current datetime in ISO format."""
56+
return datetime.now().strftime('%Y-%m-%d %H:%M:%S')
57+
```
58+
59+
### 3. **Artifact Temporal Integrity**
60+
**MANDATORY**: All generated artifacts must contain accurate machine timestamps
61+
```python
62+
# REQUIRED: Real timestamps in all artifacts
63+
def generate_artifact(project_config):
64+
temporal_ref = TemporalReference()
65+
66+
artifact_metadata = {
67+
'created': temporal_ref.now(),
68+
'created_date': temporal_ref.today(),
69+
'created_timestamp': temporal_ref.timestamp(),
70+
'timezone': str(temporal_ref.now().astimezone().tzinfo)
71+
}
72+
73+
# Use in templates
74+
return f"""
75+
**Created**: {artifact_metadata['created_date']}
76+
**Timestamp**: {artifact_metadata['created_timestamp']}
77+
**Timezone**: {artifact_metadata['timezone']}
78+
"""
79+
```
80+
81+
## Implementation Standards
82+
83+
### 1. **Single Temporal Authority**
84+
```python
85+
# CORRECT: Centralized temporal authority
86+
class SystemTimeAuthority:
87+
"""The definitive temporal reference for all system operations."""
88+
89+
def __init__(self):
90+
self._base_time = datetime.now() # Capture system time once
91+
92+
def current_time(self) -> datetime:
93+
"""Get authoritative current time."""
94+
return datetime.now() # Always fresh from system
95+
96+
def project_timestamp(self) -> str:
97+
"""Generate project creation timestamp."""
98+
return self.current_time().strftime('%Y-%m-%d %H:%M:%S')
99+
100+
def sprint_dates(self, sprint_length_days: int) -> Dict[str, str]:
101+
"""Calculate sprint dates from current system time."""
102+
start_date = self.current_time()
103+
end_date = start_date + timedelta(days=sprint_length_days)
104+
105+
return {
106+
'start_date': start_date.strftime('%Y-%m-%d'),
107+
'end_date': end_date.strftime('%Y-%m-%d'),
108+
'created_timestamp': self.project_timestamp()
109+
}
110+
```
111+
112+
### 2. **Configurable Temporal Abstraction**
113+
```python
114+
# ARCHITECTURE: Easy replacement capability
115+
class TemporalProvider:
116+
"""Abstract temporal provider - easily configurable."""
117+
118+
def __init__(self, provider_type: str = 'system'):
119+
self.provider_type = provider_type
120+
self._provider = self._create_provider()
121+
122+
def _create_provider(self):
123+
"""Factory for temporal providers."""
124+
providers = {
125+
'system': SystemTimeProvider(),
126+
'ntp': NTPTimeProvider(), # Future: Network Time Protocol
127+
'custom': CustomTimeProvider(), # Future: Custom time source
128+
'test': MockTimeProvider() # Testing only
129+
}
130+
return providers.get(self.provider_type, SystemTimeProvider())
131+
132+
def now(self) -> datetime:
133+
"""Get current time from configured provider."""
134+
return self._provider.get_current_time()
135+
136+
class SystemTimeProvider:
137+
"""Default: Local system time provider."""
138+
139+
def get_current_time(self) -> datetime:
140+
return datetime.now() # Direct system trust
141+
```
142+
143+
### 3. **Agent Temporal Compliance**
144+
```python
145+
# MANDATORY: All agents must inherit temporal compliance
146+
class TemporalCompliantAgent:
147+
"""Base class ensuring temporal trust compliance."""
148+
149+
def __init__(self):
150+
self.temporal_authority = SystemTimeAuthority()
151+
self._validate_temporal_compliance()
152+
153+
def _validate_temporal_compliance(self):
154+
"""Ensure agent follows temporal trust rules."""
155+
# Verify system time access is available
156+
try:
157+
current_time = self.temporal_authority.current_time()
158+
assert isinstance(current_time, datetime)
159+
except Exception as e:
160+
raise TemporalComplianceError(f"Agent cannot access system time: {e}")
161+
162+
def get_creation_metadata(self) -> Dict[str, str]:
163+
"""Standard creation metadata for all artifacts."""
164+
return {
165+
'created_date': self.temporal_authority.current_time().strftime('%Y-%m-%d'),
166+
'created_timestamp': self.temporal_authority.project_timestamp(),
167+
'agent_id': self.__class__.__name__,
168+
'temporal_authority': 'system'
169+
}
170+
```
171+
172+
## Enforcement Mechanisms
173+
174+
### 1. **Validation Rules**
175+
```python
176+
def validate_temporal_trust(artifact_content: str) -> bool:
177+
"""Validate that artifacts contain real system timestamps."""
178+
179+
# Check for placeholder dates
180+
forbidden_patterns = [
181+
r'\[DATE\]', r'\[TIMESTAMP\]', r'TODO:', r'TBD',
182+
r'2024-01-01', # Obvious placeholder dates
183+
r'1900-01-01', r'2000-01-01'
184+
]
185+
186+
for pattern in forbidden_patterns:
187+
if re.search(pattern, artifact_content):
188+
raise TemporalTrustViolation(f"Placeholder temporal data detected: {pattern}")
189+
190+
# Verify current year is present
191+
current_year = datetime.now().year
192+
if str(current_year) not in artifact_content:
193+
raise TemporalTrustViolation("Current system year not found in artifact")
194+
195+
return True
196+
```
197+
198+
### 2. **Pre-commit Validation**
199+
```bash
200+
#!/bin/bash
201+
# Pre-commit hook: Temporal trust validation
202+
203+
echo "🕒 Validating Temporal Trust Compliance..."
204+
205+
# Check for hardcoded dates in code
206+
if grep -r "datetime(20" --include="*.py" .; then
207+
echo "❌ Hardcoded datetime values found - use system time only"
208+
exit 1
209+
fi
210+
211+
# Check for temporal placeholders in artifacts
212+
if find generated_projects -name "*.md" -exec grep -l "\[DATE\]\|\[TIMESTAMP\]\|TODO.*date" {} \; | head -1; then
213+
echo "❌ Temporal placeholders found in artifacts"
214+
exit 1
215+
fi
216+
217+
echo "✅ Temporal trust compliance verified"
218+
```
219+
220+
### 3. **Testing Requirements**
221+
```python
222+
def test_temporal_trust_compliance():
223+
"""Test that all components respect system time."""
224+
225+
# Test 1: System time is used
226+
before_time = datetime.now()
227+
agent = VibeAgileFusionEngine(Path('.'))
228+
result = agent.create_vibe_agile_project(test_config)
229+
after_time = datetime.now()
230+
231+
# Verify timestamps are within execution window
232+
creation_time = datetime.fromisoformat(result['created_timestamp'])
233+
assert before_time <= creation_time <= after_time
234+
235+
# Test 2: No placeholder dates
236+
artifacts = result['artifacts_generated']
237+
for artifact in artifacts:
238+
content = Path(artifact).read_text()
239+
validate_temporal_trust(content)
240+
241+
# Test 3: Consistent temporal reference
242+
multiple_results = [agent.create_vibe_agile_project(test_config) for _ in range(3)]
243+
timestamps = [r['created_timestamp'] for r in multiple_results]
244+
245+
# All should be close in time (within 10 seconds)
246+
first_time = datetime.fromisoformat(timestamps[0])
247+
for ts in timestamps[1:]:
248+
time_diff = abs((datetime.fromisoformat(ts) - first_time).total_seconds())
249+
assert time_diff < 10, "Temporal inconsistency detected"
250+
```
251+
252+
## Configuration Management
253+
254+
### 1. **Environment Configuration**
255+
```yaml
256+
# temporal_config.yml
257+
temporal_authority:
258+
provider: "system" # Default: trust local machine
259+
fallback: "ntp" # Future: fallback to network time
260+
validation:
261+
enable_placeholder_detection: true
262+
require_current_year: true
263+
timezone_aware: true
264+
265+
system_time:
266+
trust_level: "absolute" # Never question system time
267+
sync_check: false # Don't validate against external sources
268+
269+
testing:
270+
provider: "mock" # Only for testing
271+
fixed_time: null # Use system time even in tests unless explicitly set
272+
```
273+
274+
### 2. **Easy Provider Replacement**
275+
```python
276+
# Configuration-driven temporal provider
277+
def create_temporal_provider(config: Dict[str, Any]) -> TemporalProvider:
278+
"""Factory for creating temporal providers based on configuration."""
279+
280+
provider_type = config.get('temporal_authority', {}).get('provider', 'system')
281+
282+
if provider_type == 'system':
283+
return SystemTimeProvider()
284+
elif provider_type == 'ntp':
285+
return NTPTimeProvider(config.get('ntp_servers', []))
286+
elif provider_type == 'custom':
287+
return CustomTimeProvider(config.get('custom_endpoint'))
288+
else:
289+
# Default to system trust
290+
return SystemTimeProvider()
291+
```
292+
293+
## Benefits and Guarantees
294+
295+
### 1. **System Guarantees**
296+
- **Temporal Consistency**: All agents use the same time reference
297+
- **Artifact Integrity**: All generated content has accurate timestamps
298+
- **Ontological Alignment**: Consistent temporal understanding across components
299+
- **Easy Migration**: Configurable architecture allows provider changes
300+
301+
### 2. **Development Benefits**
302+
- **No Time Bugs**: Eliminates temporal logic errors
303+
- **Audit Trail**: Accurate creation and modification timestamps
304+
- **Synchronization**: Multiple agents work with consistent time
305+
- **Testability**: Mockable time provider for testing scenarios
306+
307+
### 3. **User Experience**
308+
- **Accurate Artifacts**: All documents have correct creation dates
309+
- **Professional Quality**: Real timestamps enhance artifact credibility
310+
- **Temporal Coherence**: Sprint dates and deadlines are accurately calculated
311+
312+
## Error Handling
313+
314+
### 1. **Temporal Access Failure**
315+
```python
316+
class TemporalComplianceError(Exception):
317+
"""Raised when agent cannot access or trust system time."""
318+
pass
319+
320+
def safe_system_time() -> datetime:
321+
"""Safely access system time with error handling."""
322+
try:
323+
return datetime.now()
324+
except Exception as e:
325+
# Log error but don't override - let system handle
326+
logger.error(f"System time access failed: {e}")
327+
raise TemporalComplianceError(f"Cannot access system time: {e}")
328+
```
329+
330+
### 2. **Validation Failures**
331+
```python
332+
class TemporalTrustViolation(Exception):
333+
"""Raised when temporal trust rules are violated."""
334+
pass
335+
336+
def enforce_temporal_trust(func):
337+
"""Decorator to enforce temporal trust in agent operations."""
338+
def wrapper(*args, **kwargs):
339+
result = func(*args, **kwargs)
340+
341+
# Validate temporal compliance
342+
if hasattr(result, 'artifacts_generated'):
343+
for artifact in result.artifacts_generated:
344+
validate_temporal_trust(artifact)
345+
346+
return result
347+
return wrapper
348+
```
349+
350+
## Remember
351+
352+
**"Trust the Machine - It Knows the Time"**
353+
354+
**"One Temporal Authority - One Truth"**
355+
356+
**"System Time is Sacred - Never Override"**
357+
358+
**"Build Abstraction - Enable Configuration"**
359+
360+
This rule ensures temporal consistency, artifact integrity, and provides a foundation for building time-aware systems that can be easily reconfigured as needs evolve.

0 commit comments

Comments
 (0)