Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Tag-Oriented Programming (TOP)™

Compose semantic layers on one stable object identity.

TOP is a programming paradigm: a Target keeps its identity while Tags add meaning, species, roles, backgrounds, capabilities, that cut across ordinary class hierarchies. Where traditional code asks "what is this object?", TOP asks "what is this object for, here?", and lets the answer grow. The inspiration is tabletop character creation: species, class, background and feats are independent choices, and the character sheet is what they compose.

from TopKit import Tag, Record, Action, Underlay, Pre

class Character:
    def __init__(self, name, level):
        self.name, self.level = name, level

class Elf(Tag):
    @Record
    def spells(agent, stored):                 # piles up with other Tags
        return (stored or []) + ["Light"]

class Wizard(Tag):
    @Pre
    def Can_Study(agent):
        return agent.level >= 1

    @Record
    def spells(agent, stored):
        return (stored or []) + ["Magic Missile"]

    def Attack(agent):
        return f"{agent.name} casts {agent.spells[-1]}"

class War_Caster(Tag):
    @Pre
    def Is_A_Caster(agent):                    # synergy: needs Wizard
        return agent in Wizard

    @Action
    @Underlay
    def Attack(agent, underlay):
        return underlay() + " while holding a shield"

ari = Character("Ari", level=3)
Elf(ari); Wizard(ari); War_Caster(ari)

assert ari in Wizard                           # active membership
assert ari.spells == ["Light", "Magic Missile"]
assert ari.Attack() == "Ari casts Magic Missile while holding a shield"
assert ari.Wizard.Attack() == "Ari casts Magic Missile"   # the view after Wizard

Read TopKit/GUIDE.md for the patterns, and run examples/dnd_character.py and examples/biome.py for the long form; examples/fleet_patching.py and examples/crew_access.py for the design patterns Pins and published members give you.

This repository

Path What License
spec/SPECIFICATION.md The Specification, written in rings from the kernel outward. The source of truth. CC-BY-4.0
TopKit/GUIDE.md The Guide: TOP for people, pattern by pattern. Start here. Apache-2.0
TopKit/ TopKit, the Python reference implementation (the T is the Tag in T.O.P.). Apache-2.0
TopKit/CONTRACTS.md The Contracts Guide: gates, promises, membership and error control, aboard a starship. Apache-2.0
tests/ The conformance suite, organized by ring. Apache-2.0
examples/ A D&D character sheet, a mix-and-match biome, a drone fleet patched through Pins, a starship crew under published members. Each is a set of design patterns. Apache-2.0
benchmarks/ The runtime budget: reads, calls, tagging, memory. Apache-2.0
steps/ STEPs, Standard TOP Enhancement Proposals. CC-BY-4.0
RELEASING.md How TopKit reaches PyPI, and what to check first. Apache-2.0

The Specification is the source of truth. TopKit demonstrates it and must perform as the Specification describes; any gap in TopKit is TopKit's to fix, not a change to TOP.

Using TopKit

pip install .                         # or: PYTHONPATH=. python3 ...
PYTHONPATH=. python3 -m unittest tests.test_topkit tests.test_examples
PYTHONPATH=. python3 benchmarks/bench.py

Python 3.10 or later, no dependencies. TopKit is built so that an Agent's attribute reads and Action calls cost what they cost on a plain object; tagging is the slower, rarer act.

Conformance

An implementation in any language is welcome. "TOP-conformant" means it preserves the observable semantics in the Specification, ring by ring, and passes the conformance suite. See CONFORMANCE.md. The TOP Verified mark is granted by the steward, so the standard stays meaningful.

Governance & contributing

TOP is led by a Director, with a path to shared governance; see GOVERNANCE.md. Propose changes through the STEP process (CONTRIBUTING.md); every decision is recorded, in the open, with its reason.

License & trademark

Code is Apache-2.0; the Specification and STEPs are CC-BY-4.0. "Tag-Oriented Programming", "TOP", and "TopKit" are trademarks; see TRADEMARK.md. You may implement the paradigm freely; the marks identify the official spec and conformant implementations.

© 2026 Julio Toboso.

Metadata

Release files for topkit 0.2.0a3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for topkit 0.2.0a3
File Size Uploaded
topkit-0.2.0a3.tar.gz 52.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for topkit 0.2.0a3
File Interpreter ABI Platform
topkit-0.2.0a3-py3-none-any.whl Python 3 none any Details

Total release size: 94.3 kB

Release files / topkit-0.2.0a3.tar.gz

Download URL topkit-0.2.0a3.tar.gz
Size 52.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d25934bd1a5590b05d355d0da5971786253356232b3b338baac977fb159df3c9
BLAKE2b-256 checksum
How to use checksums
15d626adaed7e1d8446048c1316bc10780dab1615ef428ff2f2aec51179e40c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / topkit-0.2.0a3-py3-none-any.whl

Download URL topkit-0.2.0a3-py3-none-any.whl
Size 41.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73a50986aff2424ed1b71cab67cc42e9ef768461ee1f6975810c5209fffb1e67
BLAKE2b-256 checksum
How to use checksums
7c55430ef218b81cc8bcb7d72f62ec7a1e4f7d5c4b2091501cbe2010b0829b2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.2.0a3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page