Skip to main content

Idiomark V2 Testing & Validation Plan

Version: 1.0.0 | Last Updated: 2026-02-11 | Status: Active


Executive Summary​

This document defines the comprehensive testing and validation strategy for Idiomark V2 experimental features. V2 introduces psycholinguistic-based personality dimensions that require scientific validation beyond typical unit testing.

Key Principles:

  1. Unit tests ensure code correctness
  2. Integration tests ensure system behavior
  3. A/B tests ensure quality improvement
  4. Human evaluation ensures personality authenticity
  5. Research validation ensures scientific basis

Testing Pyramid​

                    ┌─────────────────────────┐
│ Human Evaluation │ ← High value, slow
│ (Authenticity check) │
└──────────┬─────────────┘
│
┌──────────▼─────────────┐
│ A/B Testing │ ← User preference
│ (V1 vs V2 quality) │
└──────────┬─────────────┘
│
┌──────────▼─────────────┐
│ Integration Tests │ ← System behavior
│ (End-to-end flows) │
└──────────┬─────────────┘
│
┌──────────▼─────────────┐
│ Unit Tests │ ← Fast, automated
│ (Code correctness) │
└────────────────────────┘

1. Unit Testing Strategy​

Coverage Requirements​

PackageTarget CoverageStatus
@idiomark/core (types-v2.ts)100%⬜
@idiomark/core (analyzers)90%⬜
@idiomark/core (prompts-v2)85%⬜
@idiomark/core (readers-v2)90%⬜
@idiomark/cli (V2 commands)80%⬜

Test Categories​

1.1 Type Validation Tests​

// packages/core/src/__tests__/types-v2.test.ts
import { validateIdiomarkFileV2, PersonalityV2 } from '../types-v2'

describe('PersonalityV2 Type Validation', () => {
describe('Big Five Personality', () => {
it('should accept valid OCEAN scores', () => {
const valid: BigFivePersonality = {
openness: 0.75,
conscientiousness: 0.6,
extraversion: 0.5,
agreeableness: 0.8,
neuroticism: 0.3,
confidence: 0.85
}

expect(() => validateBigFive(valid)).not.toThrow()
})

it('should reject scores outside 0-1 range', () => {
const invalid = { openness: 1.5, conscientiousness: 0.5, ... }
expect(() => validateBigFive(invalid)).toThrow()
})

it('should require all five traits', () => {
const incomplete = { openness: 0.5, conscientiousness: 0.5 } as any
expect(() => validateBigFive(incomplete)).toThrow()
})
})

describe('Linguistic Markers', () => {
it('should accept valid pronoun ratios', () => {
const valid: LinguisticMarkers = {
pronouns: {
first_person_singular: 0.05,
first_person_plural: 0.02,
second_person: 0.08
}
}
expect(validateLinguisticMarkers(valid)).toBe(true)
})

it('should validate hedge frequency', () => {
const validFrequencies = ['low', 'medium', 'high'] as const
validFrequencies.forEach(freq => {
const markers = { hedging: { frequency: freq, common_hedges: [] } }
expect(validateLinguisticMarkers(markers)).toBe(true)
})
})
})
})

1.2 Analyzer Tests​

// packages/core/src/__tests__/analyzers/linguistic-markers.test.ts
import { LinguisticMarkerAnalyzer } from '../analyzers/linguistic-markers'

describe('LinguisticMarkerAnalyzer', () => {
const analyzer = new LinguisticMarkerAnalyzer()

describe('Pronoun Detection', () => {
it('should count first-person singular pronouns', () => {
const text = "I went to the store. My car broke down."
const result = analyzer.analyze(text)

expect(result.pronouns.first_person_singular).toBeCloseTo(2/11, 1)
})

it('should distinguish between I and we', () => {
const text = "I think we should go together."
const result = analyzer.analyze(text)

expect(result.pronouns.first_person_singular).toBeGreaterThan(0)
expect(result.pronouns.first_person_plural).toBeGreaterThan(0)
expect(result.pronouns.first_person_singular)
.not.toBe(result.pronouns.first_person_plural)
})

it('should be case-insensitive', () => {
const text1 = "I think"
const text2 = "i think"

const result1 = analyzer.analyze(text1)
const result2 = analyzer.analyze(text2)

expect(result1.pronouns.first_person_singular)
.toBe(result2.pronouns.first_person_singular)
})
})

describe('Hedge Detection', () => {
it('should identify common hedge words', () => {
const text = "Maybe we could possibly try it."
const result = analyzer.analyze(text)

expect(result.hedging.frequency).not.toBe('low')
expect(result.hedging.common_hedges).toContain('maybe')
})

it('should classify hedge frequency correctly', () => {
const lowText = "I am sure about this."
const mediumText = "It might be somewhat good."
const highText = "Maybe perhaps it could be sort of okay."

const low = analyzer.analyze(lowText)
const medium = analyzer.analyze(mediumText)
const high = analyzer.analyze(highText)

expect(low.hedging.frequency).toBe('low')
expect(medium.hedging.frequency).toBe('medium')
expect(high.hedging.frequency).toBe('high')
})
})

describe('Performance', () => {
it('should analyze 1000 words in under 50ms', () => {
const longText = generateText(1000)
const start = performance.now()

analyzer.analyze(longText)

const duration = performance.now() - start
expect(duration).toBeLessThan(50)
})
})
})

1.3 Prompt Builder Tests​

// packages/core/src/__tests__/prompts-v2.test.ts
import { buildResponsePromptV2 } from '../prompts-v2'

describe('V2 Prompt Builder', () => {
it('should include Big Five when present', () => {
const personality = {
big_five: { openness: 0.8, ... }
}

const prompt = buildResponsePromptV2(personality, "Hello")

expect(prompt).toContain('Openness')
expect(prompt).toContain('80%')
})

it('should skip missing dimensions', () => {
const personality = {
big_five: { openness: 0.8, ... }
// linguistic_markers not present
}

const prompt = buildResponsePromptV2(personality, "Hello")

expect(prompt).toContain('Openness')
expect(prompt).not.toContain('Linguistic Markers')
})

it('should format scores as percentages', () => {
const personality = {
big_five: { openness: 0.75, ... }
}

const prompt = buildResponsePromptV2(personality, "Hello")

expect(prompt).toContain('75%')
expect(prompt).not.toContain('0.75')
})
})

2. Integration Testing​

2.1 End-to-End Extraction Flow​

// packages/core/src/__tests__/integration/extraction-v2.test.ts
import { PersonalityAnalyzer } from '../analyzer'
import { loadReader } from '../reader'

describe('V2 Extraction Integration', () => {
it('should extract V1 and V2 simultaneously', async () => {
const analyzer = new PersonalityAnalyzer({
provider: 'anthropic',
apiKey: process.env.ANTHROPIC_API_KEY,
enableV2: true
})

const samples = [
"I really enjoy trying new things and exploring ideas.",
"We should work together to solve this problem.",
"Perhaps we might consider another approach."
]

const result = await analyzer.analyze(samples)

// Should have V1 data
expect(result.personality).toBeDefined()
expect(result.personality.voice).toBeDefined()

// Should have V2 data
expect(result.personality_v2).toBeDefined()
expect(result.personality_v2.big_five).toBeDefined()
})

it('should fall back to V1 when V2 fails', async () => {
// Mock V2 failure
const analyzer = new PersonalityAnalyzer({
provider: 'anthropic',
apiKey: 'invalid-key',
enableV2: true
})

const result = await analyzer.analyze(["test"])

// Should still have V1
expect(result.personality).toBeDefined()
// V2 might be undefined
expect(result.personality_v2).toBeUndefined()
})

it('should produce valid Idiomark file', async () => {
const analyzer = new PersonalityAnalyzer({ enableV2: true, ... })
const result = await analyzer.analyze(samples)

const idiomarkFile = toIdiomarkFile(result)

// Validate schema
const validation = validateIdiomarkFileV2(idiomarkFile)
expect(validation.valid).toBe(true)
})
})

2.2 CLI Integration Tests​

# tests/cli/v2-extraction.test.sh
#!/bin/bash

describe "idiomark extract with V2"
it "should extract with --experimental flag"
run idiomark extract --twitter --output test.idiomark.json --experimental
assert_success
assert_file_exists test.idiomark.json

# Verify V2 data present
run jq -e '.personality_v2.big_five' test.idiomark.json
assert_success
end

it "should not extract V2 without flag"
run idiomark extract --twitter --output test.idiomark.json
assert_success

run jq -e '.personality_v2' test.idiomark.json
assert_failure # V2 should not exist
end

it "should show V2 info with idiomark info"
run idiomark info test-v2.idiomark.json
assert_output_contains "Big Five Personality"
assert_output_contains "Linguistic Markers"
end
end

3. A/B Testing Framework​

3.1 Test Design​

// packages/core/src/testing/ab-test.ts
export interface ABTestScenario {
id: string
personality: PersonalityV2
testMessages: string[]
evaluationCriteria: EvaluationCriteria
}

export interface EvaluationCriteria {
authenticity: number // 1-5: How authentic does response feel?
consistency: number // 1-5: Does it match the personality?
preference: 'v1' | 'v2' | 'tie' // Which version do you prefer?
quality_notes?: string
}

