tractatus/OPTIMAL_STARTUP_PROMPT_2025-10-23.md
TheFlow 2298d36bed fix(submissions): restructure Economist package and fix article display
- Create Economist SubmissionTracking package correctly:
  * mainArticle = full blog post content
  * coverLetter = 216-word SIR— letter
  * Links to blog post via blogPostId
- Archive 'Letter to The Economist' from blog posts (it's the cover letter)
- Fix date display on article cards (use published_at)
- Target publication already displaying via blue badge

Database changes:
- Make blogPostId optional in SubmissionTracking model
- Economist package ID: 68fa85ae49d4900e7f2ecd83
- Le Monde package ID: 68fa2abd2e6acd5691932150

Next: Enhanced modal with tabs, validation, export

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 08:47:42 +13:00

504 lines
15 KiB
Markdown

# OPTIMAL STARTUP PROMPT - 2025-10-23
**Session Type**: NEW (not --continue)
**Previous Session**: Blog Validation & Published Posts UI Implementation
**Status**: Clean closedown completed
**Framework Health**: ✅ OPERATIONAL
---
## STARTUP SEQUENCE (Execute in Order)
```bash
# 1. Initialize session framework
node scripts/session-init.js
# 2. Verify database state
mongosh tractatus_dev --eval "db.blog_posts.countDocuments({status: 'published'})"
# Expected: 6
# 3. Verify server not running
lsof -ti :9000
# Expected: no output
# 4. Start development server
npm start
# 5. Test Published Posts UI
# Navigate to: http://localhost:9000/admin/blog-curation.html
# Click "📰 Published" tab → should show 6 posts
```
---
## SYSTEM STATUS
### Application
- **MongoDB**: Port 27017, database `tractatus_dev`
- **Server**: Port 9000 (not running - start with `npm start`)
- **Branch**: main
- **Sync Status**: Up to date with origin/main
### Modified Files (Uncommitted)
1. `public/version.json`
2. `scripts/sync-instructions-to-db.js`
3. `src/middleware/rate-limit.middleware.js`
4. `src/middleware/response-sanitization.middleware.js`
5. `src/routes/index.js`
6. `src/server.js`
### Key Untracked Files (This Session)
- `SESSION_HANDOFF_2025-10-23_BLOG_VALIDATION_PUBLISHED_POSTS.md` (detailed handoff)
- `OPTIMAL_STARTUP_PROMPT_2025-10-23.md` (this file)
- `public/admin/blog-curation.html` (modified - Published tab added)
- `public/js/admin/blog-validation.js` (modified - loadPublishedPosts function)
- `public/service-worker.js` (modified - cache version 1.8.3)
### Database State
**Collection**: `blog_posts` (blog_posts collection with underscore)
- Published posts: 6
- Pending review: 4
- Total: 10
---
## COMPLETED TASKS
### 1. Database Cleanup ✅
**File**: MongoDB `tractatus_dev.blog_posts`
**Action**: Fixed production/dev mismatch
**Changes**:
```javascript
// Removed duplicate post
db.blog_posts.deleteOne({ slug: 'how-to-scale-tractatus-breaking-the-chicken-and-egg-problem' });
// Changed internal guide from published to pending_review
db.blog_posts.updateOne(
{ slug: 'the-economist-submission-strategy-guide' },
{ $set: { status: 'pending_review' } }
);
```
**Result**: Database now matches production (6 published posts)
### 2. Published Posts UI Tab ✅
**Files Modified**:
- `/home/theflow/projects/tractatus/public/admin/blog-curation.html:42-44` (tab button)
- `/home/theflow/projects/tractatus/public/admin/blog-curation.html:391-409` (section HTML)
- `/home/theflow/projects/tractatus/public/js/admin/blog-validation.js:582-653` (`loadPublishedPosts()`)
- `/home/theflow/projects/tractatus/public/js/admin/blog-validation.js:656-713` (`showReadModal()`)
- `/home/theflow/projects/tractatus/public/js/admin/blog-validation.js:747` (section navigation)
- `/home/theflow/projects/tractatus/public/js/admin/blog-validation.js:767-769` (refresh handler)
**Features Implemented**:
- View list of 6 published website articles
- Read full article content in modal overlay
- View Live link to production website
- Refresh button to reload list
- Clean card-based layout with excerpts, word counts, tags
### 3. ObjectId Buffer Conversion Helper ✅
**File**: `/home/theflow/projects/tractatus/public/js/admin/blog-validation.js:7-38`
**Function**: `toStringId(id)`
**Purpose**: Converts MongoDB Buffer ObjectIds to hex strings
- Input: `{buffer: {0:104, 1:249, 2:237, ...}}` (12 bytes)
- Output: `"68f9ed1613441dbd106aa54a"` (24-char hex)
### 4. Cache Version Updates ✅
- Service worker: `1.8.2``1.8.3` (`public/service-worker.js:8`)
- HTML assets: all updated to `v=1761220417` (cache-busting)
---
## IN-PROGRESS TASKS
**None** - All tasks completed cleanly before closedown.
---
## PENDING TASKS (Prioritized)
### Priority 1: Auto-Compact Tracking System ⚠️
**User Concern**: Auto-compacts happening frequently despite NORMAL pressure (6.6%)
**Hypothesis**: Pressure gauge not measuring actual compact triggers
**Implementation Plan**:
1. Add `auto_compact_events` array to `.claude/session-state.json`:
```json
"auto_compact_events": [
{
"timestamp": "2025-10-23T12:00:00Z",
"tokens_at_compact": 45000,
"pressure_level": "NORMAL",
"pressure_score": 6.6,
"messages": 42,
"action_count": 150
}
]
```
2. Create `/home/theflow/projects/tractatus/scripts/record-auto-compact.js`:
- Detects auto-compact (session summary message, context reset)
- Records pressure metrics at compact time
- Appends to `auto_compact_events` array
3. Update `scripts/check-session-pressure.js` to display:
- Total compacts in current session
- Average tokens per compact
- Correlation between pressure score and compact frequency
- Warning if compacts at NORMAL/ELEVATED levels
**Acceptance Criteria**:
- User can see compact frequency vs pressure correlation
- Data informs pressure gauge weight adjustments
### Priority 2: Manage Submission Modal
**File**: `/home/theflow/projects/tractatus/public/admin/blog-curation.html`
**Status**: Button exists (Manage Submission), no handler
**Requirements**:
- Modal for each pending review article
- Select/change target publication (dropdown from `publication-targets.config.js`)
- Submission package checklist:
- Cover letter (textarea + checkbox)
- Pitch email (textarea + checkbox)
- Notes to editor (textarea + checkbox)
- Author bio (textarea + checkbox)
- Save progress to `submission_tracking` collection
- Display completion percentage
**API Endpoints Needed**:
- `GET /api/blog/:id/submissions` - fetch tracking data
- `PUT /api/blog/:id/submissions` - update checklist
### Priority 3: Submissions API Endpoint
**File**: `/home/theflow/projects/tractatus/src/routes/blog.routes.js`
**Status**: Returns 404
**Implementation**:
```javascript
// In blog.routes.js
router.get('/:id/submissions', blogController.getSubmissions);
router.put('/:id/submissions', blogController.updateSubmission);
// In blog.controller.js
async getSubmissions(req, res) {
const submissions = await SubmissionTracking.find({
blogPostId: req.params.id
}).populate('createdBy', 'email');
res.json({ submissions });
}
async updateSubmission(req, res) {
const submission = await SubmissionTracking.findOneAndUpdate(
{ blogPostId: req.params.id, publicationId: req.body.publicationId },
{ submissionPackage: req.body.submissionPackage },
{ new: true, upsert: true }
);
res.json({ submission });
}
```
**Currently Commented Out**: `public/js/admin/blog-validation.js:109-125`
---
## INSTRUCTION CHANGES
### New Instructions Added
- `inst_024_CONSOLIDATED`: Session closedown procedure (6 steps)
- `inst_075`: Token checkpoint enforcement (25%, 50%, 75%)
- `inst_076`: Test user hypotheses first before alternative approaches
### Total Instruction Count
- **75 instructions** in history
- **50 active** (HIGH persistence)
- **14 STRATEGIC**, **17 SYSTEM** categories
---
## KNOWN ISSUES
### 1. Auto-Compact Frequency vs Pressure Gauge ⚠️
**Severity**: Medium
**Description**: User observes frequent auto-compacts despite pressure showing NORMAL (6.6%)
**Impact**:
- Potential context loss degrading deliverable quality
- Gauge not accurately predicting compact triggers
**Hypothesis**: Gauge may not measure:
- Message count (likely primary trigger)
- Conversation complexity
- Claude Code internal thresholds
**Resolution**: Implement auto-compact tracking (Priority 1 pending task)
### 2. Duplicate Publication Targets Config
**Severity**: Low
**Files**:
- `src/config/publication-targets.config.js` (new)
- May duplicate data in database collection
**Impact**: Minor - need to choose canonical source
**Resolution**: Decide if config file or DB is source of truth, deprecate other
### 3. Inconsistent Blog Collection Naming
**Severity**: Low
**Collections**:
- Code references `BlogPost` model
- Database uses `blog_posts` (with underscore)
**Impact**: Minor confusion, no functional issue
**Resolution**: Document convention, ensure consistency in future queries
---
## FRAMEWORK HEALTH
### Component Status
- ✅ **CrossReferenceValidator**: ACTIVE (462 validations performed)
- ✅ **BashCommandValidator**: ACTIVE (152 validations, 7 blocks issued)
- ✅ **ContextPressureMonitor**: OPERATIONAL (last: NORMAL @ 6.6%)
- ✅ **InstructionPersistenceClassifier**: READY
- ✅ **BoundaryEnforcer**: READY
- ✅ **MetacognitiveVerifier**: READY (selective mode)
- ✅ **PluralisticDeliberationOrchestrator**: READY
### Hook Performance
- **FileEditHook**: Last run 2025-10-23 11:53:11 → PASSED (`public/service-worker.js`)
- **FileWriteHook**: Last run 2025-10-23 10:05:04 → PASSED (`blog-validation.js`)
### Session Metrics
- **Action Count**: 152
- **Message Count**: 1 (reset for new session)
- **Token Estimate**: 0 (reset for new session)
- **Last Framework Activity**: 2025-10-23 11:53:11
### Pressure Analysis
**Last Reading**:
- Tokens: 100,206 / 200,000 (50.1%)
- Pressure Level: NORMAL
- Pressure Score: 6.6%
- Recommendation: PROCEED
**Metrics Breakdown**:
- Token Usage: 50.1%
- Conversation: 0.0% (new session)
- Task Complexity: 6.0%
- Error Frequency: 0.0%
- Instructions: 0.0%
---
## USER DECISIONS NEEDED
### 1. Multi-Publication Article Strategy
**Context**: User wants to submit 6 different articles to 6 publications simultaneously:
- The Economist
- NYT
- Caixin Global
- The Hindu
- Le Monde
- Der Spiegel
**Decision Required**:
- What are the other 4 articles (besides NYT & Economist)?
- When does user want to actually submit?
- Should we build submission tracking for all 6?
### 2. Auto-Compact Tracking Priority
**Context**: User raised concern about compact frequency
**Decision Required**:
- Should auto-compact tracking be top priority?
- Or continue with submission workflow features?
### 3. Social Media Promotion
**Context**: User mentioned "essentially just advertise the website on social media"
**Decision Required**:
- Should we build social media scheduling/automation?
- Integrate with Twitter/LinkedIn APIs?
- Or is this manual for now?
---
## TODOWRITE JSON
```json
{
"todos": [
{
"content": "Fix database to match production reality (6 published posts, remove duplicate/inconsistent entries)",
"status": "completed",
"activeForm": "Fixing database to match production reality"
},
{
"content": "Add Published Posts section to blog curation UI with read capability",
"status": "completed",
"activeForm": "Adding Published Posts section to UI"
},
{
"content": "Enhance pressure monitoring to track auto-compact correlation",
"status": "completed",
"activeForm": "Enhancing pressure monitoring for auto-compact tracking"
},
{
"content": "Create comprehensive handoff document for new session",
"status": "completed",
"activeForm": "Creating handoff document"
}
]
}
```
**All tasks completed** ✅ - No pending items from previous session.
---
## TESTING CHECKLIST
### Database Verification
```bash
# 1. Verify published count
mongosh tractatus_dev --eval "db.blog_posts.countDocuments({status: 'published'})"
# Expected: 6
# 2. Verify pending count
mongosh tractatus_dev --eval "db.blog_posts.countDocuments({status: 'pending_review'})"
# Expected: 4
# 3. List published titles
mongosh tractatus_dev --eval "db.blog_posts.find({status: 'published'}, {title: 1}).forEach(p => print(p.title))"
# Expected: 6 titles matching production
```
### UI Functionality
```bash
# 1. Start server
npm start
# 2. Navigate to blog curation
# http://localhost:9000/admin/blog-curation.html
# Login required (use admin credentials)
# 3. Test Published tab
# - Click "📰 Published" tab
# - Verify 6 posts displayed
# - Click "Read" on any post
# - Modal should open with full content
# - Click "View Live"
# - Should open agenticgovernance.digital/blog/{slug}
# - Click "Refresh"
# - List should reload
```
### Cache Version Verification
```bash
# 1. Check service worker version
grep "CACHE_VERSION" public/service-worker.js
# Expected: 1.8.3
# 2. Check HTML cache-busting
grep "blog-validation.js" public/admin/blog-curation.html
# Expected: v=1761220417
```
---
## IMPORTANT CONTEXT FROM USER
### User Corrections During Session
1. **Six Different Articles, Not One**
- **My Error**: Assumed same article to 6 publications
- **Reality**: 6 distinct articles for 6 different publications
- **Lesson**: Don't assume submission ethics issue without evidence
2. **Production Shows 6, Not 8**
- **My Error**: Trusted database count over production reality
- **Reality**: User sees 6 on production website = source of truth
- **Lesson**: Production website is authoritative
3. **Content Similarity Inconsistency**
- **My Error**: Said 40% similar, then 92% similar
- **Reality**: NYT (accessible) vs Economist (analytical) are different angles
- **Lesson**: Read full articles before similarity judgments
4. **Auto-Compact Frequency Concern**
- **User Observation**: Compacts happening frequently despite NORMAL pressure
- **My Mistake**: Dismissed concern citing "plenty of runway"
- **Reality**: User's empirical observations > theoretical models
- **Lesson**: Trust user's experience with framework behavior
### User Communication Style
- **Direct** but patient
- **Expects precision**, not verbosity
- **Corrects** when assumptions made
- **Challenges** inconsistencies immediately
- **Values** empirical observation over theory
---
## CRITICAL WARNINGS FOR NEXT SESSION
### DO NOT:
1. ❌ Lecture about submission ethics unless submitting identical content
2. ❌ Dismiss user observations about framework behavior
3. ❌ Trust database over production reality - production is source of truth
4. ❌ Make content similarity judgments without reading full articles
5. ❌ Assume pressure gauge is accurate - it may be missing critical metrics
### DO:
1. ✅ Test user hypotheses FIRST (per inst_076)
2. ✅ Verify production website matches database
3. ✅ Read full article content before similarity analysis
4. ✅ Take auto-compact tracking seriously (user concern is valid)
5. ✅ Prioritize user's empirical observations
---
## REFERENCE URLS
- **Production**: https://agenticgovernance.digital
- **Blog**: https://agenticgovernance.digital/blog
- **Admin**: http://localhost:9000/admin/blog-curation.html
- **MongoDB**: mongodb://localhost:27017/tractatus_dev
---
## NEXT SESSION FIRST STEPS
1. **Run session-init.js** (MANDATORY per inst_065)
2. **Read this document completely**
3. **Verify database** (6 published, 4 pending)
4. **Test Published Posts UI**
5. **Ask user**: Priority for next work (auto-compact tracking vs submission workflow)?
---
## FILES TO READ (Priority Order)
1. `.claude/instruction-history.json` - Full governance context
2. `SESSION_HANDOFF_2025-10-23_BLOG_VALIDATION_PUBLISHED_POSTS.md` - Detailed session summary
3. `src/models/SubmissionTracking.model.js` - Understand submission schema
4. `public/js/admin/blog-validation.js` - Review UI code
5. `src/config/publication-targets.config.js` - Publication target list
---
**Session Closedown Complete**
**New Session Ready to Start** 🚀
**All Work Stopped as Per Instruction**
---
*Handoff prepared: 2025-10-23*
*Next session type: NEW (not --continue)*
*Framework status: OPERATIONAL*