Skip to content

Quick Start

Get up and running with the Fetch Framework in 5 minutes.


The Formula

javascript
Fetch = Chirp × |DRIFT| × Confidence

Where:
  Chirp      = Signal strength (0-100)
  DRIFT      = Methodology − Performance (the gap)
  Confidence = min(Perch, Wake) / 100

Basic Implementation

1. Calculate Fetch Score

javascript
function calculateFetch(chirp, perch, wake, methodology, performance) {
  // Calculate DRIFT (the gap)
  const drift = Math.abs(methodology - performance);

  // Calculate confidence (weakest link)
  const confidence = Math.min(perch, wake) / 100;

  // Calculate Fetch
  const fetch = chirp * drift * confidence;

  return {
    fetch,
    drift,
    confidence
  };
}

2. Determine Action

javascript
function getAction(fetch, confidence) {
  // High confidence, high fetch
  if (fetch > 1000 && confidence > 0.60) {
    return 'execute';  // Full automation
  }

  // High fetch, low confidence
  if (fetch > 1000 && confidence <= 0.60) {
    return 'execute_with_review';  // Automate but flag
  }

  // Medium fetch
  if (fetch > 500) {
    return 'confirm';  // Ask user first
  }

  // Low-medium fetch
  if (fetch > 100) {
    return 'queue';  // Log for later
  }

  // Low fetch
  return 'wait';  // Don't act
}

3. Complete Example

javascript
// Browser automation example
const scores = {
  chirp: 90,      // Clear command: "Click Submit"
  perch: 75,      // Found button, 75% confidence
  wake: 85,       // Context from previous steps
  methodology: 80,
  performance: 20
};

const result = calculateFetch(
  scores.chirp,
  scores.perch,
  scores.wake,
  scores.methodology,
  scores.performance
);

console.log('Fetch Score:', result.fetch);
// Output: 4050

console.log('Action:', getAction(result.fetch, result.confidence));
// Output: execute

console.log('Reasoning:');
console.log('- Chirp (90): High urgency signal');
console.log('- DRIFT (60): Large gap to close');
console.log('- Confidence (0.75): Ready to act');
console.log('- Decision: Execute immediately');

TypeScript Implementation

typescript
interface DimensionScores {
  chirp: number;
  perch: number;
  wake: number;
}

interface FetchResult {
  fetch: number;
  drift: number;
  confidence: number;
  action: ActionType;
  reasoning: string;
}

type ActionType = 'execute' | 'execute_with_review' | 'confirm' | 'queue' | 'wait';

class FetchCalculator {
  calculate(
    scores: DimensionScores,
    methodology: number,
    performance: number
  ): FetchResult {
    const drift = Math.abs(methodology - performance);
    const confidence = Math.min(scores.perch, scores.wake) / 100;
    const fetch = scores.chirp * drift * confidence;

    const action = this.getAction(fetch, confidence);
    const reasoning = this.getReasoning(scores, drift, confidence, action);

    return {
      fetch,
      drift,
      confidence,
      action,
      reasoning
    };
  }

  private getAction(fetch: number, confidence: number): ActionType {
    if (fetch > 1000 && confidence > 0.60) return 'execute';
    if (fetch > 1000 && confidence <= 0.60) return 'execute_with_review';
    if (fetch > 500) return 'confirm';
    if (fetch > 100) return 'queue';
    return 'wait';
  }

  private getReasoning(
    scores: DimensionScores,
    drift: number,
    confidence: number,
    action: ActionType
  ): string {
    return `
      Chirp: ${scores.chirp} - ${this.interpretChirp(scores.chirp)}
      Perch: ${scores.perch} - ${this.interpretPerch(scores.perch)}
      Wake: ${scores.wake} - ${this.interpretWake(scores.wake)}
      DRIFT: ${drift} - ${this.interpretDrift(drift)}
      Confidence: ${confidence.toFixed(2)} - ${this.interpretConfidence(confidence)}
      Action: ${action}
    `.trim();
  }

  private interpretChirp(score: number): string {
    if (score > 80) return 'High urgency';
    if (score > 50) return 'Moderate urgency';
    return 'Low urgency';
  }

  private interpretPerch(score: number): string {
    if (score > 80) return 'Strong structure';
    if (score > 50) return 'Adequate structure';
    return 'Weak structure';
  }

