newton3

A behaviour score anyone can check, worked out from the event log every time it is read.

What it is

Newton decides who gets a shared space, such as a parking spot, a desk or a charger, when more people want one than there are. Admins set priority. Newton 3 adds a behaviour score, which orders people only among those with equal priority, where a random draw would otherwise decide.

The score is one pure function of a person's events, the tenant's policy and the time:

score(events, config, now) = max(floor, base + min(rewards, cap) + penalties)
  • Always current. No score is stored, so none goes stale, and no job runs to decay it.
  • Each event fades on its own clock. Its points shrink across its window, then it drops out of the sum.
  • The explanation is the arithmetic. Each event's points add up to the score, and the API returns them with it.
  • One engine, any policy. A tenant's weights, windows, cap and floor are a Config, passed in.
  • Every rejection says why: the rank, the bracket above, or the score that got the space.
  • Python's standard library only. The engine is pure, so the tests use no mocks.

How it works

  1. Each thing a person does is appended to their log: a no-show, a free space taken, an offence, a carpool.
  2. When the score is read, events past their window are dropped and the rest are faded by their age.
  3. Rewards are capped, penalties added, the sum rounded half up and kept above the floor.
  4. Allocation ranks by admin priority, then by score within a bracket. Repeat offenders can be ranked last, by a count, whatever their score.
  5. Each person gets the decision and the reason for it.

Try it

This is engine.py itself, running in your browser on Pyodide. Start from one of the API's demo users, add events, and slide them back in time.

Loading Python and the engine…

Run it here

The repo's own commands, on its own files, in your browser. The data is the synthetic set in docs/artifacts.


      

Use it

It needs Python 3.10 or later:

git clone https://github.com/iguigova/newton3 && cd newton3
pip install -e . pytest
pytest                          # the tests
python -m newton.cli demo       # a ranking, its decisions and one API response
python -m newton.app            # the read API on 127.0.0.1:8000
curl -s localhost:8000/users/bob/behavior-score

The README and docs/README.md hold the design, its critique and the open questions.

Edges

  • The data is synthetic, made by docs/artifacts/generate_synthetic_data.py. No real people are in it.
  • The store is in memory. The AWS design, on Lambda, DynamoDB and EventBridge, is in the docs and not built.
  • Under the default policy no one reaches Platinum: the base plus the reward cap stays below its floor.
  • With the default windows the score barely moves over three months of history. analysis.impact shows it, and shows a longer memory telling abuse from need.
  • The default policy charges a point for taking a free space. REEVALUATION.md argues for dropping it.
  • The offence override is only as fair as the offence detection behind it.
  • The no-show model in analysis.predict sets how many requests to admit, never who.
  • The page downloads Python, some megabytes, the first time it opens.