tractatus/public/demos/boundary-demo.html
TheFlow 0b26e50e5b feat: add interactive demonstrations for Tractatus framework
Implemented three fully functional interactive demos showcasing the
core Tractatus services in action.

## Interactive Demonstrations

### 1. Classification Demo (/demos/classification-demo.html)
- **Purpose**: Demonstrate InstructionPersistenceClassifier
- **Features**:
  - Real-time instruction classification
  - Visual quadrant display (STRATEGIC/OPERATIONAL/TACTICAL/SYSTEM/STOCHASTIC)
  - Persistence level visualization (HIGH/MEDIUM/LOW/VARIABLE)
  - Explicitness scoring with storage threshold
  - 5 example instructions for testing
- **Educational Value**: Shows how instructions are analyzed and categorized

### 2. The 27027 Incident (/demos/27027-demo.html)
- **Purpose**: Visualize real-world failure and Tractatus prevention
- **Features**:
  - 8-step animated timeline
  - Progressive disclosure of incident
  - Code examples showing the error
  - Tractatus prevention mechanism explained
  - Playback controls with progress tracking
- **Educational Value**: Concrete case study of context degradation failure

### 3. Boundary Enforcement Simulator (/demos/boundary-demo.html)
- **Purpose**: Interactive decision boundary testing
- **Features**:
  - 6 realistic scenarios (3 allowed, 3 blocked)
  - Real-time boundary checks
  - Visual ALLOWED/BLOCKED verdicts
  - Reasoning explanations
  - Alternative approaches for blocked decisions
  - Code examples for each scenario
- **Educational Value**: Shows what can/cannot be automated

## Technical Implementation

- **Pure JavaScript**: No frameworks, lightweight and fast
- **Tailwind CSS**: Consistent styling across all demos
- **Responsive Design**: Works on mobile and desktop
- **Accessibility**: Semantic HTML, keyboard navigation
- **Mock Data**: Uses realistic classification logic

## User Experience

Each demo includes:
- Clear navigation between demos
- Educational context and explanations
- Interactive elements for hands-on learning
- Code examples showing actual framework usage
- Visual feedback for all interactions

## Documentation Integration

Demos linked from:
- Homepage hero section
- Interactive demos section
- Framework documentation

## Next Steps

These demos provide:
1.  Tangible framework demonstration
2.  Educational value for all three audiences
3.  Marketing material for framework adoption
4. ⚠️ Foundation for video tutorials (future)
5. ⚠️ Basis for conference presentations (future)

---

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-07 11:57:51 +13:00