  private interpretWake(score: number): string {
    if (score > 80) return 'Strong memory/pattern match';
    if (score > 50) return 'Some historical context';
    return 'Limited history';
  }

  private interpretDrift(value: number): string {
    if (value > 70) return 'Large gap to close';
    if (value > 30) return 'Moderate gap';
    return 'Small gap';
  }

  private interpretConfidence(value: number): string {
    if (value > 0.7) return 'Ready to act';
    if (value > 0.4) return 'Proceed with caution';
    return 'Not ready';
  }
}

// Usage
const calculator = new FetchCalculator();

const result = calculator.calculate(
  { chirp: 90, perch: 75, wake: 85 },
  80,  // methodology
  20   // performance
);

console.log(result);
/*
{
  fetch: 4050,
  drift: 60,
  confidence: 0.75,
  action: 'execute',
  reasoning: '...'
}
*/

Real-World Use Cases

1. Browser Automation

javascript
// Detect when to click a button
const scores = {
  chirp: 90,  // Clear "click" command
  perch: 75,  // Found button element
  wake: 85    // Context from previous actions
};

const { action } = calculateFetch(scores, 80, 20);
if (action === 'execute') {
  clickButton();
}

2. Content Publishing Decision

javascript
// Should you publish this video now?
const scores = {
  chirp: 45,  // Moderate trending signal
  perch: 80,  // Good thumbnail, title ready
  wake: 70    // Fits channel history
};

const { action } = calculateFetch(scores, 70, 35);
// Returns: 'execute' or 'confirm'

3. Trading Signal

javascript
// Should you enter this trade?
const scores = {
  chirp: 70,  // Breakout signal
  perch: 85,  // Clear support/resistance
  wake: 90    // Pattern matches historical setups
};

const { action, fetch } = calculateFetch(scores, 75, 50);
// High fetch + high confidence = execute

Decision Matrix

Urgency (Chirp)Gap (DRIFT)Ready (Confidence)Action
HighLargeHighExecute
HighLargeLowExecute + Review
HighSmallAnyConfirm
LowLargeHighConfirm
LowLargeLowQueue
LowSmallAnyWait
AnyZeroAnyWait (no gap)

The Feedback Loop

javascript
async function agentLoop(goal) {
  let drift = Infinity;
  let attempts = 0;
  const maxAttempts = 10;

  while (drift > 5 && attempts < maxAttempts) {
    // 1. Sense current state
    const scores = await measureDimensions();

    // 2. Calculate DRIFT
    const { methodology, performance } = await assessState(goal);
    drift = Math.abs(methodology - performance);

    // 3. Calculate Fetch
    const result = calculateFetch(
      scores.chirp,
      scores.perch,
      scores.wake,
      methodology,
      performance
    );

    // 4. Decide & Act
    if (result.action === 'execute' || result.action === 'execute_with_review') {
      await executeAction();
    } else if (result.action === 'confirm') {
      const approved = await askUser();
      if (approved) await executeAction();
      else break;
    } else {
      break;  // Wait or queue
    }

    // 5. Re-measure (DRIFT should decrease)
    attempts++;
  }

  return drift <= 5 ? 'success' : 'timeout';
}

Next Steps


Common Patterns

Pattern 1: Gate on Confidence

javascript
// Don't act if any dimension is too weak
if (confidence < 0.3) {
  return 'wait';  // Not ready regardless of Fetch score
}

Pattern 2: Decay Urgency Over Time

javascript
// Reduce Chirp if action is delayed
const decayedChirp = originalChirp * Math.exp(-0.1 * timeElapsed);

Pattern 3: Log All Decisions

javascript
const history = [];

function logDecision(scores, result) {
  history.push({
    timestamp: Date.now(),
    scores,
    fetch: result.fetch,
    action: result.action,
    executed: result.action === 'execute'
  });
}

Troubleshooting

Fetch score always too low?

  • Check if DRIFT is near zero (no gap to close)
  • Verify Chirp is being detected (urgency signal)
  • Ensure Perch and Wake aren't both very low

Fetch score too high (acting when shouldn't)?

  • Review confidence threshold (maybe require > 0.5)
  • Check if DRIFT calculation is correct
  • Consider adding additional gates

Actions repeating infinitely?

  • Track action history
  • Abort if same action attempted 3+ times
  • Verify DRIFT is actually decreasing after actions

Ready to dive deeper? Check out the full implementation guide.