Skip to content

fix: respect entity_type param and map purpose→type for context mints#12

Merged
chitcommit merged 2 commits intomainfrom
fix/entity-type-param
Mar 17, 2026
Merged

fix: respect entity_type param and map purpose→type for context mints#12
chitcommit merged 2 commits intomainfrom
fix/entity-type-param

Conversation

@chitcommit
Copy link
Member

@chitcommit chitcommit commented Mar 17, 2026

Summary

  • entity_type query param was ignored — only type and for were read
  • for=context mapped to raw "context" which had no entry in ENTITY_TYPES, defaulting to T (Thing)
  • Now: entity_type is highest priority, and a PURPOSE_ENTITY_MAP resolves purpose values like contextperson (P)

Root cause

// Before: only reads type/for, "context" falls through to default T
const rawType = (url.searchParams.get('type') || url.searchParams.get('for') || 'thing')

Test plan

  • GET /api/get-chittyid?for=context returns entity type P
  • GET /api/get-chittyid?entity_type=P returns entity type P
  • GET /api/get-chittyid?for=thing still returns T
  • GET /api/get-chittyid?type=person still returns P
  • Deploy to id.chitty.cc and verify with can chitty authenticate-context

Related

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added support for a new "Authority" entity type to the system's supported types.
    • Entity type can now be explicitly overridden during ID generation, providing greater flexibility in type assignment.
    • Expanded recognition of additional purpose categories to improve entity type mapping.

Nick Bianchi and others added 2 commits March 16, 2026 10:37
The canonical governance (chittycanon://gov/governance#core-types) mandates
5 entity types: P/L/T/E/A. Several code paths only accepted 4, rejecting
Authority (A):

- config/index.js entityTypes map
- services/vrf-generator.js validation
- agents/validator.js validTypes array

Also fixes the pipeline to map "context" and "agent" purposes to Person (P)
instead of defaulting to Thing (T), and respects explicit entity_type query
parameter override in the API handler.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The entity_type query parameter was being ignored — only `type` and `for`
were read. When `for=context`, the raw value "context" had no mapping in
ENTITY_TYPES, causing fallback to T (Thing) instead of P (Person).

Changes:
- Add entity_type as highest-priority param (explicit override)
- Add PURPOSE_ENTITY_MAP for purpose values (context→person, claude→person)
- Fixes contexts always getting T instead of P

Ref: chittycanon://gov/governance#core-types

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
chittyid c8dfaa3 Mar 17 2026, 12:54 AM

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 01ebb242-a8aa-414b-9dac-335cf1817861

📥 Commits

Reviewing files that changed from the base of the PR and between 7451433 and c8dfaa3.

📒 Files selected for processing (6)
  • src/agents/validator.js
  • src/api/index.js
  • src/config/index.js
  • src/pipeline/index.js
  • src/services/vrf-generator.js
  • worker.js

📝 Walkthrough

Walkthrough

The pull request adds a new entity type 'A' (Authority) to the ChittyID system and introduces an optional override mechanism for entity type selection during ID generation. Entity type validations, configuration mappings, and purpose-to-type mappings are updated across the service layers to support the new type and override functionality.

Changes

Cohort / File(s) Summary
Entity Type Configuration
src/config/index.js, src/agents/validator.js, src/services/vrf-generator.js
Added 'A' (Authority) to the entity type mappings and validation lists. Updated validation error messages and added canonical reference comments.
API & Request Handling
src/api/index.js
Extracts entity_type from request URL and passes it as an override parameter to the pipeline. Updated public API specification to include the new 'A' entity type mapping.
Pipeline Processing
src/pipeline/index.js
Introduced optional entityTypeOverride parameter to the process() method signature. Added validation logic to use override when provided and valid, otherwise falls back to purpose-based mapping. Extended purpose-to-entity-type mapping to include authority, context, and agent.
Worker Process
worker.js
Added PURPOSE_ENTITY_MAP for mapping context-based purposes to entity types. Updated handleDirectChittyIdGeneration() to prioritize explicit entity_type parameter and apply additional mapping logic before defaulting to rawType.

Sequence Diagram

sequenceDiagram
    participant Client
    participant API as API Handler
    participant Pipeline as ChittyPipeline
    participant Config as Config
    participant Service as ID Service

    Client->>API: POST request with entity_type parameter
    API->>API: Extract entity_type override from URL
    API->>Pipeline: process(request, purpose, entityTypeOverride)
    Pipeline->>Config: Validate entityTypeOverride against allowed types
    alt Override valid
        Pipeline->>Pipeline: Use entityTypeOverride
    else Override invalid or not provided
        Pipeline->>Pipeline: Map purpose to entity type
    end
    Pipeline->>Service: Generate ID with selected entity type
    Service->>Service: Validate entity type in ["P","L","T","E","A"]
    Service-->>Pipeline: Return generated ID
    Pipeline-->>API: Return ID response
    API-->>Client: ChittyID response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

A rabbit hops through systems new, 🐰
With 'A' for Authority breaking through,
Overrides flow from request to stage,
Purpose maps dance across each page,
ChittyID's palette now richer than before!

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/entity-type-param
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chitcommit chitcommit merged commit 1645775 into main Mar 17, 2026
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant