Skip to content

feat: add CategorySchema validator with tests and examples (#1)#3

Merged
keepsloading merged 1 commit into
Memact:mainfrom
Kunall7890:feat/category-schema-validator
Jun 3, 2026
Merged

feat: add CategorySchema validator with tests and examples (#1)#3
keepsloading merged 1 commit into
Memact:mainfrom
Kunall7890:feat/category-schema-validator

Conversation

@Kunall7890

Copy link
Copy Markdown

Closes #1

What this adds

  • src/contracts/category-schema.v0.mjs — CategorySchema validator
  • examples/category-schema.v0.json — valid example JSON
  • 6 new tests added to test/contracts.test.mjs
  • Exported from src/index.mjs

Schema fields

  • Required: id, name, version, schema_version
  • Optional: description, contextFields, exampleInputs,
    normalizedOutputShape, wikiTemplates,
    permissionSuggestions, safetyNotes

Tests

node --test passes — 11 tests, 0 failures

@Kunall7890

Copy link
Copy Markdown
Author

Closes #1

Changes

  • Added src/contracts/category-schema.v0.mjs
  • Added examples/category-schema.v0.json
  • Added 6 new tests in test/contracts.test.mjs
  • Exported validateCategorySchema from src/index.mjs

How to verify locally

1. Clone the repo

git clone https://github.com/YOUR_USERNAME/Contracts.git
cd Contracts

2. Install dependencies

npm install

3. Run tests

npm test

Expected test output

✔ valid capture event passes
✔ missing event_type fails
✔ invalid confidence fails
✔ valid schema packet and feature manifest pass
✔ invalid feature result status fails
✔ valid minimal category schema passes
✔ valid full category schema passes
✔ missing id fails
✔ missing name fails
✔ missing version fails
✔ wrong type for contextFields fails

tests 11 | pass 11 | fail 0

Manual usage example

import { validateCategorySchema } from "@memact/contracts"

// Valid input
validateCategorySchema({
schema_version: "memact.category_schema.v0",
id: "cat-001",
name: "Technology",
version: "1.0.0"
})
// Returns: { ok: true, value: { ... } }

// Invalid input
validateCategorySchema({
schema_version: "memact.category_schema.v0",
name: "Technology"
})
// Returns: { ok: false, errors: [{ path: "id", message: "Required field is missing." }] }

@keepsloading keepsloading merged commit eba8422 into Memact:main Jun 3, 2026
@keepsloading

Copy link
Copy Markdown
Member

Hey @Kunall7890, first of all, great work on this CategorySchema validator! It's been successfully merged here.

We noticed that the SSoC leaderboard crawler only scans the main Memact/Context repository, which means contributions on Memact/Contracts aren't being tracked automatically on the leaderboard.

To make sure you get full credit and points on the leaderboard with virtually zero extra load on your end:

  1. We can create a quick issue on the Memact/Context repository to integrate/document your validator.
  2. We'll set up the changes in a branch so you just need to open a quick 1-line PR on Context pointing to it (which takes less than a minute of copy-paste) to get it merged and tracked under your profile!

Let me know if you are up for this, and we will set up the issue/branch for you!

@keepsloading

Copy link
Copy Markdown
Member

Hi @Kunall7890 👋 I noticed that you have successfully contributed and merged this PR, but your handle is currently not showing up on the official SSoC 2026 leaderboard. Please reach out to the SSoC mentors/admins to ensure your registration is correctly linked so you receive your points. Thanks for your contribution!

@keepsloading

Copy link
Copy Markdown
Member

Hi @Kunall7890 👋 I noticed that this PR has been merged, but there is no corresponding dummy PR created in the main Context repository (Memact/Context) referencing this work. For SSoC26 tracking, please make sure to open a dummy PR in Memact/Context so your merged contribution can be verified and counted on the leaderboard. Thank you!

@keepsloading

Copy link
Copy Markdown
Member

No corresponding dummy PR was found in Memact/Context. Please create one referencing Memact/Contracts#3 so this contribution can be tracked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CategorySchema validator

2 participants