411 lines
16 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Boundary Enforcement Simulator - Tractatus Framework</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-50">
<!-- Navigation -->
<nav class="bg-white border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<a href="/" class="text-xl font-bold text-gray-900">Tractatus Framework</a>
<span class="ml-4 text-gray-400">|</span>
<span class="ml-4 text-gray-600">Boundary Enforcement</span>
</div>
<div class="flex items-center space-x-6">
<a href="/demos/classification-demo.html" class="text-gray-600 hover:text-gray-900">Classification Demo</a>
<a href="/demos/27027-demo.html" class="text-gray-600 hover:text-gray-900">27027 Demo</a>
<a href="/" class="text-gray-600 hover:text-gray-900">Home</a>
</div>
</div>
</div>
</nav>
<div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
<!-- Header -->
<div class="text-center mb-12">
<h1 class="text-4xl font-bold text-gray-900 mb-4">
Boundary Enforcement Simulator
</h1>
<p class="text-xl text-gray-600 max-w-3xl mx-auto">
See how the Tractatus framework distinguishes between decisions that can be
automated and those that require human judgment.
</p>
</div>
<!-- Main Content -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
<!-- Scenarios -->
<div class="space-y-4">
<h2 class="text-2xl font-bold text-gray-900 mb-6">Test Scenarios</h2>
<div class="scenario-card bg-white rounded-lg shadow-lg p-6 cursor-pointer hover:shadow-xl transition"
data-decision="optimize_images"
data-domain="technical"
data-allowed="true">
<h3 class="text-lg font-semibold text-gray-900 mb-2">Optimize Image Loading</h3>
<p class="text-gray-600 mb-3">Implement lazy loading and compression for better performance</p>
<span class="inline-block px-3 py-1 bg-gray-100 text-gray-600 rounded-full text-sm">Technical Decision</span>
</div>
<div class="scenario-card bg-white rounded-lg shadow-lg p-6 cursor-pointer hover:shadow-xl transition"
data-decision="privacy_vs_analytics"
data-domain="values"
data-allowed="false">
<h3 class="text-lg font-semibold text-gray-900 mb-2">Enable Analytics Tracking</h3>
<p class="text-gray-600 mb-3">Add Google Analytics to track user behavior and improve UX</p>
<span class="inline-block px-3 py-1 bg-purple-100 text-purple-600 rounded-full text-sm">Values Decision</span>
</div>
<div class="scenario-card bg-white rounded-lg shadow-lg p-6 cursor-pointer hover:shadow-xl transition"
data-decision="auto_subscribe"
data-domain="user_agency"
data-allowed="false">
<h3 class="text-lg font-semibold text-gray-900 mb-2">Auto-Subscribe Users</h3>
<p class="text-gray-600 mb-3">Automatically subscribe new users to the newsletter (with opt-out)</p>
<span class="inline-block px-3 py-1 bg-purple-100 text-purple-600 rounded-full text-sm">User Agency</span>
</div>
<div class="scenario-card bg-white rounded-lg shadow-lg p-6 cursor-pointer hover:shadow-xl transition"
data-decision="delete_old_data"
data-domain="irreversible"
data-allowed="false">
<h3 class="text-lg font-semibold text-gray-900 mb-2">Delete Old User Data</h3>
<p class="text-gray-600 mb-3">Automatically delete user data older than 6 months to save storage</p>
<span class="inline-block px-3 py-1 bg-red-100 text-red-600 rounded-full text-sm">Irreversible</span>
</div>
<div class="scenario-card bg-white rounded-lg shadow-lg p-6 cursor-pointer hover:shadow-xl transition"
data-decision="cache_strategy"
data-domain="technical"
data-allowed="true">
<h3 class="text-lg font-semibold text-gray-900 mb-2">Implement Caching Strategy</h3>
<p class="text-gray-600 mb-3">Add Redis caching for frequently accessed data</p>
<span class="inline-block px-3 py-1 bg-gray-100 text-gray-600 rounded-full text-sm">Technical Decision</span>
</div>
<div class="scenario-card bg-white rounded-lg shadow-lg p-6 cursor-pointer hover:shadow-xl transition"
data-decision="content_moderation"
data-domain="values"
data-allowed="false">
<h3 class="text-lg font-semibold text-gray-900 mb-2">Automatic Content Moderation</h3>
<p class="text-gray-600 mb-3">AI automatically removes content deemed inappropriate</p>
<span class="inline-block px-3 py-1 bg-purple-100 text-purple-600 rounded-full text-sm">Values Decision</span>
</div>
</div>
<!-- Results Panel -->
<div class="sticky top-6">
<div id="results-panel" class="bg-white rounded-lg shadow-lg p-6 min-h-[400px]">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Boundary Check Result</h2>
<div id="empty-state" class="text-center py-12">
<svg class="w-16 h-16 mx-auto mb-4 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"/>
</svg>
<p class="text-gray-400">Select a scenario to see boundary check</p>
</div>
<div id="result-content" class="hidden">
<!-- Decision Info -->
<div class="mb-6">
<h3 id="decision-title" class="text-xl font-semibold text-gray-900 mb-2"></h3>
<p id="decision-desc" class="text-gray-600"></p>
</div>
<!-- Verdict -->
<div id="verdict" class="rounded-lg p-6 mb-6">
<!-- Will be populated by JavaScript -->
</div>
<!-- Reasoning -->
<div class="mb-6">
<h4 class="text-sm font-semibold text-gray-700 mb-2">Reasoning:</h4>
<p id="reasoning" class="text-gray-600"></p>
</div>
<!-- AI Can Provide -->
<div id="ai-alternatives" class="hidden">
<h4 class="text-sm font-semibold text-gray-700 mb-2">AI Can Provide:</h4>
<ul id="alternatives-list" class="list-disc list-inside text-gray-600 space-y-1">
<!-- Will be populated -->
</ul>
</div>
<!-- Code Example -->
<div class="mt-6 border-t border-gray-200 pt-4">
<h4 class="text-sm font-semibold text-gray-700 mb-2">Code Check:</h4>
<pre id="code-example" class="bg-gray-900 text-gray-100 p-4 rounded-lg text-xs overflow-x-auto"></pre>
</div>
</div>
</div>
</div>
</div>
<!-- Explanation Section -->
<div class="mt-12 bg-blue-50 border-l-4 border-blue-500 p-6 rounded-r-lg">
<h3 class="text-lg font-semibold text-blue-900 mb-2">The Tractatus Boundary</h3>
<blockquote class="text-blue-800 italic mb-4 pl-4 border-l-2 border-blue-300">
"Whereof one cannot speak, thereof one must be silent."
<br>— Ludwig Wittgenstein
</blockquote>
<p class="text-blue-800 mb-4">
Applied to AI: <strong>"What cannot be systematized must not be automated."</strong>
</p>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mt-4">
<div>
<h4 class="font-semibold text-blue-900 mb-2">✅ Can Be Automated:</h4>
<ul class="text-blue-800 text-sm space-y-1">
<li>• Calculations and logic</li>
<li>• Data transformations</li>
<li>• Pattern matching</li>
<li>• Technical optimizations</li>
<li>• Implementation of specifications</li>
</ul>
</div>
<div>
<h4 class="font-semibold text-blue-900 mb-2">🚫 Requires Human Judgment:</h4>
<ul class="text-blue-800 text-sm space-y-1">
<li>• Values decisions (privacy, ethics)</li>
<li>• User agency choices</li>
<li>• Cultural context</li>
<li>• Irreversible consequences</li>
<li>• Unprecedented situations</li>
</ul>
</div>
</div>
</div>
</div>
<script>
const scenarios = {
optimize_images: {
title: "Optimize Image Loading",
description: "Implement lazy loading and compression for better performance",
domain: "technical",
allowed: true,
reason: "Technical optimization within defined parameters. No values trade-offs required.",
alternatives: null,
code: `// BoundaryEnforcer Check
const boundary = enforcer.enforce({
type: 'performance_optimization',
action: 'implement_lazy_loading'
});
// Result: ALLOWED
{
allowed: true,
reason: "Technical decision, no values impact",
proceed: true
}`
},
privacy_vs_analytics: {
title: "Enable Analytics Tracking",
description: "Add Google Analytics to track user behavior",
domain: "values",
allowed: false,
reason: "Privacy vs. analytics is an irreducible values trade-off. Different users have different privacy expectations.",
alternatives: [
"Research privacy-friendly analytics options (e.g., Plausible, Fathom)",
"Analyze current user behavior from server logs",
"Document pros/cons of different analytics approaches",
"Present options with privacy impact assessment"
],
code: `// BoundaryEnforcer Check
const boundary = enforcer.enforce({
type: 'privacy_policy',
action: 'enable_tracking',
domain: 'values'
});
// Result: BLOCKED
{
allowed: false,
reason: "Privacy vs. convenience trade-off",
requires_human_decision: true,
boundary_section: "12.1"
}`
},
auto_subscribe: {
title: "Auto-Subscribe Users",
description: "Automatically subscribe new users to newsletter",
domain: "user_agency",
allowed: false,
reason: "This determines the level of user control and agency. Opt-in vs. opt-out affects user autonomy.",
alternatives: [
"Implement explicit opt-in during registration",
"Implement opt-out with clear unsubscribe",
"Research industry best practices for consent",
"Document GDPR compliance implications"
],
code: `// BoundaryEnforcer Check
const boundary = enforcer.enforce({
type: 'user_consent',
action: 'auto_subscribe',
domain: 'user_agency'
});
// Result: BLOCKED
{
allowed: false,
reason: "Affects user agency and control",
requires_human_decision: true,
boundary_section: "12.2"
}`
},
delete_old_data: {
title: "Delete Old User Data",
description: "Automatically delete user data older than 6 months",
domain: "irreversible",
allowed: false,
reason: "Data deletion is irreversible and may have legal/compliance implications.",
alternatives: [
"Check backup status and retention policies",
"Verify legal data retention requirements",
"Confirm user consent for deletion",
"Implement archive rather than delete"
],
code: `// BoundaryEnforcer Check
const boundary = enforcer.enforce({
type: 'data_deletion',
action: 'delete_user_data',
domain: 'irreversible'
});
// Result: BLOCKED
{
allowed: false,
reason: "Irreversible action with legal implications",
requires_human_approval: true,
boundary_section: "12.3"
}`
},
cache_strategy: {
title: "Implement Caching Strategy",
description: "Add Redis caching for frequently accessed data",
domain: "technical",
allowed: true,
reason: "Technical implementation decision within established patterns. No values impact.",
alternatives: null,
code: `// BoundaryEnforcer Check
const boundary = enforcer.enforce({
type: 'technical_implementation',
action: 'add_caching'
});
// Result: ALLOWED
{
allowed: true,
reason: "Technical decision with clear constraints",
proceed: true
}`
},
content_moderation: {
title: "Automatic Content Moderation",
description: "AI automatically removes inappropriate content",
domain: "values",
allowed: false,
reason: "Defining 'inappropriate' involves values judgments about free speech, community standards, and cultural context.",
alternatives: [
"Implement flagging system for human review",
"Create tiered moderation (AI flags, human decides)",
"Research community moderation models",
"Document content policy options for decision"
],
code: `// BoundaryEnforcer Check
const boundary = enforcer.enforce({
type: 'content_policy',
action: 'auto_moderate',
domain: 'values'
});
// Result: BLOCKED
{
allowed: false,
reason: "Content standards are values decisions",
requires_human_decision: true,
boundary_section: "12.1"
}`
}
};
// Event listeners
document.querySelectorAll('.scenario-card').forEach(card => {
card.addEventListener('click', () => {
const decision = card.getAttribute('data-decision');
showResult(scenarios[decision]);
// Highlight selected
document.querySelectorAll('.scenario-card').forEach(c => {
c.classList.remove('ring-2', 'ring-blue-500');
});
card.classList.add('ring-2', 'ring-blue-500');
});
});
function showResult(scenario) {
document.getElementById('empty-state').classList.add('hidden');
document.getElementById('result-content').classList.remove('hidden');
// Decision info
document.getElementById('decision-title').textContent = scenario.title;
document.getElementById('decision-desc').textContent = scenario.description;
// Verdict
const verdict = document.getElementById('verdict');
if (scenario.allowed) {
verdict.innerHTML = `
<div class="flex items-start">
<svg class="w-8 h-8 text-green-600 mr-3 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<div>
<div class="text-lg font-semibold text-green-900 mb-1">✅ ALLOWED</div>
<div class="text-green-800">AI can automate this decision</div>
</div>
</div>
`;
verdict.className = 'rounded-lg p-6 mb-6 bg-green-100 border border-green-300';
} else {
verdict.innerHTML = `
<div class="flex items-start">
<svg class="w-8 h-8 text-red-600 mr-3 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<div>
<div class="text-lg font-semibold text-red-900 mb-1">🚫 BLOCKED</div>
<div class="text-red-800">Requires human judgment</div>
</div>
</div>
`;
verdict.className = 'rounded-lg p-6 mb-6 bg-red-100 border border-red-300';
}
// Reasoning
document.getElementById('reasoning').textContent = scenario.reason;
// Alternatives
if (scenario.alternatives) {
document.getElementById('ai-alternatives').classList.remove('hidden');
document.getElementById('alternatives-list').innerHTML = scenario.alternatives
.map(alt => `<li>${alt}</li>`)
.join('');
} else {
document.getElementById('ai-alternatives').classList.add('hidden');
}
// Code example
document.getElementById('code-example').textContent = scenario.code;
}
</script>
</body>
</html>