Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 29, 2026

Description

Protocol audit revealed multiple naming convention violations in object metadata. Fixed field type casing (autonumber vs autoNumber) and corrected all object machine names to use lowercase/snake_case as required by @objectstack/spec v0.6.1 protocol. Added validation tooling to prevent future violations. Updated agent documentation to reflect correct naming conventions.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • CI/CD update

Related Issues

N/A - Internal protocol compliance audit

Changes Made

Code Fixes:

  • packages/finance/src/contract.object.ts: Changed type: 'autonumber'type: 'autoNumber' (camelCase required by spec)
  • All 8 object files: Changed object name property from PascalCase to lowercase/snake_case:
    • Accountaccount
    • Activityactivity
    • Contactcontact
    • Leadlead
    • Opportunityopportunity
    • Contractcontract
    • Quotequote
    • Casecase

Validation Infrastructure:

  • scripts/validate-protocol.js: Automated validator for object names (lowercase/snake_case), field names (PascalCase), field types, and object structure
  • Returns exit code 0/1 for CI/CD integration
  • Validates all 8 objects (248 fields, 18 relationships)

Documentation:

  • PROTOCOL_COMPLIANCE.md: Protocol requirements reference with corrected naming conventions, field type catalog, best practices
  • README.md: Added compliance status reference
  • .github/agents/metadata-developer.md: Updated with correct naming conventions (object names: snake_case, field names: PascalCase), corrected Product example, and clarified best practices section

Validation Results:

  • ✅ All object names use lowercase/snake_case (machine name convention)
  • ✅ All field names use PascalCase (API name convention)
  • ✅ All 16 field types valid per @objectstack/spec v0.6.1
  • ✅ Zero protocol violations after fixes

Testing

  • Unit tests pass (npm test)
  • Linting passes (npm run lint)
  • Build succeeds (npm run build)
  • Manual testing completed
  • New tests added (if applicable)

Validation script executed:

node scripts/validate-protocol.js
# ✅ ALL OBJECTS COMPLIANT WITH @objectstack/spec v0.6.1

Screenshots

N/A - Metadata changes only

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Naming Convention Rules (per @objectstack/spec v0.6.1):

  • ✅ Object names (machine names): snake_case - e.g., name: 'account', name: 'project_task'
  • ✅ Field names (API names): PascalCase - e.g., FirstName, AccountId, AnnualRevenue
  • ✅ Field types: camelCase - e.g., autoNumber not autonumber
  • ✅ Metadata keys: camelCase - e.g., trackHistory, apiEnabled

Common Mistakes Fixed:

  • name: 'Account' → ✅ name: 'account'
  • type: 'autonumber' → ✅ type: 'autoNumber'

Q&A from Review:

  • Q: Are there similar conventions for field names?
  • A: Yes! Field names (Field API Names) must use PascalCase (e.g., FirstName, AccountId, AnnualRevenue). All 248 fields in the codebase already follow this convention correctly.

Run validation before metadata commits: node scripts/validate-protocol.js

Original prompt

按照objectstack spec标准协议的要求确认所有的字段名是否满足协议规则以及其他元数据的内容,字段是否满足协议规则


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link

vercel bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
hotcrm Ready Ready Preview, Comment Jan 29, 2026 2:29am

Request Review

- Fixed Contract.ContractNumber field type: 'autonumber' → 'autoNumber'
- Added comprehensive protocol compliance documentation
- Created automated validation script for future use
- All 8 objects (248 fields, 18 relationships) now fully compliant

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Verify field names for objectstack spec compliance Fix ObjectStack spec v0.6.1 protocol compliance - field type casing Jan 29, 2026
Copilot AI requested a review from hotlong January 29, 2026 02:18
@hotlong
Copy link
Contributor

hotlong commented Jan 29, 2026

@copilot 我记得协议约定的这段名必须要小写

Copy link
Contributor Author

Copilot AI commented Jan 29, 2026

@copilot 我记得协议约定的这段名必须要小写

您说得对!根据 @objectstack/spec 协议规范,对象的 name 属性(machine name)必须使用 snake_case 小写格式。

我会立即修正所有 8 个对象的 name 属性:

  • Accountaccount
  • Activityactivity
  • Contactcontact
  • Leadlead
  • Opportunityopportunity
  • Contractcontract
  • Quotequote
  • Casecase

正在修复中...

@hotlong
Copy link
Contributor

hotlong commented Jan 29, 2026

@copilot 是不是字段名也有类似的约定?

- Changed all object 'name' properties from PascalCase to lowercase
- Updated validation script to enforce lowercase/snake_case for object names
- Updated PROTOCOL_COMPLIANCE.md with correct naming conventions
- Objects: account, activity, contact, lead, opportunity, contract, quote, case

Per @objectstack/spec protocol: machine names (object.name) use snake_case,
while field API names use PascalCase.

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title Fix ObjectStack spec v0.6.1 protocol compliance - field type casing Fix ObjectStack spec v0.6.1 protocol compliance - naming conventions Jan 29, 2026
Copy link
Contributor Author

Copilot AI commented Jan 29, 2026

@copilot 是不是字段名也有类似的约定?

是的!字段名(Field API Name)也有明确的约定:

字段名必须使用 PascalCase(首字母大写的驼峰命名)

示例:

  • FirstName(名)
  • LastName(姓)
  • AccountId(客户ID)
  • AnnualRevenue(年营收)
  • BillingStreet(账单街道)

