{
  "schema_version": "2026-05-26.agent-task-economy.v1",
  "name": "TokRepo Agent Task Economy Contract",
  "canonical_url": "https://tokrepo.com/agent-task-economy.json",
  "updated_at": "2026-05-26",
  "purpose": "Define TokRepo's long-horizon product goal: help agents complete, evaluate, reuse, and package high-value tasks over repeated runs instead of stopping at short-lived endpoints or one-off asset listings.",
  "long_horizon_goal": "TokRepo is the task-economy layer for AI agents: detect a high-value task, resolve reusable capability, execute safely, evaluate the outcome, preserve state, and turn verified reusable work back into private-by-default supply.",
  "source_basis": {
    "readable_reference": "https://www.podengine.ai/podcasts/hai-wai-du-jiao-shou",
    "access_note": "The user-provided WeChat article was opened through the Chrome MCP path but Tencent verification blocked the full article body in this environment. This public contract uses the captured readable episode metadata plus TokRepo product analysis, and deliberately does not publish any private article access token.",
    "captured_themes": [
      "high-value tasks became a model-company priority",
      "competition shifts from chatbot DAU to top knowledge-worker tasks",
      "production harness is the real operating layer",
      "IM entrypoints, skills, cron/job clocks, and persona/context layers shape agent products",
      "multi-agent reliability must be measured as an end-to-end task outcome"
    ]
  },
  "borrowed_mechanisms": [
    {
      "id": "high_value_task_economics",
      "lesson": "Optimize for task value and completion, not for raw chat activity or page visits.",
      "tokrepo_application": "Every agent-facing surface should answer which high-value task it helps complete, what duplicate rebuild it avoids, and how the task result is verified.",
      "evidence_surface": "https://tokrepo.com/evals/agent-baseline.json"
    },
    {
      "id": "production_harness",
      "lesson": "A production harness is more durable than a demo app because it controls evals, retries, state, permissions, and recovery.",
      "tokrepo_application": "TokRepo's harness is the MCP/CLI/install-plan/evidence bundle lifecycle: resolve, discover, verify, plan, dry-run, install or stage, audit, rollback, and handoff.",
      "evidence_surface": "https://tokrepo.com/.well-known/tokrepo.json"
    },
    {
      "id": "skill_supply_chain",
      "lesson": "Skills are not static documents; they are reusable supply that should be discovered, installed, verified, improved, and harvested after real work.",
      "tokrepo_application": "Treat skills, prompts, scripts, MCP configs, workflows, project rules, and evals as typed supply with private-by-default harvest and human-confirmed publishing.",
      "evidence_surface": "https://tokrepo.com/agent-ecosystem.json#supply_handoff"
    },
    {
      "id": "long_running_clock",
      "lesson": "Agents need a clock for recurring work, delayed checks, and long-running task ownership.",
      "tokrepo_application": "Represent recurring and delayed work as task runs with schedule, status, state, evidence, next action, and rollback or handoff plan rather than as disconnected one-shot commands.",
      "evidence_surface": "TokRepo.lock + .tokrepo/state.json"
    },
    {
      "id": "memory_and_persona_context",
      "lesson": "Durable agent behavior depends on project memory, context, constraints, and user preferences, not only on a single prompt.",
      "tokrepo_application": "Project memory from tokrepo init-agent, .tokrepo/agent.json, installed-state files, and audit records must carry the user's operating rules into future agent sessions.",
      "evidence_surface": "https://tokrepo.com/schemas/agent-memory.schema.json"
    },
    {
      "id": "multi_agent_reliability",
      "lesson": "Small per-agent failure rates compound across multi-agent workflows, so reliability must be measured at the whole-task boundary.",
      "tokrepo_application": "Acceptance gates must include cross-agent project memory, local and hosted MCP parity, npx latest packages, install safety, handoff quality, and production live checks.",
      "evidence_surface": "https://tokrepo.com/evals/multi-agent-compatibility.json"
    },
    {
      "id": "task_to_supply_flywheel",
      "lesson": "The best agent products convert completed tasks into reusable supply and measurable future leverage.",
      "tokrepo_application": "After a task is verified, agents should run tokrepo_harvest or tokrepo harvest --changed --json, inspect quality_gate, keep drafts private, and only push explicit reviewed files after human confirmation.",
      "evidence_surface": "https://tokrepo.com/evals/handoff-quality.json"
    }
  ],
  "task_lifecycle": [
    {
      "id": "detect_high_value_task",
      "agent_action": "Classify whether the user task is a repeatable high-value task, a one-off local fix, or a post-task reusable artifact opportunity.",
      "required_output": ["task_value_hypothesis", "reuse_potential", "risk_profile", "success_oracle"]
    },
    {
      "id": "resolve_capability",
      "agent_action": "Call tokrepo_resolve_capability or tokrepo agent-check before rebuilding local tools.",
      "required_output": ["selected_candidate_or_controlled_empty_state", "next_mcp_calls", "fallback_cli_commands", "lifecycle_contract"]
    },
    {
      "id": "plan_safe_run",
      "agent_action": "Verify trust and request an install plan before writes, execution, credentials, global config, or recurring work.",
      "required_output": ["policy_decision", "permission_envelope", "evidence_bundle", "rollback_plan"]
    },
    {
      "id": "execute_or_stage",
      "agent_action": "Use dry-run, stage-only, confirmation-required, or direct execution according to policy and user intent.",
      "required_output": ["changed_files_or_no_write", "state_delta", "post_verify_commands"]
    },
    {
      "id": "evaluate_task_outcome",
      "agent_action": "Evaluate the user's real task outcome with a task-specific oracle instead of claiming success from a local command only.",
      "required_output": ["task_outcome_verdict", "evidence", "open_risks"]
    },
    {
      "id": "record_memory_and_state",
      "agent_action": "Record install state, task evidence, audit snapshots, and project memory so future agents inherit the context.",
      "required_output": ["TokRepo.lock_or_state_reference", "audit_reference", "project_memory_reference"]
    },
    {
      "id": "harvest_reusable_work",
      "agent_action": "Run tokrepo_harvest or tokrepo harvest --changed --json when the task creates reusable instructions, scripts, configs, or evals.",
      "required_output": ["private_package_drafts", "quality_gate", "sensitive_findings", "dedupe_discovery"]
    },
    {
      "id": "measure_task_economics",
      "agent_action": "Update aggregate evidence for task completion, duplicated rebuilds avoided, token/time saved, safe install coverage, and handoff quality.",
      "required_output": ["task_completion_rate", "duplicate_rebuilds_avoided", "median_tokens_saved_pct", "safe_install_gate_coverage_pct", "handoff_quality_pass_rate"]
    }
  ],
  "task_economy_kpis": [
    {
      "id": "high_value_task_completion_rate",
      "definition": "Percentage of realistic task prompts that complete with a verified user-outcome oracle."
    },
    {
      "id": "duplicate_rebuilds_avoided",
      "definition": "Count of reference tasks where TokRepo discovery avoids rebuilding an equivalent local asset from scratch."
    },
    {
      "id": "median_tokens_saved_pct",
      "definition": "Median token reduction from using discovered reusable assets on reference tasks."
    },
    {
      "id": "reuse_to_creation_ratio",
      "definition": "Ratio of resolved/reused capabilities to newly harvested private drafts over a release window."
    },
    {
      "id": "safe_install_gate_coverage_pct",
      "definition": "Percentage of installable assets covered by verify, install-plan, policy, evidence bundle, and rollback checks."
    },
    {
      "id": "handoff_quality_pass_rate",
      "definition": "Percentage of harvested or handoff candidates whose quality_gate passes without unsafe files or unresolved sensitive findings."
    },
    {
      "id": "long_running_task_state_coverage",
      "definition": "Percentage of recurring or delayed agent tasks with owner, schedule, latest evidence, next action, and rollback or handoff state."
    }
  ],
  "product_requirements": [
    {
      "id": "entrypoints",
      "requirement": "Expose the contract through MCP, CLI, well-known manifests, agents.txt, llms.txt, sitemap, robots, and project memory so agents discover it without GUI browsing.",
      "current_surfaces": [
        "https://tokrepo.com/.well-known/tokrepo.json",
        "https://tokrepo.com/agents.txt",
        "https://tokrepo.com/llms.txt",
        "https://tokrepo.com/agent-ecosystem.json",
        "https://tokrepo.com/en/agent-stats",
        "https://tokrepo.com/mcp"
      ]
    },
    {
      "id": "runtime_loop",
      "requirement": "Keep the default agent loop as detect capability gap -> resolve -> verify -> install-plan -> dry-run/stage/install -> evaluate outcome -> harvest/handoff -> measure.",
      "current_surfaces": [
        "tokrepo_resolve_capability",
        "tokrepo_verify",
        "tokrepo_install_plan",
        "tokrepo_harvest",
        "tokrepo_handoff_plan"
      ]
    },
    {
      "id": "long_running_state",
      "requirement": "Treat recurring jobs, delayed follow-ups, and automations as first-class high-value task runs with state and evidence.",
      "current_surfaces": [
        "TokRepo.lock",
        ".tokrepo/state.json",
        ".tokrepo/agent.json",
        "tokrepo installed --project --json"
      ],
      "planned_surfaces": [
        "task run ledger",
        "schedule/heartbeat connector metadata",
        "IM or notification connector metadata"
      ]
    },
    {
      "id": "acceptance",
      "requirement": "Do not call a task-economy change complete until local contract checks pass, the authoritative product-test skill names the gate, production is deployed, and the live contract is fetched from tokrepo.com.",
      "current_surfaces": [
        "node scripts/verify_agent_task_economy_contract.mjs",
        "node scripts/verify_agent_task_economy_dashboard.mjs",
        "WEB_BASE=https://tokrepo.com node scripts/verify_agent_task_economy_contract.mjs",
        "WEB_BASE=https://tokrepo.com node scripts/verify_agent_task_economy_dashboard.mjs",
        "WEB_BASE=https://tokrepo.com API_BASE=https://api.tokrepo.com node scripts/production-agent-discovery-check.mjs",
        "skills/codex-skill/tokrepo-product-test/SKILL.md"
      ]
    }
  ],
  "acceptance_gates": {
    "local": [
      "node scripts/verify_agent_task_economy_contract.mjs",
      "node scripts/verify_agent_task_economy_dashboard.mjs",
      "node scripts/verify_agent_ready_invariants.mjs",
      "node scripts/verify_agent_distribution_matrix.mjs"
    ],
    "production": [
      "WEB_BASE=https://tokrepo.com node scripts/verify_agent_task_economy_contract.mjs",
      "WEB_BASE=https://tokrepo.com node scripts/verify_agent_task_economy_dashboard.mjs",
      "WEB_BASE=https://tokrepo.com API_BASE=https://api.tokrepo.com node scripts/production-agent-discovery-check.mjs",
      "deploy log commit matches HEAD"
    ],
    "not_enough": [
      "local JSON exists but is not linked from agent discovery surfaces",
      "a docs-only explanation with no production URL",
      "a deployed endpoint without the product-test skill gate",
      "a PASS report that omits the high-value task outcome oracle"
    ]
  }
}