export class ABTestRunner {
async runPersonalityTest(scenario: ABTestScenario): Promise<TestResults> {
const results = {
v1Responses: [],
v2Responses: [],
evaluations: []
}

for (const message of scenario.testMessages) {
// Generate with V1 prompt
const v1Response = await this.generateWithV1(
scenario.personality,
message
)
results.v1Responses.push(v1Response)

// Generate with V2 prompt
const v2Response = await this.generateWithV2(
scenario.personality,
message
)
results.v2Responses.push(v2Response)

// Collect evaluation
const evaluation = await this.evaluate(
message,
v1Response,
v2Response,
scenario.evaluationCriteria
)
results.evaluations.push(evaluation)
}

return this.calculateStatistics(results)
}

private async evaluate(
question: string,
v1Response: string,
v2Response: string,
criteria: EvaluationCriteria
): Promise<Evaluation> {
// For automated testing: use another LLM
// For manual testing: present to human evaluators

return {
question,
v1Response,
v2Response,
authenticity_v1: await this.rateAuthenticity(v1Response),
authenticity_v2: await this.rateAuthenticity(v2Response),
preference: criteria.preference
}
}

private calculateStatistics(results: TestResults): TestStatistics {
const v2Wins = results.evaluations.filter(e => e.preference === 'v2').length
const v1Wins = results.evaluations.filter(e => e.preference === 'v1').length
const ties = results.evaluations.filter(e => e.preference === 'tie').length

const total = results.evaluations.length
const v2WinRate = v2Wins / total

// Calculate statistical significance (chi-square test)
const pValue = this.chiSquareTest(v2Wins, v1Wins, ties)

return {
v2WinRate,
v1WinRate: v1Wins / total,
tieRate: ties / total,
significant: pValue < 0.05,
pValue,
sampleSize: total
}
}
}

3.2 Test Scenarios​

// packages/core/src/testing/scenarios.ts
export const AB_TEST_SCENARIOS: ABTestScenario[] = [
{
id: 'high-openness',
name: 'High Openness Personality',
personality: {
big_five: {
openness: 0.9,
conscientiousness: 0.5,
extraversion: 0.6,
agreeableness: 0.7,
neuroticism: 0.4
},
communication_style: {
question_frequency: 0.7,
self_disclosure: 0.6,
explanation_style: 'detailed'
}
},
testMessages: [
"What's your opinion on trying a new programming language?",
"How do you approach unfamiliar problems?",
"Tell me about a time you tried something new."
]
},
{
id: 'low-openness',
name: 'Low Openness Personality',
personality: {
big_five: {
openness: 0.2,
conscientiousness: 0.8,
extraversion: 0.4,
agreeableness: 0.6,
neuroticism: 0.3
},
communication_style: {
question_frequency: 0.2,
self_disclosure: 0.3,
explanation_style: 'concise'
}
},
testMessages: [
"What's your opinion on trying a new programming language?",
"How do you approach unfamiliar problems?",
"Do you prefer established methods or new approaches?"
]
},
{
id: 'high-hedging',
name: 'High Hedging Communication Style',
personality: {
linguistic_markers: {
hedging: {
frequency: 'high',
common_hedges: ['maybe', 'perhaps', 'might', 'could']
}
}
},
testMessages: [
"Is this the right approach?",
"What should we do next?",
"Can you give me a definite answer?"
]
}
]

3.3 Running A/B Tests​

# Run A/B tests locally
pnpm test:ab --scenario high-openness --samples 100

# Run full test suite
pnpm test:ab:all

# Export results for analysis
pnpm test:ab --export results.json

4. Human Evaluation Protocol​

4.1 Evaluation Interface​

// web/app/evaluate/page.tsx
'use client'

export default function ABEvaluationPage() {
const [currentTest, setCurrentTest] = useState<TestPair>()

return (
<div className="evaluation-container">
<h2>Personality Response Evaluation</h2>

<div className="test-prompt">
<strong>Question:</strong> {currentTest.question}
</div>

<div className="responses-grid">
<div className="response-a">
<h3>Response A</h3>
<p>{currentTest.responseA}</p>

<div className="evaluation-form">
<label>Authenticity (1-5):</label>
<input type="range" min={1} max={5} />

<label>Consistency with personality (1-5):</label>
<input type="range" min={1} max={5} />
</div>
</div>

<div className="response-b">
<h3>Response B</h3>
<p>{currentTest.responseB}</p>

<div className="evaluation-form">
<label>Authenticity (1-5):</label>
<input type="range" min={1} max={5} />

<label>Consistency with personality (1-5):</label>
<input type="range" min={1} max={5} />
</div>
</div>
</div>

<div className="preference">
<h3>Which response do you prefer?</h3>
<button>Response A</button>
<button>Response B</button>
<button>No preference</button>
</div>

<button onClick={submitEvaluation}>Submit & Next</button>
</div>
)
}