命名规范总结:

  • 对象名(machine name): snake_case 小写 → name: 'account'
  • 字段名(API name): PascalCase 首字母大写 → FirstName, AccountId
  • 元数据键(metadata keys): camelCase 小驼峰 → trackHistory, apiEnabled

当前代码库中所有 248 个字段都已经正确使用 PascalCase 命名,无需修改。✅

- Object names use snake_case (not PascalCase)
- Field names use PascalCase
- Updated example from 'Product' to 'product'
- Clarified naming conventions in best practices section

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@hotlong hotlong marked this pull request as ready for review January 29, 2026 03:19
Copilot AI review requested due to automatic review settings January 29, 2026 03:19
@hotlong hotlong merged commit 0c4610f into main Jan 29, 2026
5 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes ObjectStack spec v0.6.1 protocol compliance violations in object metadata. The primary changes correct naming conventions (object names from PascalCase to lowercase/snake_case, field type from autonumber to autoNumber) and add validation infrastructure.

Changes:

  • Fixed all 8 object metadata files to use lowercase/snake_case for object names (e.g., Accountaccount)
  • Corrected field type casing in contract.object.ts (autonumberautoNumber)
  • Added automated protocol validation script with comprehensive checks
  • Created detailed protocol compliance documentation and updated agent guidelines

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/validate-protocol.js New automated validator for protocol compliance checking
packages/crm/src/account.object.ts Changed object name from 'Account' to 'account'
packages/crm/src/activity.object.ts Changed object name from 'Activity' to 'activity'
packages/crm/src/contact.object.ts Changed object name from 'Contact' to 'contact'
packages/crm/src/lead.object.ts Changed object name from 'Lead' to 'lead'
packages/crm/src/opportunity.object.ts Changed object name from 'Opportunity' to 'opportunity'
packages/finance/src/contract.object.ts Changed object name to 'contract' and fixed field type to 'autoNumber'
packages/products/src/quote.object.ts Changed object name from 'Quote' to 'quote'
packages/support/src/case.object.ts Changed object name from 'Case' to 'case'
PROTOCOL_COMPLIANCE.md New comprehensive protocol compliance documentation
README.md Added reference to protocol compliance documentation
.github/agents/metadata-developer.md Updated with correct naming conventions and examples

return;
}

const fieldMatch = line.match(/^\s{4}([A-Za-z][A-Za-z0-9_]*):\s*\{/);
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field matching regex uses exactly 4 spaces (^\s{4}), but the actual code uses 2-space indentation. This will cause the regex to fail matching field names in the actual object files. The regex should be more flexible to match the actual indentation, such as ^\s{2}([A-Za-z][A-Za-z0-9_]*):\s*\{ for 2-space indentation, or better yet, use a more flexible pattern like ^\s+([A-Za-z][A-Za-z0-9_]*):\s*\{ to handle any amount of indentation.

Suggested change
const fieldMatch = line.match(/^\s{4}([A-Za-z][A-Za-z0-9_]*):\s*\{/);
const fieldMatch = line.match(/^\s+([A-Za-z][A-Za-z0-9_]*):\s*\{/);

Copilot uses AI. Check for mistakes.
- ✅ `BillingStreet`
- ✅ `IsDecisionMaker`

### 2. Field Type Specification
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both "Field Naming Convention" (line 36) and "Field Type Specification" (line 52) are numbered as section "### 2.". The Field Type Specification section should be numbered "### 3." to maintain correct sequential numbering.

Suggested change
### 2. Field Type Specification
### 3. Field Type Specification

Copilot uses AI. Check for mistakes.
Comment on lines +189 to +194
2. **Field Types:**
- Use `autoNumber` not `autonumber`
- Use `select` not `picklist`
- Use `lookup` not `reference`

3. **Object Properties:**
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both "Field Names" (line 184) and "Field Types" (line 189) are numbered as section "2.". The Field Types section should be numbered "3." to maintain correct sequential numbering.

Suggested change
2. **Field Types:**
- Use `autoNumber` not `autonumber`
- Use `select` not `picklist`
- Use `lookup` not `reference`
3. **Object Properties:**
3. **Field Types:**
- Use `autoNumber` not `autonumber`
- Use `select` not `picklist`
- Use `lookup` not `reference`
4. **Object Properties:**

Copilot uses AI. Check for mistakes.
Comment on lines +194 to +200
3. **Object Properties:**
- Always include `name`, `label`, `icon`, and `description`
- Define `fields` object with all field metadata
- Include `listViews` for common queries
- Add `validationRules` for business logic

4. **Relationships:**
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both "Object Properties" (line 194) and "Relationships" (line 200) are numbered as sections "3." and "4." respectively, but they should be "4." and "5." to maintain correct sequential numbering given the duplicate "2." earlier in the document.

Suggested change
3. **Object Properties:**
- Always include `name`, `label`, `icon`, and `description`
- Define `fields` object with all field metadata
- Include `listViews` for common queries
- Add `validationRules` for business logic
4. **Relationships:**
4. **Object Properties:**
- Always include `name`, `label`, `icon`, and `description`
- Define `fields` object with all field metadata
- Include `listViews` for common queries
- Add `validationRules` for business logic
5. **Relationships:**

Copilot uses AI. Check for mistakes.
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.

2 participants