Skip to content

YujunZhou/tellonce / codex

tellonce

Verified

Use to view, explain, correct, delete or reorganize the user's saved preferences, or to record one by hand when automatic recording is off; learning and rule injection otherwise run automatically through Codex hooks.

FileKindSize
.codex-plugin/plugin.jsonconfig1.3 KB
SKILL.mdskill md12.0 KB
dashboard.shexecutablescript348 B
docs/CC_PARITY_MATRIX.mdmarkdown7.3 KB
docs/README.mdmarkdown3.4 KB
doctor.shexecutablescript345 B
hooks/hooks.jsonconfig714 B
hooks/posttooluse-deterministic-block.shexecutablescript2.0 KB
hooks/sessionstart-init.shexecutablescript1.9 KB
hooks/userpromptsubmit-dispatch.pyscript2.6 KB
hooks/userpromptsubmit-memory-upsert.shscript326 B
hooks/userpromptsubmit-pending-inject.shexecutablescript2.0 KB
hooks/userpromptsubmit-retrieve-inject.shexecutablescript3.1 KB
hooks/userpromptsubmit-shadow-alert-inject.shexecutablescript1.2 KB
install.shexecutablescript13.9 KB
shared_lib/_install_merge_settings.pyscript12.1 KB
shared_lib/_pt_hooks.txtmarkdown407 B
shared_lib/correction_interpretation.pyscript8.5 KB
shared_lib/detect_user_prefer.pyscript7.2 KB
shared_lib/deterministic_block.pyscript9.3 KB
shared_lib/event_obligations.pyscript19.8 KB
shared_lib/execution_support.pyscript75.8 KB
shared_lib/fingerprints.yamlconfig1.1 KB
shared_lib/learning_policy.pyscript4.6 KB
shared_lib/memory_judge.pyscript84.8 KB
shared_lib/memory_publication.pyscript14.9 KB
shared_lib/memory_runtime.pyscript12.2 KB
shared_lib/memory_store.pyscript99.6 KB
shared_lib/memory_upsert.pyscript57.1 KB
shared_lib/memory_upsert_hook.pyscript4.6 KB
shared_lib/model_requests.pyscript5.8 KB
shared_lib/path_config.pyscript13.3 KB
shared_lib/pending_queue_manager.pyscript23.4 KB
shared_lib/pt_platform.pyscript1.5 KB
shared_lib/redaction.pyscript3.4 KB
shared_lib/retrieve_inject.pyexecutablescript57.9 KB
shared_lib/rule_selection.pyscript18.9 KB
shared_lib/shadow_alert_inject.pyscript6.1 KB
shared_lib/training_memory.pyscript17.8 KB
shared_lib/transcript_adapter.pyscript13.7 KB
shared_lib/verify_compliance.pyexecutablescript24.5 KB
shared_lib/verify_retry_shadow.pyscript27.4 KB
tellonce_codex/__init__.pyscript52 B
tellonce_codex/__main__.pyscript49 B
tellonce_codex/cli.pyscript6.8 KB
tellonce_codex/codex_posttooluse_block.pyscript11.2 KB
tellonce_codex/dashboard.pyscript3.4 KB
tellonce_codex/doctor.pyscript10.9 KB
tellonce_codex/index.pyscript1.8 KB
tellonce_codex/install.pyscript3.1 KB
tellonce_codex/install_codex_hooks.pyscript15.1 KB
tellonce_codex/ledger.pyscript17.1 KB
tellonce_codex/memory.pyscript5.3 KB
tellonce_codex/migrate.pyscript1.3 KB
tellonce_codex/mode.pyscript2.3 KB
tellonce_codex/paths.pyscript8.6 KB
tellonce_codex/promote.pyscript4.4 KB
tellonce_codex/scan.pyscript2.6 KB
tellonce_codex/uninstall.pyscript1.7 KB
tellonce_codex/verify.pyscript5.3 KB
tellonce_codex/wrapper.pyscript12.0 KB
uninstall.shexecutablescript4.6 KB

shared_lib/model_requests.py

View on GitHub
"""Label model work at its call site and give each request one retry owner."""
import re
import time


class ModelRequestError(RuntimeError):
    retry_exhausted=True
    def __init__(self, role, attempts, error_types, *, retry_after_s=None):
        self.attempts=attempts
        self.error_types=tuple(error_types)
        self.retry_after_s=retry_after_s
        super().__init__(f'{role} request unavailable after {attempts} attempts')