4.2 Evaluation Criteria​

CriterionDescriptionScale
AuthenticityDoes response sound like a real person?1-5
ConsistencyDoes response match personality profile?1-5
QualityIs response helpful and coherent?1-5
PreferenceWhich response is better overall?A/B/Tie

4.3 Target Metrics​

MetricMinimum TargetIdeal Target
V2 Preference Rate> 55%> 70%
V2 Authenticity> 3.5/5> 4.0/5
V2 Consistency> 3.5/5> 4.0/5
Statistical Significancep < 0.05p < 0.01
Sample Size> 100 evaluations> 500 evaluations

5. Research Validation​

5.1 Big Five Validation​

Goal: Verify extracted OCEAN scores correlate with validated personality assessments.

Method:

  1. Extract Idiomark profile from users with known Big Five scores
  2. Compare Idiomark scores to validated assessments
  3. Calculate correlation coefficients

Success Criteria:

  • Pearson correlation r > 0.7 for each trait
  • Statistically significant (p < 0.01)
// Validate against IPIP-NEO inventory results
const validateBigFive = async (idiomarkScores: BigFive, ipipScores: BigFive) => {
const correlations = {
openness: pearson(idiomarkScores.openness, ipipScores.openness),
conscientiousness: pearson(idiomarkScores.conscientiousness, ipipScores.conscientiousness),
extraversion: pearson(idiomarkScores.extraversion, ipipScores.extraversion),
agreeableness: pearson(idiomarkScores.agreeableness, ipipScores.agreeableness),
neuroticism: pearson(idiomarkScores.neuroticism, ipipScores.neuroticism)
}

const valid = Object.values(correlations).every(r => r > 0.7)
return { correlations, valid }
}

5.2 Linguistic Markers Validation​

Goal: Validate against LIWC (Linguistic Inquiry and Word Count) research.

Method:

  1. Run Idiomark analyzer on LIWC validation texts
  2. Compare to LIWC software output
  3. Calculate accuracy metrics

Success Criteria:

  • Pronoun detection accuracy > 95%
  • Hedge detection precision > 90%
  • Absolutist detection precision > 90%

6. Continuous Validation​

6.1 Monitoring Dashboard​

Metrics to track continuously:

// packages/core/src/monitoring/metrics.ts
export interface V2QualityMetrics {
extraction: {
successRate: number // % of successful V2 extractions
avgDuration: number // Average extraction time (ms)
failureReasons: Record<string, number> // Why do extractions fail?
}

quality: {
v2PreferenceRate: number // % of users preferring V2
avgAuthenticity: number // Average authenticity rating
avgConsistency: number // Average consistency rating
}

coverage: {
bigFiveRate: number // % with Big Five data
linguisticRate: number // % with linguistic markers
communicationRate: number // % with communication style
}

performance: {
v2Overhead: number // Additional time for V2 (ms)
v2MemoryIncrease: number // Additional memory usage (MB)
}
}

6.2 Alert Thresholds​

MetricWarningCritical
Extraction success rate< 95%< 90%
V2 preference rate< 50%< 40%
Extraction duration> 500ms> 1000ms
Memory overhead> 50MB> 100MB

7. Test Execution Schedule​

Weekly Tests (Automated)​

# Run every Monday at 2 AM UTC
0 2 * * 1 pnpm test:unit --coverage
0 3 * * 1 pnpm test:integration

Monthly Tests (Manual + Automated)​

# Run first of each month
- Full A/B test suite (100+ scenarios)
- Performance benchmarking
- Research validation against datasets

Quarterly Reviews​

  • Comprehensive evaluation of all V2 dimensions
  • Graduation decisions based on metrics
  • Prompt and algorithm refinements

8. Success Criteria​

Phase 1 (Weeks 1-4)​

  • Unit test coverage > 80% for V2 code
  • All integration tests passing
  • CLI can extract V2 data end-to-end

Phase 2 (Weeks 5-12)​

  • Each V2 dimension has unit tests
  • A/B testing framework operational
  • 100+ test extractions completed

Phase 3 (Weeks 13-20)​

  • > 500 human evaluations collected
  • Statistical significance achieved for ≥ 2 dimensions
  • Clear graduation recommendations

Phase 4 (Weeks 21-24)​

  • Graduated dimensions validated against research
  • V1.1 release with validated features
  • Continuous monitoring in place

Document Owner: Idiomark Quality Team Review Cadence: Weekly Last Updated: 2026-02-11