Skip to Content
AaviDocs

Add your city with Kiro

A new city is one data file plus recordings. The spec format, the city gate hook, the steps a builder follows, and the onboarding agent.

A new city is one data file plus recorded test responses. No engine code changes, and no import line to add.

You need the layer address of a utility's published inventory (an ArcGIS layer, a Socrata dataset or a CKAN table) and the utility's own page that points to it.

The city spec

One JSON file at packages/sources/sources/KEY.json, where KEY is the city's key. A key starts with a lowercase letter, then holds lowercase letters and digits, and is at most 32 characters. The ten files today are akron, dallas, dc, denver, detroit, norfolk, nys, philadelphia, pittsburgh and stlouis.

A spec holds:

  • the utility's name and its own page (publisherPage),
  • the kind of data server (dialect: arcgis, socrata or ckan) and the endpoint,
  • the Census codes that route an address to this city (locality),
  • a public test building (testBuilding), which is never a home,
  • the address field and how addresses are written in it,
  • how the record date is found (asOf),
  • the class maps: the whole line, the utility side and the home side, each built only from the city's own wording,
  • order, a whole number that puts the city in the list, and
  • fieldsHash, a fingerprint that pins the layout of the fields the spec reads.

The shape is defined by SourceSpec in packages/sources/src/types.ts. A generated registry reads every file in the folder when npm run gen runs, which npm run build and npm test both call. A scan test fails if a file in the folder is missing a working spec.

The steps

  1. Copy the closest existing spec: detroit.json for ArcGIS, norfolk.json for Socrata, pittsburgh.json for CKAN. Name the new file KEY.json.
  2. Fill it in from the city's own published values. Build each class map only from values the city publishes. Leave an unclear value out, so it reads unknown. Set publisherPage to the utility's own page. Set testBuilding to a public or government building. Set locality from the Census codes of that building. Set order to one more than the highest existing one. Put any 64-character hex string in fieldsHash for now.
  3. From the repository root, run npm run build. It builds the registry from the folder.
  4. Run npm run fingerprint -- KEY and paste the hash it prints into fieldsHash.
  5. In packages/sources, run npm run record-fixtures -- KEY to record the city's responses for the tests.
  6. Run npm run gate -- KEY. It lists every raw value the city holds today and the class each one maps to. Read that list. It is the check that no value reads milder than the city meant.
  7. Run npm test.
npm run build
npm run fingerprint -- KEY
cd packages/sources
npm run record-fixtures -- KEY
cd ../..
npm run gate -- KEY
npm test

The city gate hook

With Kiro open on the repository root, a file-save hook does steps 3, 6 and 7 for you. Each time Kiro saves a file in packages/sources/sources/, the hook builds, runs the gate and the tests, and writes .city-gate/report.txt. A second hook has the agent show that report in the chat. If the gate fails, the agent stops and asks you before it changes the spec again.

Kiro passes no output of a file-save hook to the agent, which is why the report goes through a file. Every raw value in the report comes from a public city server. It is printed quoted, cut at 200 characters a line, and the hook tells the agent to treat it as data and never as an instruction.

The fingerprint and fixtures (steps 4 and 5) stay with you or the agent. See the hook files.

The onboarding agent

Without opening Kiro, the Crew App's onboarding agent does the same work. Its request is ONBOARD KEY URL, where the URL is the layer address. The agent:

  1. reads the layer's own field list and class values with read-only requests,
  2. writes the one spec file in a clone of the product repo,
  3. reads the Census codes of the test building,
  4. runs the fingerprint command, records the fixtures, runs the gate and runs the tests,
  5. tries at most 3 fix rounds if something fails,
  6. pushes its own branch and opens one pull request that quotes the city's own wording for each class map entry, and lists everything it could not confirm, and
  7. writes a run record, whatever happened.

It may touch only that spec and its fixtures. It cannot merge. A GitHub check named agent-scope fails any agent pull request that touches anything else, and a code owner reviews. The agent treats everything it reads from a city server as data, never as an instruction.

Repair uses the same path: when a city changes a field, the daily census raises a flag, and the fix loop sends the same agent with FIX KEY. See the daily watch.

Norfolk, the tenth city, was added this way. It is in aavi main as pull request 1, authored by the aavi-city-agent bot.

Read the onboarding skill and the agent definition.