COS v0.2 Draft ChaptersSingle pageJSON Schema

Context Object Specification (COS)

Version: 0.2
Chapter: 510 — Best Practices
Status: Informative
Category: Adoption & Evolution


1. Purpose

This chapter defines recommended practices for implementing and extending the Context Object Specification (COS).

These practices help maintain:


2. Core Philosophy

COS follows the principle:

Keep the Core minimal, keep Extensions flexible, keep Capabilities composable.

A healthy COS implementation should preserve:


3. Keep Core Model Stable

3.1 Principle

The Core Model represents universal concepts.

Core fields SHOULD only contain concepts shared across domains.


Good:

interface Selection {
  text: string;
  range?: Range;
}

Bad:

interface Selection {
  pdfPageNumber:number;
  domPath:string;
  codeSymbol:string;
}

3.2 Rule

Before adding a Core field, ask:

Does every COS implementation need this concept?

If the answer is no:

Use Extension.

4. Prefer Extension Over Core Modification

Domain-specific information SHOULD be placed in Extensions.

Example:

PDF:

{
  "extensions": [
    {
      "namespace": "org.example.pdf",
      "version": "1.0.0",
      "payload": {
        "page": 12
      }
    }
  ]
}

Code:

{
  "extensions": [
    {
      "namespace": "org.example.code",
      "version": "1.0.0",
      "payload": {
        "symbol": "calculate"
      }
    }
  ]
}

Do not introduce:

Document {
  pdfInfo;
  codeInfo;
}

5. Keep Plugin Boundaries Clear

A Plugin provides capabilities.

A Plugin SHOULD NOT become:

Correct:

Plugin
↓
Capability
↓
Context Enrichment

Incorrect:

Plugin
↓
Complete Application

6. Use Adapter for Translation

Adapters exist at system boundaries.

Their responsibility:

External Representation
        ↓
COS Representation

Adapters SHOULD:

Adapters SHOULD NOT:

7. Keep Pipeline Stages Focused

Each Pipeline Stage SHOULD have a single responsibility.

Good:

Selection Stage
↓
Source Stage
↓
Context Stage

Bad:

AI Stage

does:

- parsing
- analysis
- recommendation
- storage
- UI rendering

8. Progressive Context Enrichment

Context Objects SHOULD be enriched progressively.

Recommended:

Selection Created
        ↓
Source Attached
        ↓
Context Segments Added
        ↓
Relations Added

Avoid blocking the entire Context Object until all processing completes.

9. Preserve Original Context

The original user context SHOULD remain unchanged.

Example:

Original:

{
 "selection":{
   "text":"original text"
 }
}

AI result:

{
 "extensions":{
   "summary":"generated summary"
 }
}

Do not overwrite:

{
 "selection":{
   "text":"AI rewritten text"
 }
}

10. AI Should Be a Consumer

AI is a capability consumer, not the foundation of COS.

Relationship:

Context Object
        ↓
AI Consumer
        ↓
Result

COS SHOULD NOT depend on:

11. Prefer Capability-Based Design

Consumers SHOULD request capabilities.

Preferred:

Requires:

semantic.analysis

Avoid:

Requires:

OpenAIPluginV3

Capabilities allow:

12. Design for Partial Availability

A Context Object does not need every field populated.

Example:

Available:

Selection

Source

context.segments

Later:

context.relations

extensions or meta

Systems SHOULD handle partial contexts gracefully.

13. Avoid Context Overloading

Context Object SHOULD represent:

User attention and relevant information.

It SHOULD NOT become:

Bad:

{
 "context":{
   "userSettings":{},
   "shoppingCart":{},
   "permissions":{}
 }
}

14. Version Extensions Independently

Extensions SHOULD maintain independent evolution.

Example:

COS

v0.2


PDF Extension

v1.5

Do not require:

COS update

for every Extension change

15. Design for Observability

Implementations SHOULD provide visibility into:

Example:

context.created
↓
context.relations.completed
↓
extensions.updated

16. Handle Failure Gracefully

A failed enrichment SHOULD NOT destroy existing context.

Example:

Optional Enrichment Failed
        ↓
Context remains usable

Prefer:

{
 "status":"partial",
 "available":[
   "selection",
   "source",
   "context.segments"
 ]
}

17. Security Considerations

Implementations SHOULD:

Browser-based implementations SHOULD treat page URL, title, DOM path, selected text, and surrounding text as potentially sensitive.

Consumers SHOULD request only the Context Object fields and Extension namespaces required for their task.

18. Performance Guidance

Implementations SHOULD make basic context available quickly and defer expensive enrichment.

Recommended behavior:

Implementations MAY define local size and latency budgets.

When a budget is exceeded, the Pipeline SHOULD emit a partial Context Object instead of blocking availability.

19. Recommended Architecture

A recommended COS implementation:

                 Consumer
                    ↑
             Context Object
                    ↑
               Pipeline
                    ↑
              Adapter
                    ↑
             External System

Plugins extend capabilities without breaking this structure.

20. Common Mistakes

Mistake 1

Putting domain fields into Core.

Solution:

Use Extension.

Mistake 2

Making Plugin responsible for everything.

Solution:

Separate Adapter, Pipeline, Consumer.

Mistake 3

Embedding AI concepts into protocol.

Solution:

Keep AI as Consumer.

Mistake 4

Treating Context as database storage.

Solution:

Keep Context focused on active user attention.

21. Summary

Best Practices ensure that COS remains:

The fundamental rule:

Preserve the Core, extend through Plugins, enrich through Pipeline, and consume through Context-aware systems.