def exhausted_request(error):
    """Do not give a queue another retry budget after a bounded model request."""
    seen=set()
    while error is not None and id(error) not in seen:
        seen.add(id(error))
        if isinstance(error,ModelRequestError):
            return True
        error=error.__cause__ or error.__context__
    return False


def learning_recovery_delay(error):
    """One separate recovery epoch for transient transport failures and for answers that failed validation.

    A request whose answers were produced but rejected by the local validator (2026-10-04: every failed learner
    turn in rounds 20-23 was of this kind, e.g. an evidence span that is not a literal quote) gets one fresh
    request under a new key, exactly like a transport timeout; a second exhaustion is final."""
    transient={'provider_timeout','provider_rate_limited','provider_service_unavailable',
               'provider_network_unavailable','response_validation_failed'}
    seen=set()
    while error is not None and id(error) not in seen:
        seen.add(id(error))
        if isinstance(error,ModelRequestError):
            if not error.error_types or any(code not in transient for code in error.error_types):
                return None
            delay=error.retry_after_s
            if delay is None:
                return 5.0
            if type(delay) in {int,float} and 0<=delay<=60:
                return max(5.0,float(delay))
            return None
        error=error.__cause__ or error.__context__
    return None


def bind_context(invoke, context):
    """Create an immutable role-call scope from host identities, never prompts."""
    fields={'namespace','phase','scope','task_id','session_id','event_id'}
    if (not isinstance(context,dict) or set(context)!=fields or
            any(not isinstance(v,str) or not v.strip() or not 1<=len(v)<=480 for v in context.values()) or
            context['phase'] not in {'preparation','training','test'} or
            context['scope'] not in {'user_event','publication'}):
        raise ValueError('complete bounded model invocation origin required')
    method=(getattr(invoke,'for_context',None) if callable(getattr(type(invoke),'for_context',None)) else None)
    if method is None:
        return invoke  # Plain single-attempt synthetic/compatibility callbacks.
    bound=method(dict(context))
    if not callable(bound):
        raise ValueError('a model context must produce an explicit callable owner')
    return bound


def request_validated(invoke, prompt, *, role, validate, max_attempts=2, request_key=None, repair=None):
    if (not callable(invoke) or not callable(validate) or not isinstance(prompt,str) or
            not isinstance(role,str) or not re.fullmatch('[a-z][a-z0-9_]{0,63}',role) or
            type(max_attempts) is not int or max_attempts not in {1,2} or
            (repair is not None and not callable(repair)) or
            (request_key is not None and (not isinstance(request_key,str) or not request_key.strip() or len(request_key)>480))):
        raise ValueError('explicit role, bounded attempts and response validator required')
    owner=(getattr(invoke,'request_validated',None)
           if callable(getattr(type(invoke),'request_validated',None)) else None)
    if callable(owner):
        # The experiment owner supplies task/phase identity, durable request
        # recovery and a single-attempt provider. Never wrap it in another loop.
        keyed={'request_key':request_key} if request_key is not None else {}
        repair_owner=(getattr(invoke,'request_validated_with_repair',None)
                      if callable(getattr(type(invoke),'request_validated_with_repair',None)) else None)
        if repair is not None and repair_owner is not None:
            result=repair_owner(prompt,role=role,validate=validate,max_attempts=max_attempts,
                                repair=repair,**keyed)
        else:
            # Legacy external owners keep their original retry policy; only an
            # explicit protocol implementation may own a changed second input.
            result=owner(prompt,role=role,validate=validate,max_attempts=max_attempts,**keyed)
        if (not isinstance(result,tuple) or len(result)!=2 or type(result[1]) is not int or
                not 0<=result[1]<=max_attempts):
            raise ValueError('managed model request must return its validated value and actual bounded attempt count')
        return result
    errors=[]
    next_prompt=prompt
    for attempt in range(1,max_attempts+1):
        raw=None
        try:
            raw=invoke(next_prompt)
            return validate(raw),attempt
        except Exception as exc:
            if exhausted_request(exc):
                raise
            errors.append(type(exc).__name__)
            delay=getattr(exc,'retry_after_s',None)
            if getattr(exc,'retryable',True) is False or attempt==max_attempts:
                break
            if repair is not None and isinstance(raw,str):
                next_prompt=repair(prompt,raw,exc)
                if not isinstance(next_prompt,str) or not next_prompt.strip():
                    raise ValueError('repair must return a nonempty bounded prompt')
            if delay is not None:
                if type(delay) not in {int,float} or not 0<=delay<=60:
                    break
                time.sleep(delay)
    raise ModelRequestError(role,attempt,errors,retry_after_s=delay) from None
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 323kUpdated Claude CodeCodexVerifiedInstall