I rebuilt the distinction between the current tab, an explicit destination and reference tabs as independent Python code. It uses no actual accounts or manuscripts. The purpose is to expose the checks needed before a tool acts on the wrong destination, not to supply another browser driver.

Narrow the question before writing the function

resolve_request receives a trusted work scope, an inventory of existing tabs and an already interpreted intent. It is not a universal natural-language destination detector. For a request to use cafe material in a blog, another layer must separate destination and reference before calling it. I did not combine language interpretation and deterministic routing into one implied capability.

The scope contains exactly profile, project and current. The intent contains destination, tab and references. Unknown fields fail validation, so adding a key such as execute does not create an operation. This is a newly authored synthetic contract rather than a copy of every selection feature in the production browser.

Define precedence for defaults and explicit choices

Without a destination, the request-time current tab is selected. If the declared destination matches its platform, that tab remains the target. Otherwise the resolver searches only the supplied profile and project. One match is accepted, several produce DESTINATION_AMBIGUOUS, and none produces DESTINATION_NOT_OPEN. It never chooses the first available candidate arbitrarily.

An explicit tab must exist inside the scope. If a destination is also supplied and conflicts with that tab's declared platform, the input is rejected. Additional information cannot justify ignoring a more specific field. This example opens no tabs and changes no accounts; returning a missing choice to the caller is an intentional outcome.

References must not become the writing destination

References are checked after the target is resolved. Only existing tabs in scope are allowed; duplicate references and a reference identical to the target are rejected. The result keeps target and reference_tabs in separate fields. A downstream reader should not replace the stored target with whichever reference tab was selected most recently.

The result explicitly reports creates_tab and acts_on_page as false. This is a pure planning function and does not modify the supplied dictionaries or list. Receiving a valid result is not authorization to operate a real browser. The execution host must still recheck ownership, authentication and current document state at the action boundary.

Explore the implementation

Complete independent synthetic implementation

"""Independent synthetic request routing. No browser, account or filesystem access."""
from dataclasses import dataclass

class ContextError(ValueError):
    def __init__(self,code):self.code=code;super().__init__(code)

def exact(value,keys,code):
    if not isinstance(value,dict) or set(value)!=set(keys):raise ContextError(code)
def text(value):
    if not isinstance(value,str) or not value or value!=value.strip() or len(value)>80:raise ContextError('INVALID_TEXT')

def resolve_request(scope,tabs,intent):
    """Resolve declared intent once. This does not infer intent from natural language."""
    exact(scope,['profile','project','current'],'INVALID_SCOPE')
    for v in scope.values():text(v)
    exact(intent,['destination','tab','references'],'INVALID_INTENT')
    if not isinstance(tabs,list) or not 1<=len(tabs)<=100:raise ContextError('INVALID_TABS')
    if not isinstance(intent['references'],list) or len(intent['references'])>10:raise ContextError('INVALID_REFERENCES')
    for field in ['destination','tab']:
        if intent[field] is not None:text(intent[field])
    for ref in intent['references']:text(ref)
    ids=[]
    for t in tabs:
        exact(t,['id','profile','project','platform'],'INVALID_TAB')
        for v in t.values():text(v)
        ids.append(t['id'])
    if len(set(ids))!=len(ids):raise ContextError('DUPLICATE_TAB')
    allowed=[t for t in tabs if t['project']==scope['project'] and t['profile']==scope['profile']]
    byid={t['id']:t for t in allowed}
    current=byid.get(scope['current'])
    if not current:raise ContextError('CURRENT_TAB_OUTSIDE_SCOPE')
    explicit=intent['tab'];destination=intent['destination']
    if explicit:
        target=byid.get(explicit)
        if not target:raise ContextError('TARGET_OUTSIDE_SCOPE')
        if destination and target['platform']!=destination:raise ContextError('DESTINATION_CONFLICT')
        reason='explicit-existing-tab'
    elif not destination or current['platform']==destination:
        target=current;reason='request-time-current-tab'
    else:
        matches=[t for t in allowed if t['platform']==destination]
        if not matches:raise ContextError('DESTINATION_NOT_OPEN')
        if len(matches)>1:raise ContextError('DESTINATION_AMBIGUOUS')
        target=matches[0];reason='unique-existing-destination'
    refs=intent['references']
    if len(refs)!=len(set(refs)):raise ContextError('DUPLICATE_REFERENCE')
    if any(x not in byid for x in refs):raise ContextError('REFERENCE_OUTSIDE_SCOPE')
    if target['id'] in refs:raise ContextError('TARGET_IS_REFERENCE')
    return {'scope':{'profile':scope['profile'],'project':scope['project']},'target':target['id'],'reference_tabs':list(refs),'reason':reason,'creates_tab':False,'acts_on_page':False}

Test rejected choices as carefully as accepted ones

Eighteen tests cover the current tab, explicit destinations, reference handling, current-tab preference among same-platform candidates, ambiguity and absence. They also check another profile's tab, conflicting declarations, duplicate IDs, a stale current tab and invalid references. Non-string values, unknown fields and input immutability have separate assertions.

After passing in the source folder, I compared ZIP-entry hashes, extracted the public package into a new G-drive test folder and actually ran the same eighteen tests there. These are tests of synthetic routing rules. They did not switch a live website account or use an unfinished customer manuscript as a fixture.

The frame reads records rather than operating the browser

The five records were generated by actual local Python execution. They show the current target, separated references, an ambiguous destination, a scope violation and a missing destination. The selector displays those stored outcomes; it does not run Python or browser-control code in the frame and reads no visitor account or files.

I compare displayed values with the package records and execute the actual inline selection code for both languages against DOM stubs. That is not rendered-browser or keyboard-accessibility verification. The Python module tests and the read-only viewer checks establish different things, and both are identified rather than combined into one claim.

A read-only viewer of synthetic local records

What an adapter must supply for real work

The ZIP contains the complete implementation, tests, record generator and README. It uses only the Python standard library and permits modification and reuse. Profile and project must come from a trusted authenticated host. Platform labels are declared metadata, not verified URLs. Trusting an arbitrary external tab inventory would undermine the protection this resolver is meant to support.

A multi-account system must deliberately extend the single-profile scope and enforce its own permissions. It must also recheck changes between planning and action. The module supplies no atomic browser operation, durable job storage or login-validity check. Those are the next decisions an adapter must make, and they belong beside the downloadable code.

Download code, tests and records
Python standard library, synthetic data, modification and reuse permitted